-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpath_secrets_test.go
59 lines (49 loc) · 1.41 KB
/
path_secrets_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
package kubesecrets
import (
"context"
"testing"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/vault/sdk/logical"
"github.com/onsi/gomega"
)
func TestSecretNamespaceMissing(t *testing.T) {
t.Parallel()
g := gomega.NewGomegaWithT(t)
// create new backend
b, err := newBackend()
g.Expect(err).To(gomega.BeNil())
c := &logical.BackendConfig{
Logger: hclog.New(&hclog.LoggerOptions{}),
}
err = b.Setup(context.Background(), c)
g.Expect(err).To(gomega.BeNil(), "unable to create backend")
request := &logical.Request{
Operation: logical.ReadOperation,
Path: "dummy-secret",
Data: make(map[string]interface{}),
}
errMsg := "Missing secret namespace"
_, err = b.HandleRequest(context.Background(), request)
g.Expect(err.Error()).Should(gomega.Equal(err.Error()), errMsg)
}
func TestSecretExists(t *testing.T) {
t.Parallel()
g := gomega.NewGomegaWithT(t)
// create new backend
b, err := newBackend()
g.Expect(err).To(gomega.BeNil())
c := &logical.BackendConfig{
Logger: hclog.New(&hclog.LoggerOptions{}),
}
err = b.Setup(context.Background(), c)
g.Expect(err).To(gomega.BeNil(), "unable to create backend")
data := make(map[string]interface{})
data["namespace"] = "default"
request := &logical.Request{
Operation: logical.ReadOperation,
Path: "dummy-secret",
Data: data,
}
_, err = b.HandleRequest(context.Background(), request)
g.Expect(err).To(gomega.BeNil())
}