MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / rotateTestServer

Function rotateTestServer

internal/httpapi/webhooks_rotate_idem_test.go:60–77  ·  view source on GitHub ↗
(t *testing.T, rotations *int)

Source from the content-addressed store, hash-verified

58}
59
60func 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
79func rotateCall(t *testing.T, url, key string) (int, map[string]any) {
80 t.Helper()

Calls 4

newStatefulIdemFunction · 0.85
CleanupMethod · 0.80
NewFunction · 0.70
GetMethod · 0.65

Tested by

no test coverage detected