cli: house marking asks for its own note; portal step-up redirect pinned (plans 6b tasks 12 and 14 review)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 files changed,
+23
−13
billing_cli.go+1 −1billing_cli_copy.go+10 −9billing_cli_test.go+1 −1internal/console/billingportal_test.go+11 −2
diff --git a/billing_cli.go b/billing_cli.go| index 722c73662..4a9275556 100644 |
| --- a/billing_cli.go |
| +++ b/billing_cli.go |
| @@ -126,7 +126,7 @@ func runBillingWithSession(ctx context.Context, sess *apiSession, args []string, |
| return errors.New(cliBillingCopyHouseAccount) |
| } |
| if strings.TrimSpace(*note) == "" { |
| - return errors.New(cliBillingCopyNoteRequired) |
| + return errors.New(cliBillingCopyHouseNoteRequired) |
| } |
| if sess == nil { |
| sess = requireBillingAPISession(*consoleFlag) |
diff --git a/billing_cli_copy.go b/billing_cli_copy.go| index 2fcbfade2..08a88359b 100644 |
| --- a/billing_cli_copy.go |
| +++ b/billing_cli_copy.go |
| @@ -14,13 +14,14 @@ const ( |
| cliBillingCopyClosed = "problem %d closed" |
| // Plans 6b drafts (Task 14), for carlos billing house; the Luna pass |
| // replaces them. |
| - cliBillingCopyHouseOn = "account %s is now the house: its checkout is free" |
| - cliBillingCopyHouseOff = "account %s pays like everyone else" |
| - cliBillingCopyHouseOnOff = "say -on or -off, one of them" |
| - cliBillingCopyHouseAccount = "say which account with -account" |
| - cliBillingCopyFlagAccount = "account to mark or clear" |
| - cliBillingCopyFlagOn = "make the account a house account" |
| - cliBillingCopyFlagOff = "clear the house mark" |
| - cliBillingCopyFlagHouseNote = "why. this note is kept in the console log" |
| - cliBillingCopyNeedsConsole = "billing works through a console, but this shell is in direct bucket mode\n(CARLOS_DEPLOYMENT_BUCKET/CARLOS_DEPLOYMENT_DIR is set). billing is kept by the console.\nunset the store env and run: carlos auth login --console <url>" |
| + cliBillingCopyHouseOn = "account %s is now the house: its checkout is free" |
| + cliBillingCopyHouseOff = "account %s pays like everyone else" |
| + cliBillingCopyHouseOnOff = "say -on or -off, one of them" |
| + cliBillingCopyHouseAccount = "say which account with -account" |
| + cliBillingCopyHouseNoteRequired = "say why this account is the house with -note" |
| + cliBillingCopyFlagAccount = "account to mark or clear" |
| + cliBillingCopyFlagOn = "make the account a house account" |
| + cliBillingCopyFlagOff = "clear the house mark" |
| + cliBillingCopyFlagHouseNote = "why. this note is kept in the console log" |
| + cliBillingCopyNeedsConsole = "billing works through a console, but this shell is in direct bucket mode\n(CARLOS_DEPLOYMENT_BUCKET/CARLOS_DEPLOYMENT_DIR is set). billing is kept by the console.\nunset the store env and run: carlos auth login --console <url>" |
| ) |
diff --git a/billing_cli_test.go b/billing_cli_test.go| index e2a9df8b7..af37b6be0 100644 |
| --- a/billing_cli_test.go |
| +++ b/billing_cli_test.go |
| @@ -120,7 +120,7 @@ func TestBillingCLIHouse(t *testing.T) { |
| {[]string{"house", "-account", "bab", "-note", "x"}, cliBillingCopyHouseOnOff}, |
| {[]string{"house", "-account", "bab", "-on", "-off", "-note", "x"}, cliBillingCopyHouseOnOff}, |
| {[]string{"house", "-on", "-note", "x"}, cliBillingCopyHouseAccount}, |
| - {[]string{"house", "-account", "bab", "-on"}, cliBillingCopyNoteRequired}, |
| + {[]string{"house", "-account", "bab", "-on"}, cliBillingCopyHouseNoteRequired}, |
| } { |
| err := runBillingWithSession(context.Background(), s, c.args, io.Discard) |
| if err == nil || err.Error() != c.want { |
diff --git a/internal/console/billingportal_test.go b/internal/console/billingportal_test.go| index e92103d48..4f7348cd1 100644 |
| --- a/internal/console/billingportal_test.go |
| +++ b/internal/console/billingportal_test.go |
| @@ -99,8 +99,17 @@ func TestPortalGates(t *testing.T) { |
| } |
| // Stale sign-in proof: the step-up gate, no provider call. |
| r := o.portal(t) |
| - if r.Status != http.StatusSeeOther || strings.HasPrefix(r.Loc, o.billingBase()) || strings.HasPrefix(r.Loc, "https://") { |
| - t.Fatalf("stale auth = %d %q, want the step-up redirect", r.Status, r.Loc) |
| + if r.Status != http.StatusSeeOther { |
| + t.Fatalf("stale auth = %d %q, want a 303 to the step-up", r.Status, r.Loc) |
| + } |
| + loc, err := url.Parse(r.Loc) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + q := loc.Query() |
| + if loc.Path != "/oauth/authorize" || q.Get("prompt") != "login" || q.Get("max_age") != "300" || |
| + q.Get("redirect_uri") != o.srv.cfg.Origin+"/auth/stepup/callback" || q.Get("client_id") != o.srv.cfg.Origin { |
| + t.Fatalf("stale auth redirect = %q, want the identity provider's step-up authorize URL returning to /auth/stepup/callback", r.Loc) |
| } |
| // Not ready: portal.failed, no call. |
| o.stepUp(t) |