Clean up plugin tests with CA info

This commit is contained in:
Jeff Mitchell
2017-07-31 15:09:09 -04:00
parent 211a324d04
commit efe5a35c4a
3 changed files with 12 additions and 60 deletions

View File

@@ -1,7 +1,6 @@
package plugin
import (
"io/ioutil"
"os"
"testing"
@@ -38,27 +37,12 @@ func TestBackend_PluginMain(t *testing.T) {
return
}
caPem := os.Getenv(pluginutil.PluginCACertPEMEnv)
if caPem == "" {
caPEM := os.Getenv(pluginutil.PluginCACertPEMEnv)
if caPEM == "" {
t.Fatal("CA cert not passed in")
}
content := []byte(caPem)
tmpfile, err := ioutil.TempFile("", "test-cacert")
if err != nil {
t.Fatal(err)
}
defer os.Remove(tmpfile.Name()) // clean up
if _, err := tmpfile.Write(content); err != nil {
t.Fatal(err)
}
if err := tmpfile.Close(); err != nil {
t.Fatal(err)
}
args := []string{"--ca-cert=" + tmpfile.Name()}
args := []string{"--ca-cert=" + caPEM}
apiClientMeta := &pluginutil.APIClientMeta{}
flags := apiClientMeta.FlagSet()
@@ -94,7 +78,7 @@ func testConfig(t *testing.T) (*logical.BackendConfig, func()) {
},
}
os.Setenv(pluginutil.PluginCACertPEMEnv, string(cluster.CACertPEM))
os.Setenv(pluginutil.PluginCACertPEMEnv, cluster.CACertPEMFile)
vault.TestAddTestPlugin(t, core.Core, "mock-plugin", "TestBackend_PluginMain")