Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add spar integration test about empty scim search results. #4132

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions services/spar/test-integration/Test/Spar/Scim/UserSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1152,11 +1152,13 @@ specListUsers = describe "GET /Users" $ do
it "lists all SCIM users in a team" $ testListProvisionedUsers
context "1 SAML IdP" $ do
it "finds a SCIM-provisioned user by userName or externalId" $ testFindProvisionedUser
it "returns an empty list of SCIM-provisioned users if user not found (userName, externalId)" $ testDoNotFindProvisionedUser True
it "finds a user autoprovisioned via saml by externalId via email" $ testFindSamlAutoProvisionedUserMigratedWithEmailInTeamWithSSO
it "finds a user invited via team settings by externalId via email" $ testFindTeamSettingsInvitedUserMigratedWithEmailInTeamWithSSO
it "finds a user invited via team settings by UserId" $ testFindTeamSettingsInvitedUserMigratedWithEmailInTeamWithSSOViaUserId
context "0 SAML IdP" $ do
it "finds a SCIM-provisioned user by userName or externalId" $ testFindProvisionedUserNoIdP
it "returns an empty list of SCIM-provisioned users if user not found (userName, externalId)" $ testDoNotFindProvisionedUser False
it "finds a non-SCIM-provisioned user by userName" $ testFindNonProvisionedUserNoIdP FindByHandle
it "finds a non-SCIM-provisioned user by externalId" $ testFindNonProvisionedUserNoIdP FindByExternalId
it "finds a non-SCIM-provisioned user by UserId" $ testFindNonProvisionedUserNoIdP GetByUserId
Expand Down Expand Up @@ -1188,6 +1190,21 @@ testFindProvisionedUser = do
users' <- listUsers tok (Just (filterBy "externalId" externalId))
liftIO $ users' `shouldBe` [storedUser]

testDoNotFindProvisionedUser :: Bool -> TestSpar ()
testDoNotFindProvisionedUser hasSaml = do
tok <-
if hasSaml
then registerIdPAndScimToken <&> fst
else do
env <- ask
(_owner, teamid) <- call $ createUserWithTeam (env ^. teBrig) (env ^. teGalley)
registerScimToken teamid Nothing
byName <- listUsers tok (Just (filterBy "userName" "6861f068-3dc7-11ef-9bc2-73f612ae094d"))
byEmail <- listUsers tok (Just (filterBy "externalId" "6861f068-3dc7-11ef-9bc2-73f612ae094d"))
liftIO $ do
byName `shouldBe` []
byEmail `shouldBe` []

-- The user is migrated by using the email as the externalId
testFindSamlAutoProvisionedUserMigratedWithEmailInTeamWithSSO :: TestSpar ()
testFindSamlAutoProvisionedUserMigratedWithEmailInTeamWithSSO = do
Expand Down
Loading