mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-14 03:52:26 +08:00
- Add prompt_audit_events.full_prompt (migration 182) so admins can review the exact unredacted prompt that triggered a finding; blocking mode writes it from the snapshot, async mode reconstructs it from the Redis scan payload so jobs rows stay redaction-only - Event detail API returns full_prompt (list endpoint stays lean); text is NUL-stripped and capped at 65536 runes - Detail dialog shows the full prompt in a scrollable pane with fallback to the legacy redacted preview; page copy updated to match the new behavior - Rework filter deletion into a dedicated dialog with time-range presets and criteria-change preview invalidation; localize decision/risk/category labels across the events workspace - Fix pre-existing i18n message-compile spec by declaring the @intlify/message-compiler dev dependency
26 lines
855 B
Go
26 lines
855 B
Go
package securityaudit
|
|
|
|
import "testing"
|
|
|
|
func TestShouldStorePromptAuditEvent(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
storePassEvents bool
|
|
decision EventDecision
|
|
want bool
|
|
}{
|
|
{name: "pass disabled", storePassEvents: false, decision: EventPass, want: false},
|
|
{name: "flag disabled", storePassEvents: false, decision: EventFlag, want: true},
|
|
{name: "critical disabled", storePassEvents: false, decision: EventCritical, want: true},
|
|
{name: "pass enabled", storePassEvents: true, decision: EventPass, want: true},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := shouldStorePromptAuditEvent(tt.decision, tt.storePassEvents); got != tt.want {
|
|
t.Fatalf("shouldStorePromptAuditEvent(%q, %t) = %t, want %t", tt.decision, tt.storePassEvents, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|