| index f9e4241de..99996d4a5 100644 |
| --- a/internal/host/edgesfile_import_test.go |
| +++ b/internal/host/edgesfile_import_test.go |
| @@ -22,9 +22,9 @@ import ( |
| |
| // writeImportEntry writes an imported-certificate entry (#1429) for host into |
| // acmeDir, as the edge's mirror copies it from control/certs/<host>+import: |
| -// the binding (bound to account), the PKCS#8 key, then the leaf, valid until |
| -// notAfter. |
| -func writeImportEntry(t *testing.T, acmeDir, host, account string, notAfter time.Time) { |
| +// the binding (bound to account and app), the PKCS#8 key, then the leaf, |
| +// valid until notAfter. |
| +func writeImportEntry(t *testing.T, acmeDir, host, account, app string, notAfter time.Time) { |
| t.Helper() |
| key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) |
| if err != nil { |
| @@ -40,7 +40,7 @@ func writeImportEntry(t *testing.T, acmeDir, host, account string, notAfter time |
| if err != nil { |
| t.Fatal(err) |
| } |
| - body := domains.EncodeImport(domains.ImportBinding{Host: host, Account: account, App: "app", ClaimCreated: "2026-11-25T09:00:00Z"}, pkcs8, [][]byte{der}) |
| + body := domains.EncodeImport(domains.ImportBinding{Host: host, Account: account, App: app, ClaimCreated: "2026-11-25T09:00:00Z"}, pkcs8, [][]byte{der}) |
| if err := os.MkdirAll(acmeDir, 0o700); err != nil { |
| t.Fatal(err) |
| } |
| @@ -89,18 +89,24 @@ func TestEdgesFilePublishesImportedAliasesBeforeDNS(t *testing.T) { |
| for _, a := range []struct { |
| alias, aliasAccount, importAccount string |
| notAfter time.Time |
| + importApp string |
| }{ |
| - {"billing.customer.example", "acct", "acct", future}, // the case |
| - {"otheracct.customer.example", "acct", "zzz", future}, // bound to another account |
| - {"noimport.customer.example", "acct", "", future}, // no import |
| - {"expired.customer.example", "acct", "acct", past}, // expired |
| - {"wrongrow.customer.example", "zzz", "acct", future}, // the alias row is another account's |
| + {"billing.customer.example", "acct", "acct", future, ""}, // the case |
| + {"otheracct.customer.example", "acct", "zzz", future, ""}, // bound to another account |
| + {"noimport.customer.example", "acct", "", future, ""}, // no import |
| + {"expired.customer.example", "acct", "acct", past, ""}, // expired |
| + {"wrongrow.customer.example", "zzz", "acct", future, ""}, // the alias row is another account's |
| + {"otherapp.customer.example", "acct", "acct", future, "other"}, // bound to another app |
| } { |
| if err := reg.UpsertAlias(registry.RouteAlias{Alias: a.alias, Host: "app.acct.apps.test", Account: a.aliasAccount, App: "app", DNSStatus: "elsewhere"}); err != nil { |
| t.Fatal(err) |
| } |
| if a.importAccount != "" { |
| - writeImportEntry(t, acme, a.alias, a.importAccount, a.notAfter) |
| + app := a.importApp |
| + if app == "" { |
| + app = "app" |
| + } |
| + writeImportEntry(t, acme, a.alias, a.importAccount, app, a.notAfter) |
| } |
| } |
| publish := func() map[string]importHostView { |
| @@ -115,7 +121,7 @@ func TestEdgesFilePublishesImportedAliasesBeforeDNS(t *testing.T) { |
| if h, ok := hosts["billing.customer.example"]; !ok || h.Role != "home" || !h.Alias || h.TargetHost != "app.acct.apps.test" || h.DNSPointing == nil || *h.DNSPointing { |
| t.Errorf("billing.customer.example = %+v (published %v); want home, alias, dns_pointing false", h, ok) |
| } |
| - for _, absent := range []string{"otheracct.customer.example", "noimport.customer.example", "expired.customer.example", "wrongrow.customer.example"} { |
| + for _, absent := range []string{"otheracct.customer.example", "noimport.customer.example", "expired.customer.example", "wrongrow.customer.example", "otherapp.customer.example"} { |
| if _, ok := hosts[absent]; ok { |
| t.Errorf("%s must not be published before it points here", absent) |
| } |
| @@ -159,7 +165,7 @@ func TestEdgesFileHubPublishesAFleetAliasWithAnImportBeforeDNS(t *testing.T) { |
| if _, ok := write()[alias]; ok { |
| t.Fatal("without an import the fleet alias must wait for the pointing stamp") |
| } |
| - writeImportEntry(t, acme, alias, fpOwner, time.Now().Add(60*24*time.Hour)) |
| + writeImportEntry(t, acme, alias, fpOwner, "shop", time.Now().Add(60*24*time.Hour)) |
| hosts := write() |
| if _, ok := hosts[fpEligible]; !ok { |
| t.Fatal("test bug: the hub must publish the eligible forward row") |
| @@ -169,9 +175,14 @@ func TestEdgesFileHubPublishesAFleetAliasWithAnImportBeforeDNS(t *testing.T) { |
| t.Fatalf("%s = %+v (published %v); want home, alias of %s, dns_pointing false", alias, h, ok, fpEligible) |
| } |
| |
| - // An import bound to another account publishes nothing early. |
| - writeImportEntry(t, acme, alias, fpOther, time.Now().Add(60*24*time.Hour)) |
| + // An import bound to another account, or to another app of the same |
| + // account, publishes nothing early. |
| + writeImportEntry(t, acme, alias, fpOther, "shop", time.Now().Add(60*24*time.Hour)) |
| if _, ok := write()[alias]; ok { |
| t.Fatal("an import bound to another account published the fleet alias") |
| } |
| + writeImportEntry(t, acme, alias, fpOwner, "other", time.Now().Add(60*24*time.Hour)) |
| + if _, ok := write()[alias]; ok { |
| + t.Fatal("an import bound to another app published the fleet alias") |
| + } |
| } |