Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

test: Add LogAuditEvent tests

rcourtmandaa11a072c88
diff --git a/internal/api/security_test.go b/internal/api/security_test.go
index 376a42729d..e6827f8d7c 100644
--- a/internal/api/security_test.go
+++ b/internal/api/security_test.go
@@ -1036,3 +1036,36 @@ func TestSecurityHeadersWithConfig_NextHandlerCalled(t *testing.T) {
t.Error("next handler was not called")
}
}
+
+func TestLogAuditEvent_Success(t *testing.T) {
+ // Should not panic and should log at Info level
+ LogAuditEvent(
+ "test_event",
+ "testuser",
+ "192.168.1.100",
+ "/api/test",
+ true,
+ "test details",
+ )
+ // If we got here without panic, the test passes
+}
+
+func TestLogAuditEvent_Failure(t *testing.T) {
+ // Should not panic and should log at Warn level
+ LogAuditEvent(
+ "failed_login",
+ "attacker",
+ "203.0.113.42",
+ "/api/login",
+ false,
+ "invalid credentials",
+ )
+ // If we got here without panic, the test passes
+}
+
+func TestLogAuditEvent_EmptyFields(t *testing.T) {
+ // Should handle empty strings gracefully
+ LogAuditEvent("", "", "", "", true, "")
+ LogAuditEvent("", "", "", "", false, "")
+ // If we got here without panic, the test passes
+}