-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpath_credentials_test.go
More file actions
58 lines (51 loc) · 1.5 KB
/
Copy pathpath_credentials_test.go
File metadata and controls
58 lines (51 loc) · 1.5 KB
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
package boundarysecrets
import (
"context"
"os"
"testing"
"time"
log "github.com/hashicorp/go-hclog"
"github.com/hashicorp/vault/sdk/helper/logging"
"github.com/hashicorp/vault/sdk/logical"
)
// newAcceptanceTestEnv creates a test environment for credentials
func newAcceptanceTestEnv() (*testEnv, error) {
ctx := context.Background()
maxLease, _ := time.ParseDuration("60s")
defaultLease, _ := time.ParseDuration("30s")
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{
LoginName: os.Getenv(envVarBoundaryLoginName),
Password: os.Getenv(envVarBoundaryPassword),
Addr: os.Getenv(envVarBoundaryAddr),
Backend: b,
Context: ctx,
Storage: &logical.InmemStorage{},
}, nil
}
// TestAcceptanceUserToken tests a series of steps to make
// sure the role and token creation work correctly.
func TestAcceptanceUserToken(t *testing.T) {
if !runAcceptanceTests {
t.SkipNow()
}
acceptanceTestEnv, err := newAcceptanceTestEnv()
if err != nil {
t.Fatal(err)
}
t.Run("add config", acceptanceTestEnv.AddConfig)
t.Run("add user token role", acceptanceTestEnv.AddUserTokenRole)
t.Run("read user token cred", acceptanceTestEnv.ReadUserToken)
t.Run("read user token cred", acceptanceTestEnv.ReadUserToken)
t.Run("cleanup user tokens", acceptanceTestEnv.CleanupUserTokens)
}