@@ -24,8 +24,8 @@ var _ = Describe("Get", func() {
2424 irsaManager = irsa .New ("my-cluster" , fakeStackManager , nil , nil )
2525 })
2626
27- When ("no options are specified " , func () {
28- It ("returns all service accounts" , func () {
27+ When ("no error occurs " , func () {
28+ It ("returns service accounts from GetIAMServiceAccounts " , func () {
2929 fakeStackManager .GetIAMServiceAccountsReturns ([]* api.ClusterIAMServiceAccount {
3030 {
3131 ClusterIAMMeta : api.ClusterIAMMeta {
@@ -65,109 +65,4 @@ var _ = Describe("Get", func() {
6565 }))
6666 })
6767 })
68-
69- When ("name option is specified" , func () {
70- It ("returns only the service account matching the name" , func () {
71- fakeStackManager .GetIAMServiceAccountsReturns ([]* api.ClusterIAMServiceAccount {
72- {
73- ClusterIAMMeta : api.ClusterIAMMeta {
74- Name : "test-sa" ,
75- Namespace : "default" ,
76- },
77- AttachPolicyARNs : []string {"arn-123" },
78- },
79- {
80- ClusterIAMMeta : api.ClusterIAMMeta {
81- Name : "test-sa-2" ,
82- Namespace : "not-default" ,
83- },
84- AttachPolicyARNs : []string {"arn-123" },
85- },
86- }, nil )
87-
88- serviceAccounts , err := irsaManager .Get (context .Background (), irsa.GetOptions {Name : "test-sa" })
89- Expect (err ).NotTo (HaveOccurred ())
90-
91- Expect (fakeStackManager .GetIAMServiceAccountsCallCount ()).To (Equal (1 ))
92- Expect (serviceAccounts ).To (Equal ([]* api.ClusterIAMServiceAccount {
93- {
94- ClusterIAMMeta : api.ClusterIAMMeta {
95- Name : "test-sa" ,
96- Namespace : "default" ,
97- },
98- AttachPolicyARNs : []string {"arn-123" },
99- },
100- }))
101- })
102- })
103-
104- When ("namespace option is specified" , func () {
105- It ("returns only the service account matching the name" , func () {
106- fakeStackManager .GetIAMServiceAccountsReturns ([]* api.ClusterIAMServiceAccount {
107- {
108- ClusterIAMMeta : api.ClusterIAMMeta {
109- Name : "test-sa" ,
110- Namespace : "default" ,
111- },
112- AttachPolicyARNs : []string {"arn-123" },
113- },
114- {
115- ClusterIAMMeta : api.ClusterIAMMeta {
116- Name : "test-sa-2" ,
117- Namespace : "not-default" ,
118- },
119- AttachPolicyARNs : []string {"arn-123" },
120- },
121- }, nil )
122-
123- serviceAccounts , err := irsaManager .Get (context .Background (), irsa.GetOptions {Namespace : "not-default" })
124- Expect (err ).NotTo (HaveOccurred ())
125-
126- Expect (fakeStackManager .GetIAMServiceAccountsCallCount ()).To (Equal (1 ))
127- Expect (serviceAccounts ).To (Equal ([]* api.ClusterIAMServiceAccount {
128- {
129- ClusterIAMMeta : api.ClusterIAMMeta {
130- Name : "test-sa-2" ,
131- Namespace : "not-default" ,
132- },
133- AttachPolicyARNs : []string {"arn-123" },
134- },
135- }))
136- })
137- })
138-
139- When ("name and namespace option is specified" , func () {
140- It ("returns only the service account matching the name" , func () {
141- fakeStackManager .GetIAMServiceAccountsReturns ([]* api.ClusterIAMServiceAccount {
142- {
143- ClusterIAMMeta : api.ClusterIAMMeta {
144- Name : "test-sa" ,
145- Namespace : "default" ,
146- },
147- AttachPolicyARNs : []string {"arn-123" },
148- },
149- {
150- ClusterIAMMeta : api.ClusterIAMMeta {
151- Name : "some-other-sa" ,
152- Namespace : "default" ,
153- },
154- AttachPolicyARNs : []string {"arn-123" },
155- },
156- }, nil )
157-
158- serviceAccounts , err := irsaManager .Get (context .Background (), irsa.GetOptions {Namespace : "default" , Name : "test-sa" })
159- Expect (err ).NotTo (HaveOccurred ())
160-
161- Expect (fakeStackManager .GetIAMServiceAccountsCallCount ()).To (Equal (1 ))
162- Expect (serviceAccounts ).To (Equal ([]* api.ClusterIAMServiceAccount {
163- {
164- ClusterIAMMeta : api.ClusterIAMMeta {
165- Name : "test-sa" ,
166- Namespace : "default" ,
167- },
168- AttachPolicyARNs : []string {"arn-123" },
169- },
170- }))
171- })
172- })
17368})
0 commit comments