@@ -164,36 +164,86 @@ testMultiIngressAtMostOneIdPPerDomain = do
164
164
resp. status `shouldMatchInt` 201
165
165
resp. jsonBody %. " id" >>= asString
166
166
167
+ -- Creating a second IdP for the same domain -> failure
167
168
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
171
192
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))
175
206
`bindResponse` \ resp -> do
176
207
resp. status `shouldMatchInt` 200
177
208
resp. jsonBody %. " extraInfo.domain" `shouldMatch` ernieZHost
178
209
210
+ -- After deletion of the IdP of a domain, a new one can be created
179
211
deleteIdp owner idpId1 `bindResponse` \ resp -> do
180
212
resp. status `shouldMatchInt` 204
181
213
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
185
217
resp. status `shouldMatchInt` 201
186
218
resp. jsonBody %. " extraInfo.domain" `shouldMatch` ernieZHost
187
219
resp. jsonBody %. " id" >>= asString
188
220
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
191
224
resp. status `shouldMatchInt` 409
192
225
resp. jsonBody %. " label" `shouldMatch` " idp-duplicate-domain-for-team"
193
226
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
197
247
198
248
-- We only record the domain for multi-ingress setups.
199
249
testNonMultiIngressSetupsCanHaveMoreIdPsPerDomain :: (HasCallStack ) => App ()
0 commit comments