mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
Use backend function instead of separate backend creation in consul
This commit is contained in:
@@ -9,7 +9,7 @@ func Factory(conf *logical.BackendConfig) (logical.Backend, error) {
|
||||
return Backend().Setup(conf)
|
||||
}
|
||||
|
||||
func Backend() *framework.Backend {
|
||||
func Backend() *backend {
|
||||
var b backend
|
||||
b.Backend = &framework.Backend{
|
||||
Paths: []*framework.Path{
|
||||
@@ -23,7 +23,7 @@ func Backend() *framework.Backend {
|
||||
},
|
||||
}
|
||||
|
||||
return b.Backend
|
||||
return &b
|
||||
}
|
||||
|
||||
type backend struct {
|
||||
|
@@ -15,33 +15,10 @@ import (
|
||||
|
||||
"github.com/hashicorp/consul/api"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/logical/framework"
|
||||
logicaltest "github.com/hashicorp/vault/logical/testing"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
)
|
||||
|
||||
func createBackend() *backend {
|
||||
var b backend
|
||||
b.Backend = &framework.Backend{
|
||||
PathsSpecial: &logical.Paths{
|
||||
Root: []string{
|
||||
"config/*",
|
||||
},
|
||||
},
|
||||
|
||||
Paths: []*framework.Path{
|
||||
pathConfigAccess(),
|
||||
pathRoles(),
|
||||
pathToken(&b),
|
||||
},
|
||||
|
||||
Secrets: []*framework.Secret{
|
||||
secretToken(&b),
|
||||
},
|
||||
}
|
||||
return &b
|
||||
}
|
||||
|
||||
func TestBackend_config_access(t *testing.T) {
|
||||
if os.Getenv(logicaltest.TestEnvVar) == "" {
|
||||
t.Skip(fmt.Sprintf("Acceptance tests skipped unless env '%s' set", logicaltest.TestEnvVar))
|
||||
@@ -55,8 +32,8 @@ func TestBackend_config_access(t *testing.T) {
|
||||
storage := &logical.InmemStorage{}
|
||||
config.StorageView = storage
|
||||
|
||||
b := createBackend()
|
||||
_, err := b.Backend.Setup(config)
|
||||
b := Backend()
|
||||
_, err := b.Setup(config)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user