Remove old audit behavior from test code (#24540)

* Export audit event

* Move older tests away from audit behavior that didn't use eventlogger

* spelling--;

* no more struct initialization of NoopAudit outside of NewNoopAudit

* locking since we're accessing the shared backend
This commit is contained in:
Peter Wilson
2023-12-15 09:26:34 +00:00
committed by GitHub
parent f0d8dab056
commit 24c6e82a84
11 changed files with 269 additions and 167 deletions

View File

@@ -569,10 +569,8 @@ func TestLogical_RespondWithStatusCode(t *testing.T) {
}
func TestLogical_Audit_invalidWrappingToken(t *testing.T) {
t.Setenv("VAULT_AUDIT_DISABLE_EVENTLOGGER", "true")
// Create a noop audit backend
noop := corehelpers.TestNoopAudit(t, nil)
noop := corehelpers.TestNoopAudit(t, "noop", nil)
c, _, root := vault.TestCoreUnsealedWithConfig(t, &vault.CoreConfig{
AuditBackends: map[string]audit.Factory{
"noop": func(ctx context.Context, config *audit.BackendConfig, _ bool, _ audit.HeaderFormatter) (audit.Backend, error) {
@@ -584,7 +582,6 @@ func TestLogical_Audit_invalidWrappingToken(t *testing.T) {
defer ln.Close()
// Enable the audit backend
resp := testHttpPost(t, root, addr+"/v1/sys/audit/noop", map[string]interface{}{
"type": "noop",
})

View File

@@ -247,8 +247,6 @@ func testServerWithAudit(t *testing.T, records **[][]byte) (net.Listener, string
}
func TestSysGenerateRoot_badKey(t *testing.T) {
t.Setenv("VAULT_AUDIT_DISABLE_EVENTLOGGER", "true")
var records *[][]byte
ln, addr, token, _ := testServerWithAudit(t, &records)
defer ln.Close()