Skip to content

Commit c2457d1

Browse files
committed
Improve one ingress per domain test
1 parent 9fb0a05 commit c2457d1

File tree

1 file changed

+64
-14
lines changed

1 file changed

+64
-14
lines changed

integration/test/Test/Spar/MultiIngressIdp.hs

Lines changed: 64 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -164,36 +164,86 @@ testMultiIngressAtMostOneIdPPerDomain = do
164164
resp.status `shouldMatchInt` 201
165165
resp.jsonBody %. "id" >>= asString
166166

167+
-- Creating a second IdP for the same domain -> failure
167168
SAML.SampleIdP idpmeta2 _ _ _ <- SAML.makeSampleIdPMetadata
168-
void $ createIdpWithZHost owner (Just ernieZHost) idpmeta2 `bindResponse` \resp -> do
169-
resp.status `shouldMatchInt` 409
170-
resp.jsonBody %. "label" `shouldMatch` "idp-duplicate-domain-for-team"
169+
_idpId2 <-
170+
createIdpWithZHost owner (Just ernieZHost) idpmeta2 `bindResponse` \resp -> do
171+
resp.status `shouldMatchInt` 409
172+
resp.jsonBody %. "label" `shouldMatch` "idp-duplicate-domain-for-team"
173+
174+
-- Create an IdP for one domain and update it to another that already has one -> failure
175+
SAML.SampleIdP idpmeta3 _ _ _ <- SAML.makeSampleIdPMetadata
176+
idpId3 <-
177+
createIdpWithZHost owner (Just bertZHost) idpmeta2 `bindResponse` \resp -> do
178+
resp.status `shouldMatchInt` 201
179+
resp.jsonBody %. "id" >>= asString
180+
181+
updateIdpWithZHost owner (Just ernieZHost) idpId3 idpmeta3
182+
`bindResponse` \resp -> do
183+
resp.status `shouldMatchInt` 409
184+
resp.jsonBody %. "label" `shouldMatch` "idp-duplicate-domain-for-team"
185+
186+
-- Create an IdP with no domain and update it to a domain that already has one -> failure
187+
SAML.SampleIdP idpmeta4 _ _ _ <- SAML.makeSampleIdPMetadata
188+
idpId4 <-
189+
createIdpWithZHost owner Nothing idpmeta4 `bindResponse` \resp -> do
190+
resp.status `shouldMatchInt` 201
191+
resp.jsonBody %. "id" >>= asString
171192

172-
-- The edIssuer needs to stay unchanged. Otherwise, deletion will fail
173-
-- with a 404 (see bug https://wearezeta.atlassian.net/browse/WPB-20407)
174-
updateIdpWithZHost owner (Just ernieZHost) idpId1 (idpmeta2 & SAML.edIssuer .~ (idpmeta1 ^. SAML.edIssuer))
193+
updateIdpWithZHost owner (Just ernieZHost) idpId4 idpmeta4
194+
`bindResponse` \resp -> do
195+
resp.status `shouldMatchInt` 409
196+
resp.jsonBody %. "label" `shouldMatch` "idp-duplicate-domain-for-team"
197+
198+
-- Updating an IdP itself should still work
199+
updateIdpWithZHost
200+
owner
201+
(Just ernieZHost)
202+
idpId1
203+
-- The edIssuer needs to stay unchanged. Otherwise, deletion will fail
204+
-- with a 404 (see bug https://wearezeta.atlassian.net/browse/WPB-20407)
205+
(idpmeta2 & SAML.edIssuer .~ (idpmeta1 ^. SAML.edIssuer))
175206
`bindResponse` \resp -> do
176207
resp.status `shouldMatchInt` 200
177208
resp.jsonBody %. "extraInfo.domain" `shouldMatch` ernieZHost
178209

210+
-- After deletion of the IdP of a domain, a new one can be created
179211
deleteIdp owner idpId1 `bindResponse` \resp -> do
180212
resp.status `shouldMatchInt` 204
181213

182-
SAML.SampleIdP idpmeta3 _ _ _ <- SAML.makeSampleIdPMetadata
183-
idpId3 <-
184-
createIdpWithZHost owner (Just ernieZHost) idpmeta3 `bindResponse` \resp -> do
214+
SAML.SampleIdP idpmeta5 _ _ _ <- SAML.makeSampleIdPMetadata
215+
idpId5 <-
216+
createIdpWithZHost owner (Just ernieZHost) idpmeta5 `bindResponse` \resp -> do
185217
resp.status `shouldMatchInt` 201
186218
resp.jsonBody %. "extraInfo.domain" `shouldMatch` ernieZHost
187219
resp.jsonBody %. "id" >>= asString
188220

189-
SAML.SampleIdP idpmeta4 _ _ _ <- SAML.makeSampleIdPMetadata
190-
void $ createIdpWithZHost owner (Just ernieZHost) idpmeta3 `bindResponse` \resp -> do
221+
-- After deletion of the IdP of a domain, one can be moved from another domain
222+
SAML.SampleIdP idpmeta6 _ _ _ <- SAML.makeSampleIdPMetadata
223+
createIdpWithZHost owner (Just bertZHost) idpmeta6 `bindResponse` \resp -> do
191224
resp.status `shouldMatchInt` 409
192225
resp.jsonBody %. "label" `shouldMatch` "idp-duplicate-domain-for-team"
193226

194-
updateIdpWithZHost owner (Just ernieZHost) idpId3 idpmeta4 `bindResponse` \resp -> do
195-
resp.status `shouldMatchInt` 200
196-
resp.jsonBody %. "extraInfo.domain" `shouldMatch` ernieZHost
227+
deleteIdp owner idpId3 `bindResponse` \resp -> do
228+
resp.status `shouldMatchInt` 204
229+
230+
idpId6 <-
231+
createIdpWithZHost owner (Just bertZHost) idpmeta6 `bindResponse` \resp -> do
232+
resp.status `shouldMatchInt` 201
233+
resp.jsonBody %. "extraInfo.domain" `shouldMatch` bertZHost
234+
resp.jsonBody %. "id" >>= asString
235+
236+
updateIdpWithZHost owner (Just ernieZHost) idpId6 idpmeta6 `bindResponse` \resp -> do
237+
resp.status `shouldMatchInt` 409
238+
resp.jsonBody %. "label" `shouldMatch` "idp-duplicate-domain-for-team"
239+
240+
deleteIdp owner idpId5 `bindResponse` \resp -> do
241+
resp.status `shouldMatchInt` 204
242+
243+
updateIdpWithZHost owner (Just ernieZHost) idpId6 idpmeta6
244+
`bindResponse` \resp -> do
245+
resp.status `shouldMatchInt` 200
246+
resp.jsonBody %. "extraInfo.domain" `shouldMatch` ernieZHost
197247

198248
-- We only record the domain for multi-ingress setups.
199249
testNonMultiIngressSetupsCanHaveMoreIdPsPerDomain :: (HasCallStack) => App ()

0 commit comments

Comments
 (0)