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

Function TestUpdateWebhook_ReEnableCooldown

internal/identity/webhooks_test.go:239–267  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

237}
238
239func TestUpdateWebhook_ReEnableCooldown(t *testing.T) {
240 pool := testutil.TestDB(t)
241 store := identity.NewStore(pool)
242 ctx := context.Background()
243 userID := webhookTestUser(t, store, "wh-cooldown")
244 w, _ := store.CreateWebhook(ctx, userID, "https://a.example.com", "", []string{"email.received"}, identity.WebhookFilters{})
245
246 // Simulate auto-disable that just happened.
247 _, _ = pool.Exec(ctx, `UPDATE webhooks SET enabled = false, auto_disabled_at = now() WHERE id = $1`, w.ID)
248
249 tval := true
250 _, err := store.UpdateWebhook(ctx, w.ID, userID, identity.WebhookUpdate{Enabled: &tval})
251 if !errors.Is(err, identity.ErrWebhookCooldown) {
252 t.Errorf("expected ErrWebhookCooldown, got %v", err)
253 }
254
255 // Simulate an auto_disabled_at older than 5 min — re-enable should succeed.
256 _, _ = pool.Exec(ctx, `UPDATE webhooks SET auto_disabled_at = now() - interval '10 minutes' WHERE id = $1`, w.ID)
257 got, err := store.UpdateWebhook(ctx, w.ID, userID, identity.WebhookUpdate{Enabled: &tval})
258 if err != nil {
259 t.Fatalf("re-enable after cooldown: %v", err)
260 }
261 if !got.Enabled {
262 t.Error("Enabled = false after successful re-enable")
263 }
264 if got.AutoDisabledAt != nil {
265 t.Error("auto_disabled_at not cleared after re-enable")
266 }
267}
268
269func TestRotateSecret_ReturnsNewPlaintext(t *testing.T) {
270 pool := testutil.TestDB(t)

Callers

nothing calls this directly

Calls 7

CreateWebhookMethod · 0.95
UpdateWebhookMethod · 0.95
TestDBFunction · 0.92
NewStoreFunction · 0.92
webhookTestUserFunction · 0.85
ExecMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected