@@ -20,7 +20,7 @@ module Test.Spar.MultiIngressCrossIdpSso where
2020import API.BrigInternal (getUsersId )
2121import API.Common (randomEmail )
2222import API.GalleyInternal (setTeamFeatureStatus )
23- import API.Spar (createIdpWithZHostV2 )
23+ import API.Spar (createIdpWithZHostV2 , getSsoCodeByEmailWithZHost )
2424import Data.List.NonEmpty (NonEmpty ((:|) ))
2525import Data.Text (pack )
2626import GHC.Stack
@@ -90,6 +90,7 @@ testCrossIdpSsoCreatesDistinctUsers = do
9090 ]
9191 ]
9292 )
93+ >=> setField " enableIdPByEmailDiscovery" True
9394 }
9495 $ \ domain -> do
9596 -- Create team and enable SSO
@@ -252,6 +253,7 @@ testCrossIdpSsoEmailConflict = do
252253 ]
253254 ]
254255 )
256+ >=> setField " enableIdPByEmailDiscovery" True
255257 }
256258 $ \ domain -> do
257259 -- Create team and enable SSO
@@ -301,6 +303,12 @@ testCrossIdpSsoEmailConflict = do
301303 ssoIdTenant `shouldContain` ernieIssuer
302304 ssoIdTenant `shouldNotMatch` bertIssuer
303305
306+ -- Verify sso/get-by-email returns Ernie's IdP
307+ getSsoCodeByEmailWithZHost domain (Just ernieZHost) biboEmail `bindResponse` \ resp -> do
308+ resp. status `shouldMatchInt` 200
309+ ssoCodeStr <- resp. json %. " sso_code" >>= asString
310+ ssoCodeStr `shouldMatch` idpId1
311+
304312 -- Step 1.5: Bibo re-logs in on Ernie (should succeed - proves SSO works on same ingress)
305313 (mUserIdErnieAgain, _) <-
306314 loginWithSamlWithZHost
@@ -342,6 +350,12 @@ testCrossIdpSsoEmailConflict = do
342350 ssoIdTenant `shouldContain` bertIssuer
343351 ssoIdTenant `shouldNotMatch` ernieIssuer
344352
353+ -- Verify sso/get-by-email returns Bert's IdP after migration
354+ getSsoCodeByEmailWithZHost domain (Just bertZHost) biboEmail `bindResponse` \ resp -> do
355+ resp. status `shouldMatchInt` 200
356+ ssoCodeStr <- resp. json %. " sso_code" >>= asString
357+ ssoCodeStr `shouldMatch` idpId2
358+
345359 -- Step 3: Login on Ernie again to show back-and-forth migration works
346360 (mUserIdErnieFinal, _) <-
347361 loginWithSamlWithZHost
@@ -365,3 +379,9 @@ testCrossIdpSsoEmailConflict = do
365379 bertIssuer <- _idp2. json %. " metadata.issuer" >>= asString
366380 ssoIdTenant `shouldContain` ernieIssuer
367381 ssoIdTenant `shouldNotMatch` bertIssuer
382+
383+ -- Verify sso/get-by-email returns Ernie's IdP after migration back
384+ getSsoCodeByEmailWithZHost domain (Just ernieZHost) biboEmail `bindResponse` \ resp -> do
385+ resp. status `shouldMatchInt` 200
386+ ssoCodeStr <- resp. json %. " sso_code" >>= asString
387+ ssoCodeStr `shouldMatch` idpId1
0 commit comments