Skip to content

Commit b769557

Browse files
blvaandreaangiolillotibulca
authored
CLOUDP-244266: Add connect e2e tests (#2888)
Co-authored-by: Andrea Angiolillo <[email protected]> Co-authored-by: Ciprian Tibulca <[email protected]>
1 parent 91bd8d1 commit b769557

File tree

2 files changed

+129
-80
lines changed

2 files changed

+129
-80
lines changed

test/e2e/atlas/helper_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const (
101101
federatedAuthenticationEntity = "federatedAuthentication"
102102
federationSettingsEntity = "federationSettings"
103103
identityProviderEntity = "identityProvider"
104+
connectedOrgsConfigsEntity = "connectedOrgConfigs"
104105
deletingState = "DELETING"
105106
authEntity = "auth"
106107
)

test/e2e/atlas/identity_providers_test.go

+128-80
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ func TestIdentityProviders(t *testing.T) {
3535
req.NoError(err)
3636

3737
var federationSettingsID string
38-
var oidcIdentityProviderID string
38+
var oidcWorkloadIdpID string
39+
var oidcIWorkforceIdpID string
3940

4041
t.Run("Describe an org federation settings", func(t *testing.T) {
4142
cmd := exec.Command(cliPath,
@@ -58,18 +59,33 @@ func TestIdentityProviders(t *testing.T) {
5859
federationSettingsID = settings.GetId()
5960
})
6061

61-
t.Run("List OIDC IdPs WORKFORCE", func(_ *testing.T) {
62+
t.Run("Create OIDC IdP WORKLOAD", func(t *testing.T) {
63+
idpName, err := RandIdentityProviderName()
64+
req.NoError(err)
65+
6266
cmd := exec.Command(cliPath,
6367
federatedAuthenticationEntity,
6468
federationSettingsEntity,
6569
identityProviderEntity,
66-
"list",
70+
"create",
71+
"oidc",
72+
idpName,
6773
"--federationSettingsId",
6874
federationSettingsID,
69-
"--protocol",
70-
"OIDC",
75+
"--audience",
76+
idpName, // using random as audience also should be unique
77+
"--authorizationType",
78+
"GROUP",
79+
"--desc",
80+
"CLI TEST Provider",
81+
"--groupsClaim",
82+
"groups",
7183
"--idpType",
72-
"WORKFORCE",
84+
"WORKLOAD",
85+
"--issuerUri",
86+
"https://accounts.google.com",
87+
"--userClaim",
88+
"user",
7389
"-o=json",
7490
)
7591

@@ -79,20 +95,43 @@ func TestIdentityProviders(t *testing.T) {
7995

8096
var provider atlasv2.FederationIdentityProvider
8197
req.NoError(json.Unmarshal(resp, &provider))
98+
99+
assert.NotEmpty(t, provider.GetId())
100+
oidcWorkloadIdpID = provider.GetId()
82101
})
83102

84-
t.Run("List OIDC IdPs WORKLOAD", func(_ *testing.T) {
103+
t.Run("Create OIDC IdP WORKFORCE", func(t *testing.T) {
104+
idpName, err := RandIdentityProviderName()
105+
fmt.Println(idpName)
106+
req.NoError(err)
107+
85108
cmd := exec.Command(cliPath,
86109
federatedAuthenticationEntity,
87110
federationSettingsEntity,
88111
identityProviderEntity,
89-
"list",
112+
"create",
113+
"oidc",
114+
idpName,
90115
"--federationSettingsId",
91116
federationSettingsID,
92-
"--protocol",
93-
"OIDC",
117+
"--audience",
118+
idpName, // using random as audience also should be unique
119+
"--authorizationType",
120+
"GROUP",
121+
"--clientId",
122+
"cliClients",
123+
"--desc",
124+
"CLI TEST Provider",
125+
"--groupsClaim",
126+
"groups",
94127
"--idpType",
95-
"WORKLOAD",
128+
"WORKFORCE",
129+
"--issuerUri",
130+
"https://accounts.google.com",
131+
"--userClaim",
132+
"user",
133+
"--associatedDomain",
134+
"iam-test-domain-dev.com",
96135
"-o=json",
97136
)
98137

@@ -102,18 +141,20 @@ func TestIdentityProviders(t *testing.T) {
102141

103142
var provider atlasv2.FederationIdentityProvider
104143
req.NoError(json.Unmarshal(resp, &provider))
144+
145+
assert.NotEmpty(t, provider.GetId())
146+
oidcIWorkforceIdpID = provider.Id
105147
})
106148

107-
t.Run("List SAML IdPs", func(_ *testing.T) {
149+
t.Run("Describe OIDC IdP WORKFORCE", func(t *testing.T) {
108150
cmd := exec.Command(cliPath,
109151
federatedAuthenticationEntity,
110152
federationSettingsEntity,
111153
identityProviderEntity,
112-
"list",
154+
"describe",
155+
oidcIWorkforceIdpID,
113156
"--federationSettingsId",
114157
federationSettingsID,
115-
"--protocol",
116-
"SAML",
117158
"-o=json",
118159
)
119160

@@ -123,58 +164,69 @@ func TestIdentityProviders(t *testing.T) {
123164

124165
var provider atlasv2.FederationIdentityProvider
125166
req.NoError(json.Unmarshal(resp, &provider))
167+
168+
assert.NotEmpty(t, provider.GetId())
126169
})
127170

128-
t.Run("Create OIDC IdP WORKLOAD", func(t *testing.T) {
129-
idpName, err := RandIdentityProviderName()
130-
req.NoError(err)
171+
t.Run("Connect OIDC IdP WORKFORCE", func(t *testing.T) {
172+
cmd := exec.Command(cliPath,
173+
federatedAuthenticationEntity,
174+
federationSettingsEntity,
175+
connectedOrgsConfigsEntity,
176+
"connect",
177+
"--identityProviderId",
178+
oidcIWorkforceIdpID,
179+
"--federationSettingsId",
180+
federationSettingsID,
181+
"-o=json",
182+
)
131183

184+
cmd.Env = os.Environ()
185+
resp, err := cmd.CombinedOutput()
186+
req.NoError(err, string(resp))
187+
188+
var config atlasv2.ConnectedOrgConfig
189+
req.NoError(json.Unmarshal(resp, &config))
190+
191+
assert.NotEmpty(t, config.DataAccessIdentityProviderIds)
192+
assert.Contains(t, config.GetDataAccessIdentityProviderIds(), oidcIWorkforceIdpID)
193+
})
194+
195+
t.Run("Disconnect OIDC IdP WORKFORCE", func(t *testing.T) {
132196
cmd := exec.Command(cliPath,
133197
federatedAuthenticationEntity,
134198
federationSettingsEntity,
135-
identityProviderEntity,
136-
"create",
137-
"oidc",
138-
idpName,
199+
connectedOrgsConfigsEntity,
200+
"disconnect",
201+
"--identityProviderId",
202+
oidcIWorkforceIdpID,
139203
"--federationSettingsId",
140204
federationSettingsID,
141-
"--audience",
142-
"AtlasCLIAudience",
143-
"--authorizationType",
144-
"GROUP",
145-
"--desc",
146-
"CLI TEST Provider",
147-
"--groupsClaim",
148-
"groups",
149-
"--idpType",
150-
"WORKLOAD",
151-
"--issuerUri",
152-
"https://accounts.google.com",
153-
"--userClaim",
154-
"user",
155205
"-o=json",
156206
)
157207

158208
cmd.Env = os.Environ()
159209
resp, err := cmd.CombinedOutput()
160210
req.NoError(err, string(resp))
161211

162-
var provider atlasv2.FederationIdentityProvider
163-
req.NoError(json.Unmarshal(resp, &provider))
212+
var config atlasv2.ConnectedOrgConfig
213+
req.NoError(json.Unmarshal(resp, &config))
164214

165-
assert.NotEmpty(t, provider.GetId())
166-
oidcIdentityProviderID = provider.GetId()
215+
assert.NotContains(t, config.GetDataAccessIdentityProviderIds(), oidcIWorkforceIdpID)
167216
})
168217

169-
t.Run("Describe OIDC IdP WORKFORCE", func(t *testing.T) {
218+
t.Run("List OIDC IdPs WORKFORCE", func(_ *testing.T) {
170219
cmd := exec.Command(cliPath,
171220
federatedAuthenticationEntity,
172221
federationSettingsEntity,
173222
identityProviderEntity,
174-
"describe",
175-
oidcIdentityProviderID,
223+
"list",
176224
"--federationSettingsId",
177225
federationSettingsID,
226+
"--protocol",
227+
"OIDC",
228+
"--idpType",
229+
"WORKFORCE",
178230
"-o=json",
179231
)
180232

@@ -184,60 +236,41 @@ func TestIdentityProviders(t *testing.T) {
184236

185237
var provider atlasv2.FederationIdentityProvider
186238
req.NoError(json.Unmarshal(resp, &provider))
187-
188-
assert.NotEmpty(t, provider.GetId())
189239
})
190240

191-
t.Run("Delete OIDC IdP WORKFORCE", func(_ *testing.T) {
241+
t.Run("List OIDC IdPs WORKLOAD", func(_ *testing.T) {
192242
cmd := exec.Command(cliPath,
193243
federatedAuthenticationEntity,
194244
federationSettingsEntity,
195245
identityProviderEntity,
196-
"delete",
197-
oidcIdentityProviderID,
246+
"list",
198247
"--federationSettingsId",
199248
federationSettingsID,
200-
"--force",
249+
"--protocol",
250+
"OIDC",
251+
"--idpType",
252+
"WORKLOAD",
201253
"-o=json",
202254
)
203255

204256
cmd.Env = os.Environ()
205257
resp, err := cmd.CombinedOutput()
206258
req.NoError(err, string(resp))
207-
})
208259

209-
t.Run("Create OIDC IdP WORKFORCE", func(t *testing.T) {
210-
idpName, err := RandIdentityProviderName()
211-
fmt.Println(idpName)
212-
req.NoError(err)
260+
var provider atlasv2.FederationIdentityProvider
261+
req.NoError(json.Unmarshal(resp, &provider))
262+
})
213263

264+
t.Run("List SAML IdPs", func(_ *testing.T) {
214265
cmd := exec.Command(cliPath,
215266
federatedAuthenticationEntity,
216267
federationSettingsEntity,
217268
identityProviderEntity,
218-
"create",
219-
"oidc",
220-
idpName,
269+
"list",
221270
"--federationSettingsId",
222271
federationSettingsID,
223-
"--audience",
224-
"AtlasCLIAudience",
225-
"--authorizationType",
226-
"GROUP",
227-
"--clientId",
228-
"cliClients",
229-
"--desc",
230-
"CLI TEST Provider",
231-
"--groupsClaim",
232-
"groups",
233-
"--idpType",
234-
"WORKFORCE",
235-
"--issuerUri",
236-
"https://accounts.google.com",
237-
"--userClaim",
238-
"user",
239-
"--associatedDomain",
240-
"iam-test-domain-dev.com",
272+
"--protocol",
273+
"SAML",
241274
"-o=json",
242275
)
243276

@@ -247,9 +280,6 @@ func TestIdentityProviders(t *testing.T) {
247280

248281
var provider atlasv2.FederationIdentityProvider
249282
req.NoError(json.Unmarshal(resp, &provider))
250-
251-
assert.NotEmpty(t, provider.GetId())
252-
oidcIdentityProviderID = provider.Id
253283
})
254284

255285
t.Run("Describe OIDC IdP WORKFORCE", func(t *testing.T) {
@@ -258,7 +288,7 @@ func TestIdentityProviders(t *testing.T) {
258288
federationSettingsEntity,
259289
identityProviderEntity,
260290
"describe",
261-
oidcIdentityProviderID,
291+
oidcIWorkforceIdpID,
262292
"--federationSettingsId",
263293
federationSettingsID,
264294
"-o=json",
@@ -279,7 +309,25 @@ func TestIdentityProviders(t *testing.T) {
279309
federationSettingsEntity,
280310
identityProviderEntity,
281311
"delete",
282-
oidcIdentityProviderID,
312+
oidcIWorkforceIdpID,
313+
"--federationSettingsId",
314+
federationSettingsID,
315+
"--force",
316+
"-o=json",
317+
)
318+
319+
cmd.Env = os.Environ()
320+
resp, err := cmd.CombinedOutput()
321+
req.NoError(err, string(resp))
322+
})
323+
324+
t.Run("Delete OIDC IdP WORKLOAD", func(_ *testing.T) {
325+
cmd := exec.Command(cliPath,
326+
federatedAuthenticationEntity,
327+
federationSettingsEntity,
328+
identityProviderEntity,
329+
"delete",
330+
oidcWorkloadIdpID,
283331
"--federationSettingsId",
284332
federationSettingsID,
285333
"--force",

0 commit comments

Comments
 (0)