diff --git a/internal/api/security_test.go b/internal/api/security_test.go index 376a427..e6827f8 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 +}