* feat (events): Add new options needed for AuditConfig WithAuditWrapper and WithFilterOperations all for optional paramters when creating AuditConfig types. * refactor (event): Change EventerConfig.Sinks to a ptr We need to modify the SinkConfig.AuditConfig during the NewEventer factory, so we have to use a ptr not a ref. * feat (events): Add audit configuration types * feat (events): add audit config to sink configuration. * feat (events): add redact/encrypt node for audit events to Eventer Integrate the encrypt.Filter node from the eventlogger into the event.Eventer, so audit events can be redacted/encrypted based on data classifications. * test (events) Add test protobufs for events Add test protobufs along with a test service for testing the audit event encrypt node
51 lines
967 B
Go
51 lines
967 B
Go
package event
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestEventerConfig_Validate(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
c EventerConfig
|
|
wantErrIs error
|
|
wantErrContains string
|
|
}{
|
|
{
|
|
name: "invalid-sink",
|
|
c: EventerConfig{
|
|
Sinks: []*SinkConfig{
|
|
{
|
|
Type: "invalid",
|
|
},
|
|
},
|
|
},
|
|
wantErrIs: ErrInvalidParameter,
|
|
wantErrContains: "is not a valid sink type",
|
|
},
|
|
{
|
|
name: "valid-with-all-defaults",
|
|
c: EventerConfig{},
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
assert, require := assert.New(t), require.New(t)
|
|
err := tt.c.Validate()
|
|
if tt.wantErrIs != nil {
|
|
require.Error(err)
|
|
assert.ErrorIs(err, tt.wantErrIs)
|
|
if tt.wantErrContains != "" {
|
|
assert.Contains(err.Error(), tt.wantErrContains)
|
|
}
|
|
return
|
|
}
|
|
assert.NoError(err)
|
|
})
|
|
}
|
|
}
|