console: invite delivery residuals (doc comment, pow-slot test cleanup, neutral test addresses)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 files changed,
+27
−18
cmd/console/mailbackends_test.go+1 −1internal/console/consolemail_test.go+2 −2internal/console/keymailfed_test.go+9 −1internal/console/server.go+15 −14
diff --git a/cmd/console/mailbackends_test.go b/cmd/console/mailbackends_test.go| index 7835f6b4b..37cff9efe 100644 |
| --- a/cmd/console/mailbackends_test.go |
| +++ b/cmd/console/mailbackends_test.go |
| @@ -150,7 +150,7 @@ func TestConsoleMailerWiring(t *testing.T) { |
| if m, _ := consoleMailer(dep, store, nil, nil, sesOK); m != nil { |
| t.Error("no provisioner: want no mailer") |
| } |
| - t.Setenv("CARLOS_CONSOLE_MAIL_FROM", "invites@tito.io") |
| + t.Setenv("CARLOS_CONSOLE_MAIL_FROM", "invites@shop.example") |
| if m, _ := consoleMailer(mail.Deployment{Region: "eu-west-1"}, store, prov, nil, sesOK); m == nil { |
| t.Error("explicit From, no suffix: want a mailer") |
| } |
diff --git a/internal/console/consolemail_test.go b/internal/console/consolemail_test.go| index 86058e64b..3130f63bb 100644 |
| --- a/internal/console/consolemail_test.go |
| +++ b/internal/console/consolemail_test.go |
| @@ -38,10 +38,10 @@ func testMailDeployment() mail.Deployment { |
| func TestConsoleMailFrom(t *testing.T) { |
| cases := []struct{ explicit, suffix, want string }{ |
| - {"invites@tito.io", "oncarlos.test", "invites@tito.io"}, |
| + {"invites@shop.example", "oncarlos.test", "invites@shop.example"}, |
| {"", "oncarlos.test", "noreply@console-mail.bab.oncarlos.test"}, |
| {"", "", ""}, |
| - {" Invites@Tito.io ", "", "invites@tito.io"}, |
| + {" Invites@Shop.example ", "", "invites@shop.example"}, |
| } |
| for _, c := range cases { |
| if got := ConsoleMailFrom(c.explicit, c.suffix); got != c.want { |
diff --git a/internal/console/keymailfed_test.go b/internal/console/keymailfed_test.go| index 5e653904f..78b6400a1 100644 |
| --- a/internal/console/keymailfed_test.go |
| +++ b/internal/console/keymailfed_test.go |
| @@ -145,6 +145,14 @@ func TestPowSlotIsOneAtATimeAndHonoursTheDeadline(t *testing.T) { |
| if err != nil { |
| t.Fatalf("first acquire: %v", err) |
| } |
| + released := false |
| + releaseOnce := func() { |
| + if !released { |
| + release() |
| + released = true |
| + } |
| + } |
| + defer releaseOnce() |
| ctx, cancel := context.WithTimeout(context.Background(), 50*time.Millisecond) |
| defer cancel() |
| start := time.Now() |
| @@ -154,7 +162,7 @@ func TestPowSlotIsOneAtATimeAndHonoursTheDeadline(t *testing.T) { |
| if d := time.Since(start); d > time.Second { |
| t.Fatalf("waiting acquire took %v", d) |
| } |
| - release() |
| + releaseOnce() |
| again, err := acquirePowSlot(context.Background()) |
| if err != nil { |
| t.Fatalf("acquire after release: %v", err) |
diff --git a/internal/console/server.go b/internal/console/server.go| index 6c4c2bae3..9006bf62c 100644 |
| --- a/internal/console/server.go |
| +++ b/internal/console/server.go |
| @@ -3735,6 +3735,21 @@ func validBuildProbe(p string) bool { |
| // it here. See the call site for why that default matters. |
| func ownerExempt(prefix, ownPrefix string) bool { return prefix == ownPrefix } |
| +// reservedAppName reports whether no app in acct may take name, by create or |
| +// by rename. |
| +// |
| +// "new" is the literal path segment GET /a/{sqid}/apps/new resolves to — |
| +// Go 1.22's mux prefers it over apps/{app}, so an app named "new" could |
| +// never be viewed. |
| +// |
| +// The console's own mail identity hangs off consoleMailApp in the ops |
| +// account (consolemail.go). The mail layer refuses to tear that domain down |
| +// whatever app holds the name, but an app wearing it would still read as |
| +// the domain's owner everywhere else. |
| +func reservedAppName(acct *Account, name string) bool { |
| + return name == "new" || (acct.Sqid == release.OpsAccount && name == consoleMailApp) |
| +} |
| + |
| // claimApp claims an app name for acct — once, ever. A name is refused when |
| // the apps table has it, when ANY owner exists for it (CLI-granted apps stay |
| // claim-proof), or when the release store already holds anything under |
| @@ -3782,20 +3797,6 @@ func ownerExempt(prefix, ownPrefix string) bool { return prefix == ownPrefix } |
| // |
| // held is set only with claimApexHeld: who holds the name's platform apex, so |
| // a door can say so without asking again. |
| -// reservedAppName reports whether no app in acct may take name, by create or |
| -// by rename. |
| -// |
| -// "new" is the literal path segment GET /a/{sqid}/apps/new resolves to — |
| -// Go 1.22's mux prefers it over apps/{app}, so an app named "new" could |
| -// never be viewed. |
| -// |
| -// The console's own mail identity hangs off consoleMailApp in the ops |
| -// account (consolemail.go). The mail layer refuses to tear that domain down |
| -// whatever app holds the name, but an app wearing it would still read as |
| -// the domain's owner everywhere else. |
| -func reservedAppName(acct *Account, name string) bool { |
| - return name == "new" || (acct.Sqid == release.OpsAccount && name == consoleMailApp) |
| -} |
| func (s *Server) claimApp(ctx context.Context, acct *Account, name, addr, placement string, ownerClaim bool, rq regionReq) (outcome claimOutcome, placed string, held *apexHold) { |
| if !release.ValidApp(name) { |