Adding tests to ensure all backends are mountable (#3861)

This commit is contained in:
Chris Hoffman
2018-02-01 11:30:04 -05:00
committed by GitHub
parent f94e7e318b
commit 7cc193d666
5 changed files with 225 additions and 62 deletions

View File

@@ -1,6 +1,7 @@
package command
import (
"io/ioutil"
"strings"
"testing"
@@ -157,4 +158,42 @@ func TestAuditEnableCommand_Run(t *testing.T) {
_, cmd := testAuditEnableCommand(t)
assertNoTabs(t, cmd)
})
t.Run("mount_all", func(t *testing.T) {
t.Parallel()
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 {
ui, cmd := testAuditEnableCommand(t)
cmd.client = client
args := []string{
b,
}
switch b {
case "file":
args = append(args, "file_path=discard")
case "socket":
args = append(args, "address=127.0.0.1:8888")
}
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())
}
}
})
}