Implement phase 1 foundations
build-image / docker (push) Successful in 53s

This commit is contained in:
2026-07-03 20:14:06 -08:00
commit 6f7549d439
39 changed files with 2221 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
package alerts
import (
"net/http"
"net/http/httptest"
"testing"
"gitea.wayfinderak.com/wayfinderak/log-guardian/internal/analysis"
"gitea.wayfinderak.com/wayfinderak/log-guardian/internal/store"
)
func TestNtfyDelivery(t *testing.T) {
var gotAuth string
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/alerts" {
t.Fatalf("unexpected path %s", r.URL.Path)
}
gotAuth = r.Header.Get("Authorization")
w.WriteHeader(http.StatusNoContent)
}))
defer ts.Close()
d := NewDispatcher()
_, err := d.Send(t.Context(), store.Rule{Name: "API", Severity: "warning"}, analysis.Finding{Summary: "failed"}, []store.AlertChannel{{ID: "c1", Name: "ntfy", Type: "ntfy", Enabled: true, Params: map[string]string{"server_url": ts.URL, "topic": "alerts", "token": "secret"}}})
if err != nil {
t.Fatal(err)
}
if gotAuth != "Bearer secret" {
t.Fatalf("missing auth header: %q", gotAuth)
}
}