mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-03 03:58:01 +00:00
Update databse backend tests to use the APIClientMeta for the plugin conns
This commit is contained in:
@@ -3,6 +3,7 @@ package database
|
|||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
stdhttp "net/http"
|
stdhttp "net/http"
|
||||||
"os"
|
"os"
|
||||||
@@ -10,7 +11,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/vault/api"
|
|
||||||
"github.com/hashicorp/vault/builtin/logical/database/dbplugin"
|
"github.com/hashicorp/vault/builtin/logical/database/dbplugin"
|
||||||
"github.com/hashicorp/vault/helper/pluginutil"
|
"github.com/hashicorp/vault/helper/pluginutil"
|
||||||
"github.com/hashicorp/vault/http"
|
"github.com/hashicorp/vault/http"
|
||||||
@@ -109,11 +109,28 @@ func TestBackend_PluginMain(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := postgresql.Run(&api.TLSConfig{Insecure: true})
|
content := []byte(vault.TestClusterCACert)
|
||||||
|
tmpfile, err := ioutil.TempFile("", "example")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
t.Fatal("We shouldn't get here")
|
|
||||||
|
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{}
|
||||||
|
flags := apiClientMeta.FlagSet()
|
||||||
|
flags.Parse(args)
|
||||||
|
|
||||||
|
postgresql.Run(apiClientMeta.GetTLSConfig())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBackend_config_connection(t *testing.T) {
|
func TestBackend_config_connection(t *testing.T) {
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/vault/api"
|
|
||||||
"github.com/hashicorp/vault/builtin/logical/database/dbplugin"
|
"github.com/hashicorp/vault/builtin/logical/database/dbplugin"
|
||||||
"github.com/hashicorp/vault/helper/pluginutil"
|
"github.com/hashicorp/vault/helper/pluginutil"
|
||||||
"github.com/hashicorp/vault/http"
|
"github.com/hashicorp/vault/http"
|
||||||
@@ -107,7 +106,13 @@ func TestPlugin_Main(t *testing.T) {
|
|||||||
users: make(map[string][]string),
|
users: make(map[string][]string),
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins.Serve(plugin, &api.TLSConfig{Insecure: true})
|
args := []string{"--tls-skip-verify=true"}
|
||||||
|
|
||||||
|
apiClientMeta := &pluginutil.APIClientMeta{}
|
||||||
|
flags := apiClientMeta.FlagSet()
|
||||||
|
flags.Parse(args)
|
||||||
|
|
||||||
|
plugins.Serve(plugin, apiClientMeta.GetTLSConfig())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPlugin_Initialize(t *testing.T) {
|
func TestPlugin_Initialize(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user