Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TestEmitAuditEventForLargeEvents #48212

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions lib/events/dynamoevents/dynamoevents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,17 +315,30 @@ func TestEmitAuditEventForLargeEvents(t *testing.T) {
assert.Len(t, result, 1)
}, 10*time.Second, 500*time.Millisecond)

appReqEvent := &apievents.AppSessionRequest{
Metadata: apievents.Metadata{
Time: tt.suite.Clock.Now().UTC(),
Type: events.AppSessionRequestEvent,
appReqEvent := &testAuditEvent{
AppSessionRequest: apievents.AppSessionRequest{
Metadata: apievents.Metadata{
Time: tt.suite.Clock.Now().UTC(),
Type: events.AppSessionRequestEvent,
},
Path: strings.Repeat("A", maxItemSize),
},
Path: strings.Repeat("A", maxItemSize),
}
err = tt.suite.Log.EmitAuditEvent(ctx, appReqEvent)
require.ErrorContains(t, err, "ValidationException: Item size has exceeded the maximum allowed size")
}

// testAuditEvent wraps an existing AuditEvent, but overrides
// the TrimToMaxSize to be a noop so that functionality can
// be tested if an event exceeds the size limits.
type testAuditEvent struct {
apievents.AppSessionRequest
}

func (t *testAuditEvent) TrimToMaxSize(maxSizeBytes int) apievents.AuditEvent {
return t
}

func TestConfig_SetFromURL(t *testing.T) {
useFipsCfg := Config{
UseFIPSEndpoint: types.ClusterAuditConfigSpecV2_FIPS_ENABLED,
Expand Down
Loading