forked from kgateway-dev/kgateway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsvc_accnt_test.go
69 lines (56 loc) · 1.95 KB
/
svc_accnt_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
65
66
67
68
69
//go:build ignore
package test
import (
. "github.com/onsi/ginkgo/v2"
glootestutils "github.com/kgateway-dev/kgateway/test/testutils"
. "github.com/onsi/gomega"
. "github.com/solo-io/k8s-utils/manifesttestutils"
)
var _ = Describe("SVC Accnt Test", func() {
var allTests = func(testCase renderTestCase) {
Describe(testCase.rendererName, func() {
var (
testManifest TestManifest
resourceBuilder ResourceBuilder
)
prepareMakefile := func(name string, helmFlags []string) {
resourceBuilder.Name = name
resourceBuilder.Labels["gloo"] = name
tm, err := testCase.renderer.RenderManifest(namespace, glootestutils.HelmValues{
ValuesArgs: helmFlags,
})
Expect(err).NotTo(HaveOccurred(), "Should be able to render the manifest in the service account unit test")
testManifest = tm
}
BeforeEach(func() {
resourceBuilder = ResourceBuilder{
Namespace: namespace,
Labels: map[string]string{
"app": "gloo",
},
}
})
It("gloo", func() {
prepareMakefile("gloo", []string{"global.glooRbac.namespaced=false"})
testManifest.ExpectServiceAccount(resourceBuilder.GetServiceAccount())
})
It("discovery", func() {
prepareMakefile("discovery", []string{"global.glooRbac.namespaced=false"})
testManifest.ExpectServiceAccount(resourceBuilder.GetServiceAccount())
})
It("gateway-proxy", func() {
prepareMakefile("gateway-proxy", []string{"global.glooRbac.namespaced=false"})
svcAccount := resourceBuilder.GetServiceAccount()
testManifest.ExpectServiceAccount(svcAccount)
})
It("gateway-proxy disables svc account", func() {
prepareMakefile("gateway-proxy", []string{"global.glooRbac.namespaced=false", "gateway.proxyServiceAccount.disableAutomount=true"})
svcAccount := resourceBuilder.GetServiceAccount()
falze := false
svcAccount.AutomountServiceAccountToken = &falze
testManifest.ExpectServiceAccount(svcAccount)
})
})
}
runTests(allTests)
})