| index da9d24e70..e9c1bf81d 100644 |
| --- a/internal/console/billingretire_test.go |
| +++ b/internal/console/billingretire_test.go |
| @@ -6,6 +6,7 @@ import ( |
| "fmt" |
| "html" |
| "net/http" |
| + "net/http/httptest" |
| "net/url" |
| "strings" |
| "testing" |
| @@ -551,3 +552,36 @@ func TestReplayNeedsRetirementToHold(t *testing.T) { |
| wantCounts(t, o.counts(), map[string]int{}) |
| o.wantKept(t) |
| } |
| + |
| +// A replay whose proof expired between the callback and the dispatch, with |
| +// its retirement mark gone, is still a replay: refused before the gate, no |
| +// new mark and no new step-up, nothing deleted. |
| +func TestReplayWithExpiredProofNeedsRetirement(t *testing.T) { |
| + o := newDeleteFixture(t, nil, false) |
| + form := url.Values{"csrf": {o.csrf}, "confirm": {o.acct.Name}} |
| + req := httptest.NewRequest(http.MethodPost, o.ts.URL+"/a/"+o.acct.Sqid+"/delete", strings.NewReader(form.Encode())) |
| + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") |
| + u, _ := url.Parse(o.ts.URL) |
| + for _, ck := range o.owner.Jar.Cookies(u) { |
| + req.AddCookie(ck) |
| + } |
| + req = req.WithContext(context.WithValue(req.Context(), stepUpReplayKey{}, true)) |
| + rr := httptest.NewRecorder() |
| + o.srv.ServeHTTP(rr, req) |
| + var flash string |
| + for _, ck := range rr.Result().Cookies() { |
| + if ck.Name == flashCookie { |
| + flash, _ = url.QueryUnescape(ck.Value) |
| + } |
| + } |
| + if rr.Code != http.StatusSeeOther || rr.Header().Get("Location") != o.settingsPath() || flash != "err|"+billingCopy["delete.retry"] { |
| + t.Fatalf("replay = %d %q flash %q, want delete.retry", rr.Code, rr.Header().Get("Location"), flash) |
| + } |
| + wantCounts(t, o.counts(), map[string]int{}) |
| + o.wantKept(t) |
| + var stashed int |
| + o.st.db.QueryRow(`SELECT COUNT(*) FROM pending_actions`).Scan(&stashed) |
| + if stashed != 0 { |
| + t.Fatalf("%d pending actions parked by a refused replay", stashed) |
| + } |
| +} |