forked from hashicorp/vault-plugin-auth-azure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
backend_test.go
34 lines (30 loc) · 934 Bytes
/
backend_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package azureauth
import (
"context"
"testing"
"time"
log "github.com/hashicorp/go-hclog"
"github.com/hashicorp/vault/sdk/logical"
)
func getTestBackend(t *testing.T) (*azureAuthBackend, logical.Storage) {
return getTestBackendWithComputeClient(t, nil, nil)
}
func getTestBackendWithComputeClient(t *testing.T, c computeClientFunc, v vmssClientFunc) (*azureAuthBackend, logical.Storage) {
defaultLeaseTTLVal := time.Hour * 12
maxLeaseTTLVal := time.Hour * 24
config := &logical.BackendConfig{
Logger: log.New(&log.LoggerOptions{Level: log.Trace}),
System: &logical.StaticSystemView{
DefaultLeaseTTLVal: defaultLeaseTTLVal,
MaxLeaseTTLVal: maxLeaseTTLVal,
},
StorageView: &logical.InmemStorage{},
}
b := backend(config)
err := b.Setup(context.Background(), config)
if err != nil {
t.Fatalf("unable to create backend: %v", err)
}
b.provider = newMockProvider(c, v)
return b, config.StorageView
}