carlos / platform Public

test: cover the account-mismatch half of the alias ownership gate (#151)

TestReconcileAliasesOwnershipGate only exercised the App-mismatch side of
aliases.go's OR condition (rt.App != c.App || release.RouteAccount(rt) !=
c.Account). Add TestReconcileAliasesOwnershipGateAccountMismatch, seeding
the route with a valid but differing account sqid so the comparison is
isolated from RouteAccount's OpsAccount fallback for invalid values —
this line is the authoritative tenancy gate for the whole feature.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Paul Campbell e2539b77610b21a51b88e625652627bf0d7b64d3 parent 35548ca
1 file changed, +26 −0
  • internal/domains/aliases_test.go +26 −0
diff --git a/internal/domains/aliases_test.go b/internal/domains/aliases_test.go
index c07a79467..3e202c599 100644
--- a/internal/domains/aliases_test.go
+++ b/internal/domains/aliases_test.go
@@ -93,6 +93,32 @@ func TestReconcileAliasesOwnershipGate(t *testing.T) {
}
}
+func TestReconcileAliasesOwnershipGateAccountMismatch(t *testing.T) {
+ s := release.NewDirStore(t.TempDir())
+ // Route's account is a VALID sqid ("bad") so release.RouteAccount
+ // returns it verbatim rather than falling back to OpsAccount — the
+ // mismatch must come from the comparison itself, not an invalid-account
+ // fallback masking it.
+ reg := aliasRegWith(t, registry.Route{
+ Host: "canary/live", App: "kass", Account: "bad", Kind: "instance", Status: "ready",
+ })
+ // Claim names the right route and the right app, but a different
+ // (also valid) account.
+ putClaim(t, s, Claim{
+ Host: "tickets.example.com", Account: "bab", App: "kass", Route: "canary/live",
+ })
+ if err := ReconcileAliases(context.Background(), s, reg, aliasNow()); err != nil {
+ t.Fatal(err)
+ }
+ aliases, err := reg.ListAliases()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(aliases) != 0 {
+ t.Fatalf("got %d aliases, want 0 (account mismatch must refuse): %+v", len(aliases), aliases)
+ }
+}
+
func TestReconcileAliasesRoutesWin(t *testing.T) {
s := release.NewDirStore(t.TempDir())
reg := aliasRegWith(t,