mirror of
https://github.com/Dvorinka/Containr.git
synced 2026-10-28 07:41:27 +00:00
feat: outbound webhooks — signed event delivery + delivery log
Every audited action now emits a "resource.action" event (bare actions get resource-qualified; already-qualified actions like service.clone pass through). Webhooks subscribe per-user with exact names, resource.* wildcards, or *. - schema: outbound_webhooks + webhook_deliveries (sqlc + goose) - dispatcher: 4 workers, 512-queue, 3 attempts with backoff, 10s timeout; deliveries record status/http-code/body(4KiB)/duration - signing: X-Containr-Signature sha256=<hmac> over raw body; X-Containr-Event + X-Containr-Delivery headers; custom headers per hook - api: CRUD + /deliveries + /test (ping) under authed group - fix: SetAuditDB never called — LogAudit was a silent no-op at every call site; now wired at boot - coverage: service create/delete audited (previously uninstrumented) - cli: containr webhooks list|create|update|delete|deliveries|test - mcp: 6 tools, delete requires confirm - frontend: /settings/webhooks page — list/create/expand-deliveries/ test/disable/delete, secret-shown-once banner; nav + account menu - openapi + regenerated types; CLI.md + docs snapshot; roadmap ticks
This commit is contained in:
1 parent
5c2f2861bd
commit
f499678964
23 files changed
+2278
-7
No files matched your search
@@ -0,0 +1,33 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestWebhookEventMatches(t *testing.T) {
|
||||
subs := func(list ...string) json.RawMessage {
|
||||
raw, _ := json.Marshal(list)
|
||||
return raw
|
||||
}
|
||||
cases := []struct {
|
||||
events json.RawMessage
|
||||
event string
|
||||
want bool
|
||||
}{
|
||||
{subs("service.*"), "service.deploy", true},
|
||||
{subs("service.*"), "database.create", false},
|
||||
{subs("*"), "service.deploy", true},
|
||||
{subs("deployment.fail", "service.*"), "deployment.fail", true},
|
||||
{subs("deployment.fail"), "deployment.success", false},
|
||||
{subs(" ping "), "ping", true},
|
||||
{subs(), "service.deploy", false},
|
||||
{json.RawMessage(`"not-a-list"`), "service.deploy", false},
|
||||
{json.RawMessage(`invalid`), "service.deploy", false},
|
||||
}
|
||||
for i, tc := range cases {
|
||||
if got := webhookEventMatches(tc.events, tc.event); got != tc.want {
|
||||
t.Errorf("case %d: matches(%s, %q) = %v, want %v", i, tc.events, tc.event, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user