(t *testing.T, rotations *int)
| 58 | } |
| 59 | |
| 60 | func rotateTestServer(t *testing.T, rotations *int) *httptest.Server { |
| 61 | t.Helper() |
| 62 | srv := httptest.NewServer(New(Deps{ |
| 63 | Authenticator: func(r *http.Request) (*identity.User, error) { |
| 64 | if r.Header.Get("Authorization") == "Bearer good" { |
| 65 | return &identity.User{ID: "u_1", Email: "owner@acme.com"}, nil |
| 66 | } |
| 67 | return nil, errors.New("unauthorized") |
| 68 | }, |
| 69 | Idempotency: newStatefulIdem(), |
| 70 | RotateSecret: func(_ context.Context, _, _ string) (string, time.Time, error) { |
| 71 | *rotations++ |
| 72 | return fmt.Sprintf("whsec_rot_%d", *rotations), time.Unix(1700086400, 0).UTC(), nil |
| 73 | }, |
| 74 | })) |
| 75 | t.Cleanup(srv.Close) |
| 76 | return srv |
| 77 | } |
| 78 | |
| 79 | func rotateCall(t *testing.T, url, key string) (int, map[string]any) { |
| 80 | t.Helper() |
no test coverage detected