carlos / platform Public

Fleet public routes Task 6 fix round 1: no certificate entry for a refused claim, and aliases resolve as the edge resolves them

P1: a wildcard parent whose claim's primary is refused (named by its
catch-all alias, its plain alias or its own row) publishes neither half,
including through a platform alias dropped with a refused source, so no
separate issuer's WildcardParents or delegated set holds it. Parents no
refused claim derives (certificate-only, regional) are unchanged.

P2: the alias loop replays Reload's alias fold (served rows, then every
alias by name through the growing map, an alias of a fleet-refused row not
folded), so a served chained alias is published with its root primary's
owner and target, with no nil owner.

The served-vs-written cross-check now covers catch-all keys and chained
aliases; the separate-issuer test asserts the wildcard parents. Spec §4.4
and §7 reconciled with the census card.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev adf3df876383676d6d5449bc49fcc184162e166f parent 9c0f4d3
5 files changed, +219 −42
  • docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md +21 −2
  • internal/edge/issuer_forward_test.go +32 −1
  • internal/edge/testdata/edges-forward-hub.json +1 −1
  • internal/host/edgesfile.go +58 −20
  • internal/host/edgesfile_forward_test.go +107 −18
diff --git a/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md b/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md
index 88f5744f4..eb853d8e7 100644
--- a/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md
+++ b/docs/superpowers/specs/2026-10-29-fleet-public-routes-design.md
@@ -465,7 +465,12 @@ Callers:
name is also taken out where another row's alias carries it, a platform
alias whose source is withheld goes with it, a forward host's path rows
do not count toward its published owner, and a wildcard entry (both
- halves) whose catch-all primary is withheld is left out. The one thing
+ halves) whose claim's primary is refused (named by its catch-all
+ alias, its plain alias or its own row, including a platform alias
+ dropped with a refused source) is left out, so it is in no issuer's
+ delegated set; a parent no refused claim derives (certificate-only,
+ regional) is unchanged. Aliases resolve as `Reload`'s alias fold does,
+ through earlier aliases in name order. The one thing
the file cannot say is `refusedUnder`: a refused name under another
row's served `*.<parent>` is not in the file (`KnownHost` is exact), and
a far edge that dials it through that catch-all reaches the hub, which
@@ -992,7 +997,21 @@ Units, by file (N = new, R = removed, otherwise a changed body or sites):
`forwards` marks, the platform-alias source check, the path rows of a
forward host left out of its owner, the catch-all whose primary was
withheld, and the alias loop now taking its primary from the served
- rows (`owners`) rather than from the growing map. `Edge.Reload` moves
+ rows (`owners`) rather than from the growing map. Fix round 1 (Astra
+ P1, P2) changes the card to `+registry:Account`, `+registry:Alias` x5,
+ `+registry:Host` x5, `+registry:Name`, `+whole:Fleet` x2,
+ `+whole:Route`, `+whole:RouteAlias` x2, `+whole:RoutePath` x7,
+ `+whole:WildcardDomain` (same class, keeps authority, task F,J1): the
+ alias loop replays Reload's alias fold (`resolve`, the served rows then
+ every alias by name, each through the map as it grows, an alias of a
+ fleet-refused row not folded), so a served chained alias is published
+ with its root primary's owner and target; and `certRefused` (the
+ withheld rows and every platform alias dropped with its withheld
+ source) with `parentRefused` (a wildcard parent whose claim's primary,
+ named by its `*.<parent>` alias, its plain alias or its own row, is
+ certificate-refused) leaves out both halves of that parent's entry, so
+ no separate issuer's `WildcardParents` or delegated set holds it. Rows
+ read, all already read in the pass. `Edge.Reload` moves
from `+registry:Host` x9 to x10: the alias fold skips an alias whose
primary is a refused row (`fleetRefused[a.Host]`), so a refused row's
attached names are not served through an alias that carries the
diff --git a/internal/edge/issuer_forward_test.go b/internal/edge/issuer_forward_test.go
index c80ee7eff..f729cefb5 100644
--- a/internal/edge/issuer_forward_test.go
+++ b/internal/edge/issuer_forward_test.go
@@ -4,6 +4,7 @@ import (
"context"
"os"
"path/filepath"
+ "slices"
"testing"
"github.com/carlosframework/platform/internal/release"
@@ -41,9 +42,39 @@ func TestSeparateIssuerAdmitsOnlyPublishedForwardNames(t *testing.T) {
t.Errorf("%s: the issuer refuses a name the hub publishes", h)
}
}
- for _, h := range []string{"shop.baj.example.com", "store.example.com", "shop.baj-custom.example.com"} {
+ for _, h := range []string{"shop.baj.example.com", "store.example.com", "shop.baj-custom.example.com",
+ "baj-certonly.example.com", "hand.baj.example.com", "apex.baj.example.com"} {
if issuer.deploymentHost(h) {
t.Errorf("%s: the issuer admits a refused forward row's name", h)
}
}
+
+ // Wildcard certificates go by another door: the home map's
+ // WildcardParents, unioned into the issuer's delegated set (wildcard.go,
+ // the delegated source), from which the wildcard manager orders by
+ // DNS-01. A parent derived from a refused claim, directly (the catch-all
+ // and the certificate-only claim of the refused forward row) or through
+ // the platform alias of a refused row, is in neither; the eligible row's
+ // parents and the parents no refused claim derives are.
+ local, err := issuer.reg.ListWildcardDomains()
+ if err != nil || len(local) != 0 {
+ t.Fatalf("the issuer's own wildcard rows = %v, %v; want none", local, err)
+ }
+ parents := m.WildcardParents()
+ delegated := unionDelegated(nil, parents, "acme-delegation.example.com")
+ for _, set := range []struct {
+ name string
+ got []string
+ }{{"WildcardParents", parents}, {"delegated", delegated}} {
+ for _, p := range []string{"bah-wild.example.com", "bah-certonly.example.com", "bah-certs.example.com", "bah-regional.example.com"} {
+ if !slices.Contains(set.got, p) {
+ t.Errorf("%s %v lacks %s", set.name, set.got, p)
+ }
+ }
+ for _, p := range []string{"baj-wild.example.com", "baj-certonly.example.com", "baj-apex.example.com"} {
+ if slices.Contains(set.got, p) {
+ t.Errorf("%s %v holds %s, a refused claim's parent", set.name, set.got, p)
+ }
+ }
+ }
}
diff --git a/internal/edge/testdata/edges-forward-hub.json b/internal/edge/testdata/edges-forward-hub.json
index 00967b69c..f3102adcc 100644
--- a/internal/edge/testdata/edges-forward-hub.json
+++ b/internal/edge/testdata/edges-forward-hub.json
@@ -1 +1 @@
-{"v":1,"box":"hub","eip":"198.51.100.7","hibernation_configured":false,"serves_shared_pool":false,"accepts_inbound":false,"moves_protocol":0,"seeds_protocol":0,"addrs":null,"generation":"2026-10-30T00:00:00Z","hosts":{"*.bah-wild.example.com":{"role":"home","platform":false,"alias":true,"wildcard":true,"account":"bah","app":"shop","target_host":"shop.bah.example.com"},"shop.bah-custom.example.com":{"role":"home","platform":false,"alias":true,"account":"bah","app":"shop","target_host":"shop.bah.example.com"},"shop.bah.example.com":{"role":"home","platform":true,"account":"bah","app":"shop"},"tickets.example.com":{"role":"home","platform":false,"alias":true,"account":"bah","app":"shop","target_host":"shop.bah.example.com"}}}
+{"v":1,"box":"hub","eip":"198.51.100.7","hibernation_configured":false,"serves_shared_pool":false,"accepts_inbound":false,"moves_protocol":0,"seeds_protocol":0,"addrs":null,"generation":"2026-10-30T00:00:00Z","hosts":{"*.bah-certonly.example.com":{"role":"wildcard","platform":false,"wildcard":true},"*.bah-certs.example.com":{"role":"wildcard","platform":false,"wildcard":true},"*.bah-regional.example.com":{"role":"wildcard","platform":false,"wildcard":true},"*.bah-wild.example.com":{"role":"home","platform":false,"alias":true,"wildcard":true,"account":"bah","app":"shop","target_host":"shop.bah.example.com"},"bah-certonly.example.com":{"role":"home","platform":false,"alias":true,"account":"bah","app":"shop","target_host":"shop.bah.example.com"},"shop.bah-custom.example.com":{"role":"home","platform":false,"alias":true,"account":"bah","app":"shop","target_host":"shop.bah.example.com"},"shop.bah.example.com":{"role":"home","platform":true,"account":"bah","app":"shop"},"tickets.example.com":{"role":"home","platform":false,"alias":true,"account":"bah","app":"shop","target_host":"shop.bah.example.com"}}}
diff --git a/internal/host/edgesfile.go b/internal/host/edgesfile.go
index 80a104cc0..2722c3187 100644
--- a/internal/host/edgesfile.go
+++ b/internal/host/edgesfile.go
@@ -522,8 +522,10 @@ var errBoxAddressesUnknown = errors.New("edges file: the box's addresses could n
// instancectl.LocalAddresses, and tests their own.
//
// Fleet public routes (spec §4.4): a row edge.FleetServeEligible refuses, as
-// Reload asks it, is not published, nor is any alias, instance catch-all or
-// wildcard entry served with it, nor its name under another row's alias. The
+// Reload asks it, is not published, nor is any alias or instance catch-all
+// served with it, nor its name under another row's alias, nor either half of
+// a wildcard entry its claims derive (directly or through a platform alias
+// dropped with it). Aliases resolve as Reload's alias fold does. The
// hub test and the tunnels switch are read from the environment inside each
// write (edge.HubArmed, edge.TunnelsArmed), and the fleet owners from this
// box's fleets table. A forward row and every name served with it publish no
@@ -651,10 +653,18 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re
}
// A platform alias is served with its source's own entry, so one whose
// source was withheld above is not served either (Reload drops it when
- // the source has no entry).
+ // the source has no entry). It is not a refused name (Reload does not
+ // hold it through the later folds), but whatever a claim derives from it
+ // is refused with it: certRefused is every primary whose claims publish
+ // no certificate entry, the withheld rows and these aliases.
+ certRefused := make(map[string]bool, len(withheld))
+ for host := range withheld {
+ certRefused[host] = true
+ }
for host, src := range platformSources {
if _, served := hosts[src]; !served {
delete(hosts, host)
+ certRefused[host] = true
}
}
// Owners (#175 P7): computed over the served rows alone, before any alias
@@ -709,15 +719,33 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re
if err != nil {
return fmt.Errorf("edges: list aliases: %w", err)
}
+ // resolve is Reload's alias fold, replayed: each name maps to the served
+ // row the edge serves it with. Seeded with the served rows, then every
+ // alias in the same order Reload reads them (by name), each resolving
+ // through the map as it grows, so an alias of an alias the edge serves
+ // is resolved as the edge resolves it. As in Reload, a name already
+ // held is not replaced, and an alias of a refused row is not folded
+ // (it would serve the refused row's attached names through an alias
+ // carrying the refused name). Every value is a served row, so owners
+ // holds it.
+ resolve := make(map[string]string, len(hosts)+len(aliases))
+ for host := range hosts {
+ resolve[host] = host
+ }
+ for _, a := range aliases {
+ if _, taken := resolve[a.Alias]; taken || a.Alias == "" || withheld[a.Host] {
+ continue
+ }
+ if p, ok := resolve[a.Host]; ok {
+ resolve[a.Alias] = p
+ }
+ }
for _, a := range aliases {
if a.Alias == "" || strings.HasPrefix(a.Alias, "*.") {
continue
}
- // The primary must be a served row (owners holds exactly those), not
- // an alias this loop added: a name that is attached here while its
- // own row is withheld or not ready lends nothing to the aliases of
- // that row.
- if _, served := owners[a.Host]; !served {
+ primary, served := resolve[a.Alias]
+ if !served {
continue
}
if a.DNSStatus != "pointing" {
@@ -737,7 +765,7 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re
// The edge serves an alias with its primary's own entry, prefix map
// included, so the alias's owner is the primary's, never the alias
// row's own columns.
- acct, app := owners[a.Host].owner()
+ acct, app := owners[primary].owner()
// The alias is served by its primary's installation, so it carries
// the primary's stamp (region HA HA4): an unstamped alias would tie
// with a dead predecessor's and the edge would keep the first box
@@ -745,9 +773,9 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re
// So it carries the primary's lifetime pair too (none with lifetimes
// off), and names the primary as its target: the edge compares two
// aliases' pairs only for one target.
- p := hosts[a.Host]
+ p := hosts[primary]
hosts[a.Alias] = edgeHost{Role: "home", Alias: true, Account: acct, App: app, Stamp: p.Stamp,
- Incarnation: p.Incarnation, ServingSeq: p.ServingSeq, TargetHost: a.Host}
+ Incarnation: p.Incarnation, ServingSeq: p.ServingSeq, TargetHost: primary}
}
// Replica placements (#162): a row minted from a role=replica record —
@@ -784,17 +812,27 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re
// catchallServed maps each served parent to the primary its "*.<parent>"
// alias row points at, the route the edge serves the catch-all with.
catchallServed := map[string]string{}
- // catchallWithheld names each parent whose catch-all is served by a row
- // the fleet rule withheld: its wildcard entry goes with its primary.
- catchallWithheld := map[string]bool{}
+ // parentRefused names each parent whose claim's primary is refused
+ // (certRefused): the primary its "*.<parent>" catch-all alias names, the
+ // one its plain alias (the parent itself, for a claim with a Route)
+ // names, or the parent's own row (a claim that is its own primary).
+ // Neither half of its wildcard entry is published, so no reader loads or
+ // orders a certificate for a claim the edge refuses; a parent with none
+ // of these refused (a certificate-only or regional parent) is unchanged.
+ parentRefused := map[string]bool{}
+ for _, wd := range wds {
+ parentRefused[wd.Host] = certRefused[wd.Host]
+ }
for _, a := range aliases {
- if parent, ok := strings.CutPrefix(a.Alias, "*."); ok {
- if _, served := owners[a.Host]; served {
- catchallServed[parent] = a.Host
- } else if withheld[a.Host] {
- catchallWithheld[parent] = true
+ parent, star := strings.CutPrefix(a.Alias, "*.")
+ if star {
+ if p, ok := resolve[a.Alias]; ok && !strings.HasPrefix(p, "*.") {
+ catchallServed[parent] = p
}
}
+ if _, ok := parentRefused[parent]; ok && certRefused[a.Host] {
+ parentRefused[parent] = true
+ }
}
for _, wd := range wds {
if wd.Host == "" || strings.HasPrefix(wd.Host, "*.") {
@@ -811,7 +849,7 @@ func edgesFileWriteClaims(ctx context.Context, s release.Store, reg *registry.Re
hosts[key] = prev
continue
}
- if _, served := catchallServed[wd.Host]; !served && catchallWithheld[wd.Host] {
+ if _, served := catchallServed[wd.Host]; !served && parentRefused[wd.Host] {
continue
}
// Marked alias whenever the DIAL half is on, and the mark is
diff --git a/internal/host/edgesfile_forward_test.go b/internal/host/edgesfile_forward_test.go
index 7d00267d3..4f3e052ba 100644
--- a/internal/host/edgesfile_forward_test.go
+++ b/internal/host/edgesfile_forward_test.go
@@ -16,6 +16,8 @@ import (
"context"
"database/sql"
"encoding/json"
+ "net/http"
+ "net/http/httptest"
"os"
"path/filepath"
"reflect"
@@ -95,10 +97,27 @@ func fpWildcard(t *testing.T, reg *registry.Registry, parent, primary, account s
}
}
+// fpCertOnly attaches a Wildcard claim without Catchall on primary, as the
+// domains pass derives it: the plain alias naming the parent itself, and the
+// parent's wildcard_domains row (the certificate half only).
+func fpCertOnly(t *testing.T, reg *registry.Registry, parent, primary, account string) {
+ t.Helper()
+ fpAlias(t, reg, parent, primary, account)
+ if err := reg.UpsertWildcardDomain(registry.WildcardDomain{Host: parent, Account: account, App: "shop"}); err != nil {
+ t.Fatal(err)
+ }
+}
+
// fpWorld is the first test's world: two forward rows on fleet home, one of
// the owner's (eligible) and one of the second account's (refused), each with
// an attached custom domain, an instance catch-all name (<slug>.<parent>,
-// what deriveInstanceAliases writes) and a served wildcard catch-all.
+// what deriveInstanceAliases writes), a served wildcard catch-all and a
+// certificate-only wildcard claim. Beside them: a hand row of the second
+// account on the owner's fleet (refused on the hub) with a platform alias
+// sharing its socket and a catch-all claim on that alias, and two parents
+// that derive from no refused claim, a certificate-only parent with no local
+// primary and a regional parent (regional rows never target a fleet row,
+// release.RegionalTarget).
func fpWorld(t *testing.T) *registry.Registry {
t.Helper()
reg := fpRegistry(t)
@@ -107,14 +126,47 @@ func fpWorld(t *testing.T) *registry.Registry {
fpAlias(t, reg, "tickets.example.com", fpEligible, fpOwner)
fpAlias(t, reg, "shop.bah-custom.example.com", fpEligible, fpOwner)
fpWildcard(t, reg, "bah-wild.example.com", fpEligible, fpOwner)
+ fpCertOnly(t, reg, "bah-certonly.example.com", fpEligible, fpOwner)
fpAlias(t, reg, "store.example.com", fpRefused, fpOther)
fpAlias(t, reg, "shop.baj-custom.example.com", fpRefused, fpOther)
fpWildcard(t, reg, "baj-wild.example.com", fpRefused, fpOther)
+ fpCertOnly(t, reg, "baj-certonly.example.com", fpRefused, fpOther)
+ for _, rt := range []registry.Route{
+ {Host: "hand.baj.example.com", Kind: "instance", Socket: "/run/carlos/hand.sock", Status: "ready",
+ Region: registry.PlacementTarget("home"), Account: fpOther, App: "shop"},
+ {Host: "apex.baj.example.com", Kind: "instance", Socket: "/run/carlos/hand.sock", Status: "ready",
+ Platform: true, Account: fpOther, App: "shop"},
+ } {
+ if err := reg.Upsert(rt); err != nil {
+ t.Fatal(err)
+ }
+ }
+ fpWildcard(t, reg, "baj-apex.example.com", "apex.baj.example.com", fpOther)
+ for _, parent := range []string{"bah-certs.example.com", "bah-regional.example.com"} {
+ if err := reg.UpsertWildcardDomain(registry.WildcardDomain{Host: parent, Account: fpOwner, App: "shop"}); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if err := reg.ReplaceRegionalSet("bah-regional.example.com", []registry.RegionalDomain{
+ {Host: "bah-regional.example.com", Account: fpOwner, App: "shop", Region: "uk"},
+ }); err != nil {
+ t.Fatal(err)
+ }
return reg
}
-var fpEligibleNames = []string{fpEligible, "tickets.example.com", "shop.bah-custom.example.com", "*.bah-wild.example.com"}
-var fpRefusedNames = []string{fpRefused, "store.example.com", "shop.baj-custom.example.com", "*.baj-wild.example.com"}
+var fpEligibleNames = []string{fpEligible, "tickets.example.com", "shop.bah-custom.example.com", "*.bah-wild.example.com", "bah-certonly.example.com"}
+var fpRefusedNames = []string{fpRefused, "store.example.com", "shop.baj-custom.example.com", "*.baj-wild.example.com",
+ "baj-certonly.example.com", "*.baj-certonly.example.com"}
+
+// fpCertOnlyKeys are the certificate-only entries (role "wildcard"): the
+// eligible row's claim, published with its primary, and the two unrelated
+// parents, published everywhere.
+var fpCertOnlyKeys = []string{"*.bah-certonly.example.com", "*.bah-certs.example.com", "*.bah-regional.example.com"}
+
+// fpRefusedOnTheHub is what the refused claims derive through the platform
+// alias of the refused hand row: nothing of it is published on the hub.
+var fpRefusedOnTheHub = []string{"hand.baj.example.com", "apex.baj.example.com", "*.baj-apex.example.com"}
// fpWrite runs one writer pass on box "hub" into a fresh store and returns the
// written body.
@@ -168,12 +220,17 @@ func TestEdgesFilePublishesOnlyEligibleForwardRows(t *testing.T) {
if h := hosts[fpEligible]; !h.Platform || h.Alias {
t.Errorf("the forward row's own entry = %+v, want platform, not alias", h)
}
- for _, n := range []string{"tickets.example.com", "shop.bah-custom.example.com", "*.bah-wild.example.com"} {
+ for _, n := range []string{"tickets.example.com", "shop.bah-custom.example.com", "*.bah-wild.example.com", "bah-certonly.example.com"} {
if h := hosts[n]; !h.Alias || h.TargetHost != fpEligible {
t.Errorf("%s = %+v, want an alias served by %s", n, h, fpEligible)
}
}
- for _, n := range fpRefusedNames {
+ for _, n := range fpCertOnlyKeys {
+ if h, ok := hosts[n]; !ok || h.Role != "wildcard" || !h.Wildcard {
+ t.Errorf("%s = %+v, %v; want the certificate half (role wildcard)", n, h, ok)
+ }
+ }
+ for _, n := range append(append([]string{}, fpRefusedNames...), fpRefusedOnTheHub...) {
if _, ok := hosts[n]; ok {
t.Errorf("refused name %s published:\n%s", n, body)
}
@@ -199,11 +256,17 @@ func TestEdgesFileOmitsForwardRowsOffTheHub(t *testing.T) {
if _, ok := hosts["plain.example.com"]; !ok {
t.Fatalf("the positive control is not published: %+v", hosts)
}
- for _, n := range append(append([]string{}, fpEligibleNames...), fpRefusedNames...) {
+ for _, n := range append(append([]string{"*.bah-certonly.example.com"}, fpEligibleNames...), fpRefusedNames...) {
if _, ok := hosts[n]; ok {
t.Errorf("%s published off the hub", n)
}
}
+ // The parents no refused claim derives stay, on every box.
+ for _, n := range []string{"*.bah-certs.example.com", "*.bah-regional.example.com"} {
+ if _, ok := hosts[n]; !ok {
+ t.Errorf("%s (no refused claim) not published", n)
+ }
+ }
})
}
}
@@ -362,6 +425,18 @@ func fpServedBy(t *testing.T, reg *registry.Registry) *edge.Edge {
return e
}
+// fpAnswers reports whether e serves host at all: anything but its
+// unknown-host answer (a dead upstream still counts as served).
+func fpAnswers(e *edge.Edge, host string) bool {
+ // A cancelled request: a served name fails at once at its upstream
+ // rather than dialing it; the unknown-host answer does not depend on it.
+ ctx, cancel := context.WithCancel(context.Background())
+ cancel()
+ rec := httptest.NewRecorder()
+ e.ServeHTTP(rec, httptest.NewRequest("GET", "http://"+host+"/", nil).WithContext(ctx))
+ return !(rec.Code == http.StatusNotFound && rec.Body.String() == "unknown host\n")
+}
+
// The edge and the file agree, name by name: every exact name the file
// publishes as served is Allowed by the hub's edge and every name it leaves
// out is not, including a refused host under another row's alias, a platform
@@ -372,16 +447,12 @@ func TestEdgesFilePublishesWhatTheHubServes(t *testing.T) {
// The refused host's own name attached to the eligible row: the edge's
// alias fold would serve it, and refusedHosts takes it out again.
fpAlias(t, reg, fpRefused, fpEligible, fpOwner)
- // A hand row of the second account on the owner's fleet, and a
- // platform alias sharing its socket (PlatformAliasFold's source).
for _, rt := range []registry.Route{
- {Host: "hand.baj.example.com", Kind: "instance", Socket: "/run/carlos/hand.sock", Status: "ready",
- Region: registry.PlacementTarget("home"), Account: fpOther, App: "shop"},
- {Host: "apex.baj.example.com", Kind: "instance", Socket: "/run/carlos/hand.sock", Status: "ready",
- Platform: true, Account: fpOther, App: "shop"},
// A served catch-all row over the refused host's parent.
{Host: "*.example.com", Kind: "service", Addr: "10.0.0.1:3000", Status: "ready"},
{Host: "plain.example.com", Kind: "service", Addr: "10.0.0.1:3001", Status: "ready"},
+ // A row that is not ready, of no fleet, its name attached below.
+ {Host: "a.example.com", Kind: "service", Addr: "10.0.0.1:3002", Status: "creating"},
} {
if err := reg.Upsert(rt); err != nil {
t.Fatal(err)
@@ -400,10 +471,19 @@ func TestEdgesFilePublishesWhatTheHubServes(t *testing.T) {
t.Fatal(err)
}
fpAlias(t, reg, "idle.bah.example.com", "plain.example.com", "")
+ // Aliases of aliases, resolved as Reload's fold resolves them, in
+ // name order through the map as it grows: z resolves through a (a
+ // sorts first), b does not resolve through y (y sorts after it).
+ fpAlias(t, reg, "a.example.com", "plain.example.com", "")
+ fpAlias(t, reg, "z.example.com", "a.example.com", "")
+ fpAlias(t, reg, "b.example.com", "y.example.com", "")
+ fpAlias(t, reg, "y.example.com", "plain.example.com", "")
return reg
}
- names := append(append([]string{"hand.baj.example.com", "apex.baj.example.com", "plain.example.com", "idle.bah.example.com"},
- fpEligibleNames...), fpRefusedNames...)
+ names := []string{"plain.example.com", "idle.bah.example.com", "a.example.com", "z.example.com", "b.example.com", "y.example.com"}
+ for _, l := range [][]string{fpEligibleNames, fpRefusedNames, fpCertOnlyKeys, fpRefusedOnTheHub} {
+ names = append(names, l...)
+ }
for _, c := range []struct{ name, tunnel, fleet string }{
{"hub", fpTunnel, ""},
{"tunnels on, not the hub", fpTunnel, "home"},
@@ -415,15 +495,24 @@ func TestEdgesFilePublishesWhatTheHubServes(t *testing.T) {
hosts, _ := fpHosts(t, fpWrite(t, reg))
e := fpServedBy(t, reg)
for _, n := range names {
- if strings.HasPrefix(n, "*.") {
- continue // never Allowed; the catch-all keys are checked by name in the tests above
- }
h, published := hosts[n]
published = published && h.Role == "home"
- if served := e.Allowed(n); served != published {
+ // An exact name: the edge's own admission (Allowed). A
+ // catch-all key: whether the edge answers a one-label name
+ // under it (Allowed never admits "*.").
+ served := e.Allowed(n)
+ if parent, ok := strings.CutPrefix(n, "*."); ok {
+ served = fpAnswers(e, "probe."+parent)
+ }
+ if served != published {
t.Errorf("%s: edge serves %v, file publishes %v (%+v)", n, served, published, h)
}
}
+ for _, n := range []string{"a.example.com", "z.example.com"} {
+ if h := hosts[n]; h.TargetHost != "plain.example.com" {
+ t.Errorf("%s = %+v, want an alias served by plain.example.com", n, h)
+ }
+ }
if c.name == "hub" {
if _, ok := hosts[fpEligible]; !ok {
t.Fatalf("positive control: %s not published on the hub", fpEligible)