forked from gardener/gardener
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstatic_token_test.go
More file actions
76 lines (65 loc) · 1.88 KB
/
Copy pathstatic_token_test.go
File metadata and controls
76 lines (65 loc) · 1.88 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// SPDX-FileCopyrightText: SAP SE or an SAP affiliate company and Gardener contributors
//
// SPDX-License-Identifier: Apache-2.0
package secrets_test
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/gardener/gardener/pkg/utils/secrets"
)
var _ = Describe("Static Token Secrets", func() {
Describe("StaticToken Secret Configuration", func() {
var (
staticTokenConfig *StaticTokenSecretConfig
username = "bar"
)
BeforeEach(func() {
staticTokenConfig = &StaticTokenSecretConfig{
Name: "static-token",
Tokens: map[string]TokenConfig{
username: {
Username: username,
UserID: "foo",
Groups: []string{"group"},
},
},
}
})
Describe("#Generate", func() {
It("should properly generate RSAKeys object", func() {
obj, err := staticTokenConfig.Generate()
Expect(err).NotTo(HaveOccurred())
staticToken, ok := obj.(*StaticToken)
Expect(ok).To(BeTrue())
Expect(staticToken.Tokens).To(HaveLen(1))
Expect(staticToken.Tokens[0].Token).ToNot(Equal(""))
Expect(staticToken.Tokens[0].Username).To(Equal(staticTokenConfig.Tokens[username].Username))
Expect(staticToken.Tokens[0].UserID).To(Equal(staticTokenConfig.Tokens[username].UserID))
Expect(staticToken.Tokens[0].Groups).To(Equal(staticTokenConfig.Tokens[username].Groups))
})
})
})
Describe("StaticToken Object", func() {
var staticToken *StaticToken
BeforeEach(func() {
staticToken = &StaticToken{
Tokens: []Token{
{
Token: "foo",
Username: "foo",
UserID: "bar",
Groups: []string{"group"},
},
},
}
})
Describe("#SecretData", func() {
It("should properly return secret data", func() {
secretData := map[string][]byte{
DataKeyStaticTokenCSV: []byte("foo,foo,bar,group"),
}
Expect(staticToken.SecretData()).To(Equal(secretData))
})
})
})
})