| index 31c61feec..f107b5772 100644 |
| --- a/internal/host/edgesfile_test.go |
| +++ b/internal/host/edgesfile_test.go |
| @@ -744,6 +744,88 @@ func TestEdgesFilePublishesPointingAliasesOfServedPrimaries(t *testing.T) { |
| } |
| } |
| |
| +// #162: a replica alias — the account's own public host, derived by |
| +// domains.ReconcileAliases from a route's ReplicaOf — is a platform row, not |
| +// a tenant-chosen name, so it publishes regardless of dns_status. It is |
| +// marked role "replica" (never "home": foldHomes must drop it fleet-wide so |
| +// the account host stays single-valued), while the replica's own route |
| +// keeps role "home" so ordinary backhaul can still reach it. |
| +func TestEdgesFilePublishesReplicaAliasWithoutADNSStamp(t *testing.T) { |
| + s, reg := release.NewDirStore(t.TempDir()), edgesTestRegistry(t) |
| + if err := reg.Upsert(registry.Route{ |
| + Host: "r7x2k9m4qa.go.tito.io", Kind: "instance", Status: "ready", |
| + Socket: "/run/carlos/r7x2k9m4qa.go.tito.io.sock", Provisioned: true, |
| + Account: "bab", App: "tito", ReplicaOf: "acme.go.tito.io", |
| + }); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := reg.UpsertAlias(registry.RouteAlias{ |
| + Alias: "acme.go.tito.io", Host: "r7x2k9m4qa.go.tito.io", |
| + Account: "bab", App: "tito", // deliberately unstamped |
| + }); err != nil { |
| + t.Fatal(err) |
| + } |
| + var lastBody []byte |
| + if err := edgesFilePass(context.Background(), s, reg, |
| + edgesFile{Box: "uk-1", Placement: "uk"}, "203.0.113.9", &lastBody); err != nil { |
| + t.Fatal(err) |
| + } |
| + got, _, err := s.Get(context.Background(), "control/edges/uk-1.json") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var f edgesFile |
| + if err := json.Unmarshal(got, &f); err != nil { |
| + t.Fatal(err) |
| + } |
| + if h, ok := f.Hosts["acme.go.tito.io"]; !ok || h.Role != "replica" || !h.Alias { |
| + t.Fatalf("public host entry = %+v, want role replica alias true: %+v", h, f.Hosts) |
| + } |
| + if h, ok := f.Hosts["r7x2k9m4qa.go.tito.io"]; !ok || h.Role != "home" { |
| + t.Fatalf("the replica's own host must stay role home: %+v", f.Hosts) |
| + } |
| +} |
| + |
| +// #162 revision 2: with custom domains in scope, a replica alias's NAME can |
| +// be a custom domain rather than the account host — the alias row is |
| +// `claim.Host -> replica.Host`, and `ReplicaOf` names the account host, not |
| +// the alias. The replica test must therefore key off the PRIMARY route's |
| +// ReplicaOf (byHost[a.Host].ReplicaOf != ""), never off a.Alias equality, |
| +// or every custom-domain replica alias is silently withheld exactly like an |
| +// unstamped tenant name. |
| +func TestEdgesFilePublishesReplicaCustomDomainAliasWithoutADNSStamp(t *testing.T) { |
| + s, reg := release.NewDirStore(t.TempDir()), edgesTestRegistry(t) |
| + if err := reg.Upsert(registry.Route{ |
| + Host: "r7x2k9m4qa.go.tito.io", Kind: "instance", Status: "ready", |
| + Socket: "/run/carlos/r7x2k9m4qa.go.tito.io.sock", Provisioned: true, |
| + Account: "bab", App: "tito", ReplicaOf: "acme.go.tito.io", |
| + }); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := reg.UpsertAlias(registry.RouteAlias{ |
| + Alias: "tickets.example.com", Host: "r7x2k9m4qa.go.tito.io", |
| + Account: "bab", App: "tito", // deliberately unstamped |
| + }); err != nil { |
| + t.Fatal(err) |
| + } |
| + var lastBody []byte |
| + if err := edgesFilePass(context.Background(), s, reg, |
| + edgesFile{Box: "uk-1", Placement: "uk"}, "203.0.113.9", &lastBody); err != nil { |
| + t.Fatal(err) |
| + } |
| + got, _, err := s.Get(context.Background(), "control/edges/uk-1.json") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var f edgesFile |
| + if err := json.Unmarshal(got, &f); err != nil { |
| + t.Fatal(err) |
| + } |
| + if h, ok := f.Hosts["tickets.example.com"]; !ok || h.Role != "replica" || !h.Alias { |
| + t.Fatalf("custom-domain replica alias = %+v, want role replica alias true: %+v", h, f.Hosts) |
| + } |
| +} |
| + |
| // #305: delegated customer wildcard parents publish as "*.<parent>" in their |
| // own class — never platform, never over an existing key. |
| func TestEdgesFilePublishesDelegatedWildcardParents(t *testing.T) { |