mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
Clean up plugin tests with CA info
This commit is contained in:
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user