fix(registry): dev never falls back to the public registry

BaseURL() in dev mode used to silently fall back to https://git.dcntrlized.org
when DCNTRLIZED_GITEA_URL was unset — a dev Maestro could resolve installs and
infra from the wrong (and cred-less) registry. Dev now uses the debug registry
exclusively; an unset URL returns '' so registry ops fail loudly. Locked with
a BaseURL seam test.
This commit is contained in:
2026-08-16 17:18:16 +01:00
parent e66cf54d5b
commit becf3043e3
2 changed files with 27 additions and 2 deletions
+21
View File
@@ -50,3 +50,24 @@ func TestItemByNameLive(t *testing.T) {
t.Logf("resolved %s -> image=%s url=%s version=%s", name, item.Image, item.URL, item.Version)
}
}
// TestBaseURLNeverFallsBackToPublicInDev locks the dev registry seam: with
// DCNTRLIZED_DEV=true Maestro must talk to the debug registry
// (DCNTRLIZED_GITEA_URL) only — an unset dev URL yields "" (loud failure),
// never the public git.dcntrlized.org.
func TestBaseURLNeverFallsBackToPublicInDev(t *testing.T) {
t.Setenv("DCNTRLIZED_DEV", "true")
t.Setenv("DCNTRLIZED_GITEA_URL", "http://192.168.122.183:3000")
if got := BaseURL(); got != "http://192.168.122.183:3000" {
t.Fatalf("dev with DCNTRLIZED_GITEA_URL: got %q", got)
}
t.Setenv("DCNTRLIZED_GITEA_URL", "")
if got := BaseURL(); got != "" {
t.Fatalf("dev without DCNTRLIZED_GITEA_URL must not fall back to public, got %q", got)
}
t.Setenv("DCNTRLIZED_DEV", "")
t.Setenv("DCNTRLIZED_GITEA_URL", "http://192.168.122.183:3000")
if got := BaseURL(); got != "https://git.dcntrlized.org" {
t.Fatalf("production must use the public registry, got %q", got)
}
}