| new file mode 100644 |
| index 000000000..559727532 |
| --- /dev/null |
| +++ b/internal/host/egress_source_test.go |
| @@ -0,0 +1,464 @@ |
| +package host |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "errors" |
| + "io/fs" |
| + "os" |
| + "path/filepath" |
| + "reflect" |
| + "slices" |
| + "strconv" |
| + "strings" |
| + "sync" |
| + "sync/atomic" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/apppolicy" |
| + "github.com/carlosframework/platform/internal/domains" |
| + "github.com/carlosframework/platform/internal/instancectl" |
| + "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/registry" |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// nestedRow and flatRow (systemapply_test.go) are an activator-managed |
| +// instance row at the nested and the flat defaults under a data dir. |
| + |
| +// rootfsRow is a rootfs app's row (rootfs apps #366): an ordinary nested |
| +// instance row that differs only in Route.Runtime "rootfs-v1". This branch |
| +// predates that column, so the field is set by name when the struct has |
| +// it: once the two branches meet, the row carries the rootfs runtime and |
| +// the table still wants it nested (ruling C14: never key on Runtime). |
| +func rootfsRow(dataDir, host string) registry.Route { |
| + rt := nestedRow(dataDir, host) |
| + if f := reflect.ValueOf(&rt).Elem().FieldByName("Runtime"); f.IsValid() && f.Kind() == reflect.String { |
| + f.SetString("rootfs-v1") |
| + } |
| + return rt |
| +} |
| + |
| +func TestBoxWhollyNestedTable(t *testing.T) { |
| + t.Parallel() |
| + dd := t.TempDir() |
| + if err := os.MkdirAll(filepath.Join(dd, "layout"), 0o755); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.WriteFile(provision.LayoutJournalPath(dd, "moving.example.com"), []byte("{}"), 0o644); err != nil { |
| + t.Fatal(err) |
| + } |
| + a, b := nestedRow(dd, "shop-a.example.com"), nestedRow(dd, "shop-b.example.com") |
| + foreign := nestedRow(dd, "odd.example.com") |
| + foreign.DBPath = "/srv/odd.db" |
| + external := registry.Route{Host: "ext.example.com", Kind: "instance", Socket: "/run/ext/app.sock"} |
| + sidecar := registry.Route{Host: "worker.example.com", Kind: "sidecar", App: "shop"} |
| + static := registry.Route{Host: "files.example.com", Kind: "static"} |
| + unit := registry.Route{Host: "unit.example.com", Kind: "instance", Hibernate: true, Addr: "127.0.0.1:8090", Backing: registry.BackingUnit} |
| + tunnel := nestedRow(dd, "tun.example.com") |
| + tunnel.Tunnel = "fleet/pi" |
| + addrExec := registry.Route{Host: "tcp.example.com", Kind: "instance", Hibernate: true, Addr: "127.0.0.1:9000"} |
| + service := registry.Route{Host: "svc.example.com", Kind: "service", Addr: "127.0.0.1:7000"} |
| + unknown := registry.Route{Host: "new.example.com", Kind: "machine"} |
| + |
| + for _, tc := range []struct { |
| + name string |
| + rows []registry.Route |
| + ok bool |
| + reason string // a substring the reason must hold |
| + }{ |
| + {"empty box", nil, true, ""}, |
| + {"all nested", []registry.Route{a, b}, true, ""}, |
| + {"a rootfs row is nested", []registry.Route{a, rootfsRow(dd, "image.example.com")}, true, ""}, |
| + {"an external unflagged socket row does not count", []registry.Route{a, external}, true, ""}, |
| + {"a static row runs nothing", []registry.Route{a, static}, true, ""}, |
| + {"one flat", []registry.Route{a, flatRow(dd, "old.example.com"), b}, false, "old.example.com is flat"}, |
| + {"one fenced by a journal", []registry.Route{a, nestedRow(dd, "moving.example.com")}, false, "moving.example.com is fenced: layout migration in flight"}, |
| + {"one foreign", []registry.Route{a, foreign}, false, "odd.example.com is foreign"}, |
| + {"a sidecar member alone", []registry.Route{sidecar}, false, "worker.example.com is a sidecar member"}, |
| + {"a sidecar member beside nested rows", []registry.Route{a, sidecar, b}, false, "worker.example.com is a sidecar member"}, |
| + {"a unit-backed row", []registry.Route{a, unit}, false, "unit.example.com"}, |
| + {"a tunnel-served row", []registry.Route{a, tunnel}, false, "tun.example.com"}, |
| + {"an addr exec row", []registry.Route{a, addrExec}, false, "tcp.example.com"}, |
| + {"a service row", []registry.Route{a, service}, false, "svc.example.com"}, |
| + {"an unknown kind", []registry.Route{a, unknown}, false, "new.example.com"}, |
| + {"the first failing row is named", []registry.Route{a, flatRow(dd, "first.example.com"), sidecar}, false, "first.example.com is flat"}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + ok, reason := boxWhollyNested(tc.rows, dd) |
| + if ok != tc.ok { |
| + t.Fatalf("boxWhollyNested = %v (%q), want %v", ok, reason, tc.ok) |
| + } |
| + if tc.ok && reason != "" { |
| + t.Fatalf("a wholly nested box has a reason: %q", reason) |
| + } |
| + if !strings.Contains(reason, tc.reason) { |
| + t.Fatalf("reason %q does not hold %q", reason, tc.reason) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// egressRegistry is a temp registry in its own data dir (the package's |
| +// testRegistry: <dataDir>/registry.db) holding rows, with policy columns |
| +// set by SetPolicy, the agent's writer. |
| +func egressRegistry(t *testing.T) (*registry.Registry, string) { |
| + t.Helper() |
| + reg := testRegistry(t) |
| + return reg, filepath.Dir(reg.Path()) |
| +} |
| + |
| +func upsertRows(t *testing.T, reg *registry.Registry, rows ...registry.Route) { |
| + t.Helper() |
| + for _, rt := range rows { |
| + if err := reg.Upsert(rt); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| +} |
| + |
| +func setAllow(t *testing.T, reg *registry.Registry, host, allow string, expires string) { |
| + t.Helper() |
| + if err := reg.SetPolicy(host, allow, "", expires); err != nil { |
| + t.Fatal(err) |
| + } |
| +} |
| + |
| +// testClock is a clock the test moves. |
| +type testClock struct { |
| + mu sync.Mutex |
| + now time.Time |
| +} |
| + |
| +func (c *testClock) Now() time.Time { c.mu.Lock(); defer c.mu.Unlock(); return c.now } |
| +func (c *testClock) Set(t time.Time) { c.mu.Lock(); c.now = t; c.mu.Unlock() } |
| + |
| +func unixText(t time.Time) string { return strconv.FormatInt(t.Unix(), 10) } |
| + |
| +func readPolicy(t *testing.T, src instancectl.EgressSource, host string) instancectl.EgressPolicy { |
| + t.Helper() |
| + p, err := src(context.Background(), host) |
| + if err != nil { |
| + t.Fatalf("source(%s): %v", host, err) |
| + } |
| + return p |
| +} |
| + |
| +func wantPolicy(t *testing.T, got, want instancectl.EgressPolicy) { |
| + t.Helper() |
| + if !reflect.DeepEqual(got, want) { |
| + t.Fatalf("policy = %+v, want %+v", got, want) |
| + } |
| +} |
| + |
| +func TestRegistryEgressSourceReadsTheColumn(t *testing.T) { |
| + t.Parallel() |
| + reg, dd := egressRegistry(t) |
| + clock := &testClock{now: time.Date(2026, 10, 25, 9, 0, 0, 0, time.UTC)} |
| + upsertRows(t, reg, nestedRow(dd, "shop-a.example.com"), nestedRow(dd, "shop-b.example.com")) |
| + setAllow(t, reg, "shop-a.example.com", "10.0.5.20 fd00:5::20", unixText(clock.Now().Add(time.Hour))) |
| + src := registryEgressSource(dd, clock.Now) |
| + |
| + wantPolicy(t, readPolicy(t, src, "shop-a.example.com"), instancectl.EgressPolicy{Allow: []string{"10.0.5.20", "fd00:5::20"}}) |
| + // A row with no policy, and a host with no row: no allow, and nothing to say. |
| + wantPolicy(t, readPolicy(t, src, "shop-b.example.com"), instancectl.EgressPolicy{}) |
| + wantPolicy(t, readPolicy(t, src, "gone.example.com"), instancectl.EgressPolicy{}) |
| +} |
| + |
| +func TestRegistryEgressSourceClosesOnAMixedBox(t *testing.T) { |
| + t.Parallel() |
| + reg, dd := egressRegistry(t) |
| + clock := &testClock{now: time.Date(2026, 10, 25, 9, 0, 0, 0, time.UTC)} |
| + upsertRows(t, reg, nestedRow(dd, "shop-a.example.com")) |
| + setAllow(t, reg, "shop-a.example.com", "10.0.5.20", unixText(clock.Now().Add(time.Hour))) |
| + src := registryEgressSource(dd, clock.Now) |
| + wantPolicy(t, readPolicy(t, src, "shop-a.example.com"), instancectl.EgressPolicy{Allow: []string{"10.0.5.20"}}) |
| + |
| + upsertRows(t, reg, flatRow(dd, "old.example.com")) |
| + got := readPolicy(t, src, "shop-a.example.com") |
| + if got.Closed != instancectl.EgressNotNested || len(got.Allow) != 0 || !strings.Contains(got.Detail, "old.example.com is flat") { |
| + t.Fatalf("a mixed box: %+v, want closed %q naming old.example.com", got, instancectl.EgressNotNested) |
| + } |
| + // A host without a policy on the same box has nothing to close. |
| + wantPolicy(t, readPolicy(t, src, "old.example.com"), instancectl.EgressPolicy{}) |
| + |
| + // A sidecar member makes the box mixed on its own. |
| + if err := reg.Delete("old.example.com"); err != nil { |
| + t.Fatal(err) |
| + } |
| + wantPolicy(t, readPolicy(t, src, "shop-a.example.com"), instancectl.EgressPolicy{Allow: []string{"10.0.5.20"}}) |
| + upsertRows(t, reg, registry.Route{Host: "worker.example.com", Kind: "sidecar", App: "shop"}) |
| + got = readPolicy(t, src, "shop-a.example.com") |
| + if got.Closed != instancectl.EgressNotNested || !strings.Contains(got.Detail, "worker.example.com is a sidecar member") { |
| + t.Fatalf("a box with a sidecar member: %+v, want closed %q naming it", got, instancectl.EgressNotNested) |
| + } |
| +} |
| + |
| +// treeState is every file and directory under root: mode, size, mtime and |
| +// bytes. |
| +func treeState(t *testing.T, root string) map[string]string { |
| + t.Helper() |
| + out := map[string]string{} |
| + err := filepath.WalkDir(root, func(p string, d fs.DirEntry, err error) error { |
| + if err != nil { |
| + return err |
| + } |
| + fi, err := d.Info() |
| + if err != nil { |
| + return err |
| + } |
| + s := fi.Mode().String() + " " + strconv.FormatInt(fi.Size(), 10) + " " + fi.ModTime().Format(time.RFC3339Nano) |
| + if !d.IsDir() { |
| + b, err := os.ReadFile(p) |
| + if err != nil { |
| + return err |
| + } |
| + s += " " + string(b) |
| + } |
| + out[p] = s |
| + return nil |
| + }) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + return out |
| +} |
| + |
| +func TestRegistryEgressSourceWritesNothing(t *testing.T) { |
| + t.Parallel() |
| + reg, dd := egressRegistry(t) |
| + clock := &testClock{now: time.Date(2026, 10, 25, 9, 0, 0, 0, time.UTC)} |
| + if err := os.MkdirAll(filepath.Join(dd, "layout"), 0o755); err != nil { |
| + t.Fatal(err) |
| + } |
| + // A journal for a host that is not on this box, and a temp file. |
| + if err := os.WriteFile(provision.LayoutJournalPath(dd, "elsewhere.example.com"), []byte(`{"host":"elsewhere.example.com"}`), 0o644); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.WriteFile(filepath.Join(dd, "layout", ".tmp-1"), []byte("x"), 0o600); err != nil { |
| + t.Fatal(err) |
| + } |
| + upsertRows(t, reg, nestedRow(dd, "shop-a.example.com")) |
| + setAllow(t, reg, "shop-a.example.com", "10.0.5.20", unixText(clock.Now().Add(time.Hour))) |
| + src := registryEgressSource(dd, clock.Now) |
| + |
| + check := func(phase string, call func()) { |
| + t.Helper() |
| + // Let any earlier write's mtime settle into the past, so a write |
| + // during call shows as a change. |
| + time.Sleep(20 * time.Millisecond) |
| + before := treeState(t, filepath.Join(dd, "layout")) |
| + db := treeState(t, reg.Path()) |
| + call() |
| + if after := treeState(t, filepath.Join(dd, "layout")); !reflect.DeepEqual(before, after) { |
| + t.Fatalf("%s: the layout tree changed:\n before %v\n after %v", phase, before, after) |
| + } |
| + if after := treeState(t, reg.Path()); !reflect.DeepEqual(db, after) { |
| + t.Fatalf("%s: registry.db changed:\n before %v\n after %v", phase, db, after) |
| + } |
| + } |
| + check("an allow", func() { |
| + wantPolicy(t, readPolicy(t, src, "shop-a.example.com"), instancectl.EgressPolicy{Allow: []string{"10.0.5.20"}}) |
| + wantPolicy(t, readPolicy(t, src, "gone.example.com"), instancectl.EgressPolicy{}) |
| + }) |
| + upsertRows(t, reg, flatRow(dd, "old.example.com")) |
| + check("a mixed box", func() { |
| + if got := readPolicy(t, src, "shop-a.example.com"); got.Closed != instancectl.EgressNotNested { |
| + t.Fatalf("a mixed box: %+v", got) |
| + } |
| + }) |
| + clock.Set(clock.Now().Add(2 * time.Hour)) |
| + if err := reg.Delete("old.example.com"); err != nil { |
| + t.Fatal(err) |
| + } |
| + check("an expired allow", func() { |
| + if got := readPolicy(t, src, "shop-a.example.com"); got.Closed != instancectl.EgressExpired { |
| + t.Fatalf("an expired allow: %+v", got) |
| + } |
| + }) |
| +} |
| + |
| +func TestRegistryEgressSourceClosesAtTheRecordedExpiry(t *testing.T) { |
| + t.Parallel() |
| + reg, dd := egressRegistry(t) |
| + t0 := time.Date(2026, 10, 25, 9, 0, 0, 0, time.UTC) |
| + exp := t0.Add(time.Hour) |
| + clock := &testClock{now: t0} |
| + upsertRows(t, reg, nestedRow(dd, "shop-a.example.com")) |
| + setAllow(t, reg, "shop-a.example.com", "10.0.5.20", unixText(exp)) |
| + src := registryEgressSource(dd, clock.Now) |
| + allow := instancectl.EgressPolicy{Allow: []string{"10.0.5.20"}} |
| + expired := instancectl.EgressPolicy{Closed: instancectl.EgressExpired, Detail: "the policy expired at 2026-10-25T10:00:00Z"} |
| + noExpiry := instancectl.EgressPolicy{Closed: instancectl.EgressExpired, Detail: "no expiry recorded"} |
| + |
| + // Ahead: the allow. At the expiry itself and one second past: expired. |
| + wantPolicy(t, readPolicy(t, src, "shop-a.example.com"), allow) |
| + clock.Set(exp.Add(-time.Second)) |
| + wantPolicy(t, readPolicy(t, src, "shop-a.example.com"), allow) |
| + clock.Set(exp) |
| + wantPolicy(t, readPolicy(t, src, "shop-a.example.com"), expired) |
| + clock.Set(exp.Add(time.Second)) |
| + wantPolicy(t, readPolicy(t, src, "shop-a.example.com"), expired) |
| + |
| + // An allow with no usable expiry closes (ruling C1). |
| + clock.Set(t0) |
| + for _, col := range []string{"0", "", "soon", "-5"} { |
| + setAllow(t, reg, "shop-a.example.com", "10.0.5.20", col) |
| + wantPolicy(t, readPolicy(t, src, "shop-a.example.com"), noExpiry) |
| + } |
| + |
| + // A fresh source over the same registry, as after a restart of the |
| + // control service, with the clock past: expired. |
| + setAllow(t, reg, "shop-a.example.com", "10.0.5.20", unixText(exp)) |
| + clock.Set(exp.Add(time.Minute)) |
| + wantPolicy(t, readPolicy(t, registryEgressSource(dd, clock.Now), "shop-a.example.com"), expired) |
| + |
| + // An allowed read, then the registry cannot be read: an error (the |
| + // asserter keeps the last allow) only until the expiry it was read |
| + // under, then expired, never the error. |
| + clock.Set(t0) |
| + src = registryEgressSource(dd, clock.Now) |
| + wantPolicy(t, readPolicy(t, src, "shop-a.example.com"), allow) |
| + if err := os.Rename(reg.Path(), reg.Path()+".away"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := src(context.Background(), "shop-a.example.com"); err == nil { |
| + t.Fatal("an unreadable registry inside the expiry: no error") |
| + } |
| + if _, err := src(context.Background(), "shop-b.example.com"); err == nil { |
| + t.Fatal("an unreadable registry, a host never read: no error") |
| + } |
| + clock.Set(exp.Add(time.Second)) |
| + got, err := src(context.Background(), "shop-a.example.com") |
| + if err != nil { |
| + t.Fatalf("an unreadable registry past the expiry: %v, want %+v", err, expired) |
| + } |
| + wantPolicy(t, got, expired) |
| + if _, err := src(context.Background(), "shop-b.example.com"); err == nil { |
| + t.Fatal("an unreadable registry, a host never read, past the expiry: no error") |
| + } |
| +} |
| + |
| +// failingPolicyStore is a DirStore whose app-policy reads fail with a |
| +// transient error once fail is set: a store outage, as the agent sees it. |
| +type failingPolicyStore struct { |
| + *release.DirStore |
| + fail atomic.Bool |
| +} |
| + |
| +var errStoreOutage = errors.New("connection reset by peer") |
| + |
| +func (s *failingPolicyStore) Get(ctx context.Context, key string) ([]byte, string, error) { |
| + if s.fail.Load() && strings.HasPrefix(key, apppolicy.Prefix) { |
| + return nil, "", errStoreOutage |
| + } |
| + return s.DirStore.Get(ctx, key) |
| +} |
| + |
| +func (s *failingPolicyStore) ListETags(ctx context.Context, prefix string) ([]release.KeyETag, error) { |
| + if s.fail.Load() && strings.HasPrefix(prefix, apppolicy.Prefix) { |
| + return nil, errStoreOutage |
| + } |
| + return s.DirStore.ListETags(ctx, prefix) |
| +} |
| + |
| +// TestPreClaimAllowClosesWhenAStoreOutageOutlastsTheRecord is Astra plan |
| +// R1-3 through the agent's real converge: provision.Reconcile writes the |
| +// row from a policy the release key signed, the store then fails every |
| +// policy read, and once the clock passes SignedAt + apppolicy.Lifetime |
| +// root's source closes the allow from the row alone, whether or not the |
| +// agent ever runs again. |
| +func TestPreClaimAllowClosesWhenAStoreOutageOutlastsTheRecord(t *testing.T) { |
| + t.Parallel() |
| + ctx := context.Background() |
| + reg, dd := egressRegistry(t) |
| + store := &failingPolicyStore{DirStore: release.NewDirStore(t.TempDir())} |
| + clock := &testClock{now: time.Date(2026, 10, 25, 9, 0, 0, 0, time.UTC)} |
| + sqid := domains.Sqid(2) |
| + manifest, err := json.Marshal(map[string]any{"id": 2, "sqid": sqid, "name": "fixture", "created_at": clock.Now()}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := store.Put(ctx, "accounts/"+sqid+"/account.json", manifest, ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := provision.PutManifest(ctx, store, sqid, "shop", provision.Manifest{Schema: 1, App: "shop", Domain: "example.com"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + const host = "shop-a.example.com" |
| + if err := provision.CreateRecord(ctx, store, provision.Record{Schema: 1, Host: host, Slug: "shop-a", App: "shop", Account: sqid, |
| + Region: "ie", Channel: "stable", CreatedAt: clock.Now().Add(-24 * time.Hour)}); err != nil { |
| + t.Fatal(err) |
| + } |
| + seed, pubB64, err := release.GenerateKey() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + priv, err := release.ParseSigningKey(seed, "test") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + pub, err := release.ParsePublicKey(pubB64, "test") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + signedAt := clock.Now() |
| + if err := apppolicy.PutIfMatch(ctx, store, priv, apppolicy.Policy{V: 1, Account: sqid, App: "shop", Revision: 1, |
| + SignedAt: signedAt, EgressAllow: []string{"10.0.5.20"}}, ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + cfg := provision.ReconcileConfig{Region: "ie", DataDir: dd, ReleasePub: pub, Now: clock.Now, |
| + Layout: func(context.Context, release.Store) (string, error) { return release.LayoutModeNested, nil }} |
| + reconcile := func() { |
| + t.Helper() |
| + if err := provision.Reconcile(ctx, store, reg, cfg); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + reconcile() |
| + rt, err := reg.Get(host) |
| + if err != nil || rt == nil { |
| + t.Fatalf("the converge minted no row: %v", err) |
| + } |
| + if want := unixText(signedAt.Add(apppolicy.Lifetime)); rt.EgressAllow != "10.0.5.20" || rt.PolicyExpiresAt != want { |
| + t.Fatalf("converged row: egress %q expires %q, want %q %q", rt.EgressAllow, rt.PolicyExpiresAt, "10.0.5.20", want) |
| + } |
| + src := registryEgressSource(dd, clock.Now) |
| + wantPolicy(t, readPolicy(t, src, host), instancectl.EgressPolicy{Allow: []string{"10.0.5.20"}}) |
| + |
| + // The outage: the agent's passes keep the row while its expiry is ahead. |
| + store.fail.Store(true) |
| + clock.Set(signedAt.Add(apppolicy.Lifetime - time.Hour)) |
| + reconcile() |
| + wantPolicy(t, readPolicy(t, src, host), instancectl.EgressPolicy{Allow: []string{"10.0.5.20"}}) |
| + |
| + // The outage outlasts the record, and the agent has not run since. |
| + clock.Set(signedAt.Add(apppolicy.Lifetime + time.Second)) |
| + wantExpired := instancectl.EgressPolicy{Closed: instancectl.EgressExpired, |
| + Detail: "the policy expired at " + signedAt.Add(apppolicy.Lifetime).UTC().Format(time.RFC3339)} |
| + wantPolicy(t, readPolicy(t, src, host), wantExpired) |
| + wantPolicy(t, readPolicy(t, registryEgressSource(dd, clock.Now), host), wantExpired) |
| + |
| + // When the agent does run, it clears the row: still no allow. |
| + reconcile() |
| + wantPolicy(t, readPolicy(t, src, host), instancectl.EgressPolicy{}) |
| +} |
| + |
| +func TestRegistryEgressHostsListsTheRows(t *testing.T) { |
| + t.Parallel() |
| + reg, dd := egressRegistry(t) |
| + upsertRows(t, reg, nestedRow(dd, "shop-b.example.com"), nestedRow(dd, "shop-a.example.com"), |
| + registry.Route{Host: "worker.example.com", Kind: "sidecar", App: "shop"}) |
| + hosts, err := registryEgressHosts(dd)() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + slices.Sort(hosts) |
| + if want := []string{"shop-a.example.com", "shop-b.example.com", "worker.example.com"}; !slices.Equal(hosts, want) { |
| + t.Fatalf("hosts = %v, want %v", hosts, want) |
| + } |
| + if _, err := registryEgressHosts(filepath.Join(dd, "missing"))(); err == nil { |
| + t.Fatal("no registry: no error") |
| + } |
| +} |