mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-01-05 13:07:14 +00:00
Add audit event tests for callback_handler
This commit is contained in:
@@ -27,13 +27,13 @@ type WantedAuditLog struct {
|
||||
Params map[string]any
|
||||
}
|
||||
|
||||
func WantAuditLog(message string, params map[string]any, auditID string) WantedAuditLog {
|
||||
func WantAuditLog(message string, params map[string]any, auditID ...string) WantedAuditLog {
|
||||
result := WantedAuditLog{
|
||||
Message: message,
|
||||
Params: params,
|
||||
}
|
||||
if auditID != "" {
|
||||
result.Params["auditID"] = auditID
|
||||
if len(auditID) > 0 {
|
||||
result.Params["auditID"] = auditID[0]
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -41,6 +41,12 @@ func WantAuditLog(message string, params map[string]any, auditID string) WantedA
|
||||
func CompareAuditLogs(t *testing.T, wantAuditLogs []WantedAuditLog, actualAuditLogsOneLiner string) {
|
||||
t.Helper()
|
||||
|
||||
// There are tests that verify that no audit events were emitted
|
||||
if len(wantAuditLogs) == 0 {
|
||||
require.Empty(t, actualAuditLogsOneLiner, "no audit events were expected, but some were found")
|
||||
return
|
||||
}
|
||||
|
||||
wantJsonAuditLogs := make([]map[string]any, 0)
|
||||
wantMessages := make([]string, 0)
|
||||
for _, wantAuditLog := range wantAuditLogs {
|
||||
|
||||
Reference in New Issue
Block a user