* 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
40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
package event
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestDataClassification_Validate(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
c DataClassification
|
|
wantIsErr error
|
|
wantErrContains string
|
|
}{
|
|
{name: "invalid........", c: "invalid", wantIsErr: ErrInvalidParameter, wantErrContains: "invalid data classification 'invalid'"},
|
|
{name: "invalid-unknown", c: UnknownClassification, wantIsErr: ErrInvalidParameter, wantErrContains: "invalid data classification 'unknown'"},
|
|
{name: "valid-sensitive", c: SensitiveClassification},
|
|
{name: "valid-public...", c: PublicClassification},
|
|
{name: "valid-secret...", c: SecretClassification},
|
|
{name: "valid-unknown..", c: SecretClassification},
|
|
}
|
|
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.wantIsErr != nil {
|
|
require.Error(err)
|
|
assert.ErrorIs(err, tt.wantIsErr)
|
|
if tt.wantErrContains != "" {
|
|
assert.Contains(err.Error(), tt.wantErrContains)
|
|
}
|
|
return
|
|
}
|
|
require.NoError(err)
|
|
})
|
|
}
|
|
}
|