The /admin/guard page, a Guardrails link, and the policies in force on the profile page
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
7e18b8ab53
commit
02aac84ca5
11 files changed
+305
-3
No files matched your search
@@ -0,0 +1,27 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTheGuardrailsPageShowsNamesAndCounts(t *testing.T) {
|
||||
rec := httptest.NewRecorder()
|
||||
render(rec, "admin_guard", guardPageData{
|
||||
Nav: Nav{Admin: true, Guard: true, Current: "guard"}, Window: "7d", Windows: []string{"24h", "7d"},
|
||||
Policies: []string{"base", "finance"}, Default: []string{"base"},
|
||||
Attachments: []guardAttachmentRow{{Scope: "project", Who: "Acme/fin/payroll", Policy: "finance"}},
|
||||
Counts: []guardCountRow{{Where: "Acme/fin/payroll", Action: "blocked", Policy: "base,finance", Category: "iban", Count: 3}},
|
||||
Events: []guardEventRow{{At: "2026-10-04 10:00:00", RequestID: "req_1", Action: "blocked", Category: "iban", Status: 400}},
|
||||
})
|
||||
body := rec.Body.String()
|
||||
for _, want := range []string{"Acme/fin/payroll", "base,finance", "req_1", `href="/admin/guard" aria-current="page"`, `href="?window=24h"`} {
|
||||
if !strings.Contains(body, want) {
|
||||
t.Errorf("no %q", want)
|
||||
}
|
||||
}
|
||||
if rec.Code != 200 {
|
||||
t.Errorf("status %d: %s", rec.Code, body)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user