Merge pull request #1484 from hashicorp/consul-be-test

Use backend function instead of separate backend creation in consul
This commit is contained in:
Jeff Mitchell 2016-06-03 10:09:19 -04:00
commit 5b18c10826
2 changed files with 4 additions and 27 deletions

View file

@ -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 {

View file

@ -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)
}