Let the operator set the agent's managed settings through claude-code
managed-settings.json carried only the mesh's fixed keys, so permissions and auto-mode rules could only be set by hand per machine, outside the mesh. A managed_settings setting is laid under the mesh's keys, which still win.
This commit is contained in:
@@ -94,6 +94,40 @@ func TestASettingCannotReplaceTheMeshsOwnEntryAndABadNameIsLeftOut(t *testing.T)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTheOperatorsManagedSettingsAreLaidUnderTheMeshsOwnKeys(t *testing.T) {
|
||||
settings := Settings{ManagedSettings: map[string]any{
|
||||
"autoMode": map[string]any{"allow": []any{"merging an approved pull request"}},
|
||||
"permissions": map[string]any{"deny": []any{"Bash(rm -rf /)"}},
|
||||
"attribution": map[string]any{"commit": "made by a machine"},
|
||||
"allowAllClaudeAiMcps": false,
|
||||
"apiKeyHelper": "/somewhere/else",
|
||||
}}
|
||||
read := func(binding *Binding) map[string]any {
|
||||
var m map[string]any
|
||||
out := Render(Facts{Console: "x"}, settings, binding, "/h", nil)
|
||||
if err := json.Unmarshal([]byte(out["managed-settings.json"]), &m); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
m := read(nil)
|
||||
if allow := m["autoMode"].(map[string]any)["allow"].([]any); len(allow) != 1 || allow[0] != "merging an approved pull request" {
|
||||
t.Errorf("the operator's auto mode was not carried: %v", m["autoMode"])
|
||||
}
|
||||
if m["permissions"] == nil {
|
||||
t.Errorf("the operator's permissions were not carried: %v", m)
|
||||
}
|
||||
if !reflect.DeepEqual(m["attribution"], map[string]any{"commit": "", "pr": ""}) || m["allowAllClaudeAiMcps"] != true {
|
||||
t.Errorf("a setting replaced the mesh's own keys: %v", m)
|
||||
}
|
||||
if _, ok := m["apiKeyHelper"]; ok {
|
||||
t.Errorf("a setting named a key-helper the licence did not: %v", m)
|
||||
}
|
||||
if helper := read(&Binding{Licence: "api", Kind: "api-key"})["apiKeyHelper"]; helper != "/h" {
|
||||
t.Errorf("an API-key licence's key-helper was replaced: %v", helper)
|
||||
}
|
||||
}
|
||||
|
||||
// ---- the credentials file -----------------------------------------------------------------------------
|
||||
|
||||
func i64(v int64) *int64 { return &v }
|
||||
|
||||
Reference in New Issue
Block a user