mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-03 03:58:01 +00:00
Clean up plugin tests with CA info
This commit is contained in:
@@ -3,7 +3,6 @@ package database
|
|||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
@@ -90,7 +89,7 @@ func getCluster(t *testing.T) (*vault.TestCluster, logical.SystemView) {
|
|||||||
cluster.Start()
|
cluster.Start()
|
||||||
cores := cluster.Cores
|
cores := cluster.Cores
|
||||||
|
|
||||||
os.Setenv(pluginutil.PluginCACertPEMEnv, string(cluster.CACertPEM))
|
os.Setenv(pluginutil.PluginCACertPEMEnv, cluster.CACertPEMFile)
|
||||||
|
|
||||||
sys := vault.TestDynamicSystemView(cores[0].Core)
|
sys := vault.TestDynamicSystemView(cores[0].Core)
|
||||||
vault.TestAddTestPlugin(t, cores[0].Core, "postgresql-database-plugin", "TestBackend_PluginMain")
|
vault.TestAddTestPlugin(t, cores[0].Core, "postgresql-database-plugin", "TestBackend_PluginMain")
|
||||||
@@ -103,27 +102,12 @@ func TestBackend_PluginMain(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
caPem := os.Getenv(pluginutil.PluginCACertPEMEnv)
|
caPEM := os.Getenv(pluginutil.PluginCACertPEMEnv)
|
||||||
if caPem == "" {
|
if caPEM == "" {
|
||||||
t.Fatal("CA cert not passed in")
|
t.Fatal("CA cert not passed in")
|
||||||
}
|
}
|
||||||
|
|
||||||
content := []byte(caPem)
|
args := []string{"--ca-cert=" + caPEM}
|
||||||
tmpfile, err := ioutil.TempFile("", "example")
|
|
||||||
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()}
|
|
||||||
|
|
||||||
apiClientMeta := &pluginutil.APIClientMeta{}
|
apiClientMeta := &pluginutil.APIClientMeta{}
|
||||||
flags := apiClientMeta.FlagSet()
|
flags := apiClientMeta.FlagSet()
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package plugin
|
package plugin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -38,27 +37,12 @@ func TestBackend_PluginMain(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
caPem := os.Getenv(pluginutil.PluginCACertPEMEnv)
|
caPEM := os.Getenv(pluginutil.PluginCACertPEMEnv)
|
||||||
if caPem == "" {
|
if caPEM == "" {
|
||||||
t.Fatal("CA cert not passed in")
|
t.Fatal("CA cert not passed in")
|
||||||
}
|
}
|
||||||
|
|
||||||
content := []byte(caPem)
|
args := []string{"--ca-cert=" + 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()}
|
|
||||||
|
|
||||||
apiClientMeta := &pluginutil.APIClientMeta{}
|
apiClientMeta := &pluginutil.APIClientMeta{}
|
||||||
flags := apiClientMeta.FlagSet()
|
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")
|
vault.TestAddTestPlugin(t, core.Core, "mock-plugin", "TestBackend_PluginMain")
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package vault_test
|
package vault_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@@ -48,7 +47,7 @@ func TestSystemBackend_enableAuth_plugin(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
os.Setenv(pluginutil.PluginCACertPEMEnv, string(cluster.CACertPEM))
|
os.Setenv(pluginutil.PluginCACertPEMEnv, cluster.CACertPEMFile)
|
||||||
|
|
||||||
vault.TestAddTestPlugin(t, core.Core, "mock-plugin", "TestBackend_PluginMain")
|
vault.TestAddTestPlugin(t, core.Core, "mock-plugin", "TestBackend_PluginMain")
|
||||||
|
|
||||||
@@ -70,29 +69,14 @@ func TestBackend_PluginMain(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
caPem := os.Getenv(pluginutil.PluginCACertPEMEnv)
|
caPEM := os.Getenv(pluginutil.PluginCACertPEMEnv)
|
||||||
if caPem == "" {
|
if caPEM == "" {
|
||||||
t.Fatal("CA cert not passed in")
|
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)
|
|
||||||
}
|
|
||||||
|
|
||||||
factoryFunc := mock.FactoryType(logical.TypeCredential)
|
factoryFunc := mock.FactoryType(logical.TypeCredential)
|
||||||
|
|
||||||
args := []string{"--ca-cert=" + tmpfile.Name()}
|
args := []string{"--ca-cert=" + caPEM}
|
||||||
|
|
||||||
apiClientMeta := &pluginutil.APIClientMeta{}
|
apiClientMeta := &pluginutil.APIClientMeta{}
|
||||||
flags := apiClientMeta.FlagSet()
|
flags := apiClientMeta.FlagSet()
|
||||||
|
|||||||
Reference in New Issue
Block a user