-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpath_credentials_test.go
64 lines (51 loc) · 1.42 KB
/
path_credentials_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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package secretsengine
import (
"context"
"os"
"testing"
"time"
log "github.com/hashicorp/go-hclog"
"github.com/hashicorp/vault/sdk/helper/logging"
"github.com/hashicorp/vault/sdk/logical"
)
func newTestEnv() (*testEnv, error) {
ctx := context.Background()
defaultLease, _ := time.ParseDuration("1d")
maxLease, _ := time.ParseDuration("1d")
conf := &logical.BackendConfig{
System: &logical.StaticSystemView{
DefaultLeaseTTLVal: defaultLease,
MaxLeaseTTLVal: maxLease,
},
Logger: logging.NewVaultLogger(log.Debug),
}
b, err := Factory(ctx, conf)
if err != nil {
return nil, err
}
return &testEnv{
Host: os.Getenv(envVarApigeeHost),
OAuthToken: os.Getenv(envVarApigeeOAuthToken),
Username: os.Getenv(envVarApigeeUsername),
Password: os.Getenv(envVarApigeePassword),
OrgName: os.Getenv(envVarApigeeOrgName),
DeveloperEmail: os.Getenv(envVarApigeeDeveloperEmail),
AppName: os.Getenv(envVarApigeeAppName),
ApiProducts: os.Getenv(envVarApigeeApiProducts),
Backend: b,
Context: ctx,
Storage: &logical.InmemStorage{},
}, nil
}
func TestCreds(t *testing.T) {
testEnv, err := newTestEnv()
if err != nil {
t.Fatal(err)
}
t.Run("CreateConfig", testEnv.CreateConfig)
t.Run("CreateRole", testEnv.CreateRole)
t.Run("ReadCred1", testEnv.ReadCred)
t.Run("ReadCred2", testEnv.ReadCred)
t.Run("ReadCred3", testEnv.ReadCred)
t.Run("DeleteCreds", testEnv.DeleteCreds)
}