test: tests para privileged ACL y isSpecialConfig

- TestResolveACL_PrivilegedVsGeneral: verifica que father-bot solo
  es accesible por admins y que agentes generales son accesibles
  por todos. Reproduce la config real de produccion.
- TestIsSpecialConfig_*: 3 tests para la funcion que detecta
  configs de SpecialConfig ya cargados (orchestrator) y los salta
  en el loop de discovery normal del launcher.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-09 22:05:41 +00:00
parent db1a93c3fe
commit a6100b5154
2 changed files with 111 additions and 1 deletions
+56
View File
@@ -56,3 +56,59 @@ func TestReadReloadTarget_whitespace(t *testing.T) {
t.Fatalf("expected 'asistente-2', got %q", got)
}
}
// ── isSpecialConfig tests ─────────────────────────────────────────────────
func TestIsSpecialConfig_matchesLoadedSpecial(t *testing.T) {
dir := t.TempDir()
cfg := filepath.Join(dir, "config.yaml")
if err := os.WriteFile(cfg, []byte(`
special:
id: orchestrator
type: orchestrator
enabled: true
llm:
primary:
provider: openai
`), 0o644); err != nil {
t.Fatal(err)
}
loaded := map[string]bool{"orchestrator": true}
if !isSpecialConfig(cfg, loaded) {
t.Fatal("expected isSpecialConfig to return true for loaded orchestrator")
}
}
func TestIsSpecialConfig_agentConfigNotSpecial(t *testing.T) {
dir := t.TempDir()
cfg := filepath.Join(dir, "config.yaml")
// An AgentConfig doesn't have special.id, so LoadSpecial will fail validation.
if err := os.WriteFile(cfg, []byte(`
agent:
id: father-bot
enabled: true
matrix:
homeserver: "https://example.com"
user_id: "@father:example.com"
llm:
primary:
provider: claude-code
`), 0o644); err != nil {
t.Fatal(err)
}
loaded := map[string]bool{"orchestrator": true}
if isSpecialConfig(cfg, loaded) {
t.Fatal("expected isSpecialConfig to return false for agent config")
}
}
func TestIsSpecialConfig_emptyLoadedMap(t *testing.T) {
if isSpecialConfig("any-path", nil) {
t.Fatal("expected false when no specials loaded")
}
if isSpecialConfig("any-path", map[string]bool{}) {
t.Fatal("expected false when empty specials map")
}
}