VAULT-24452: audit refactor (#26460)

* Refactor audit code into audit package
* remove builtin/audit
* removed unrequired files
This commit is contained in:
Peter Wilson
2024-04-18 08:25:04 +01:00
committed by GitHub
parent 961bf20bdb
commit 8bee54c89d
60 changed files with 2638 additions and 3214 deletions

View File

@@ -4,7 +4,6 @@
package command
import (
"io/ioutil"
"os"
"strings"
"testing"
@@ -169,26 +168,12 @@ func TestAuditEnableCommand_Run(t *testing.T) {
client, closer := testVaultServerAllBackends(t)
defer closer()
files, err := ioutil.ReadDir("../builtin/audit")
if err != nil {
t.Fatal(err)
}
var backends []string
for _, f := range files {
if f.IsDir() {
backends = append(backends, f.Name())
}
}
for _, b := range backends {
for name := range auditBackends {
ui, cmd := testAuditEnableCommand(t)
cmd.client = client
args := []string{
b,
}
switch b {
args := []string{name}
switch name {
case "file":
args = append(args, "file_path=discard")
case "socket":
@@ -199,15 +184,10 @@ func TestAuditEnableCommand_Run(t *testing.T) {
t.Log("skipping syslog test on WSL")
continue
}
if os.Getenv("CIRCLECI") == "true" {
// TODO install syslog in docker image we run our tests in
t.Log("skipping syslog test on CircleCI")
continue
}
}
code := cmd.Run(args)
if exp := 0; code != exp {
t.Errorf("type %s, expected %d to be %d - %s", b, code, exp, ui.OutputWriter.String()+ui.ErrorWriter.String())
t.Errorf("type %s, expected %d to be %d - %s", name, code, exp, ui.OutputWriter.String()+ui.ErrorWriter.String())
}
}
})