2026-04-10 19:07:15 +05:30
|
|
|
package audit
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
2026-06-24 15:43:20 +05:30
|
|
|
// TestEventTypeOnDiskValues pins the event_type strings written to the on-disk
|
|
|
|
|
// event log. The audit package is the single owner of this vocabulary; the
|
|
|
|
|
// eventlog sink writes string(event.Type) verbatim, so these values are the
|
|
|
|
|
// file-format contract and must not change without a migration.
|
|
|
|
|
func TestEventTypeOnDiskValues(t *testing.T) {
|
2026-04-10 19:07:15 +05:30
|
|
|
tests := []struct {
|
|
|
|
|
input EventType
|
2026-06-24 15:43:20 +05:30
|
|
|
expected string
|
2026-04-10 19:07:15 +05:30
|
|
|
}{
|
2026-06-24 15:43:20 +05:30
|
|
|
{EventTypeMalwareBlocked, "malware_blocked"},
|
|
|
|
|
{EventTypeMalwareConfirmed, "malware_confirmed"},
|
|
|
|
|
{EventTypeInstallAllowed, "install_allowed"},
|
|
|
|
|
{EventTypeInstallTrustedAllowed, "install_trusted_allowed"},
|
|
|
|
|
{EventTypeInstallStarted, "install_started"},
|
|
|
|
|
{EventTypeDependencyResolved, "dependency_resolved"},
|
|
|
|
|
{EventTypeInstallInsecureBypass, "install_insecure_bypass"},
|
|
|
|
|
{EventTypeProxyHostObserved, "proxy_host_observed"},
|
|
|
|
|
{EventTypeDependencyCooldown, "dependency_cooldown"},
|
|
|
|
|
{EventTypeCooldownSkipped, "dependency_cooldown_skipped"},
|
|
|
|
|
{EventTypeSandboxOverride, "sandbox_override"},
|
|
|
|
|
{EventTypeError, "error"},
|
|
|
|
|
{EventTypeSessionComplete, "session_complete"},
|
2026-04-10 19:07:15 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, tt := range tests {
|
2026-06-24 15:43:20 +05:30
|
|
|
t.Run(tt.expected, func(t *testing.T) {
|
|
|
|
|
assert.Equal(t, tt.expected, string(tt.input))
|
2026-04-10 19:07:15 +05:30
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|