@@ -16,6 +16,7 @@ import qualified Data.Aeson.Types as A
1616import qualified Data.CaseInsensitive as CI
1717import Data.String.Conversions (cs )
1818import qualified Data.Text as ST
19+ import Debug.Trace
1920import qualified SAML2.WebSSO as SAML
2021import qualified SAML2.WebSSO.Test.MockResponse as SAML
2122import qualified SAML2.WebSSO.Test.Util as SAML
@@ -367,17 +368,65 @@ testSparCreateScimTokenWithName = do
367368
368369testSparScimCreateUserGroup :: (HasCallStack ) => App ()
369370testSparScimCreateUserGroup = do
370- (owner, _ , _) <- createTeam OwnDomain 1
371+ (owner, tid , _) <- createTeam OwnDomain 1
371372 tok <- createScimTokenV6 owner def >>= \ resp -> resp. json %. " token" >>= asString
373+
374+ -- f0, f1, ... are stolen from other tests in this module, but they don't wokr quite yet.
375+
376+ {-
377+ let _f0 :: App String
378+ _f0 = do
379+ void $ setTeamFeatureStatus owner tid "sso" "enabled"
380+ void $ registerTestIdPWithMeta owner >>= getJSON 201
381+ email <- randomEmail
382+ extId <- randomExternalId
383+ scimUser <- randomScimUserWithEmail extId email
384+ scimUserId <- createScimUser OwnDomain tok scimUser >>= getJSON 201 >>= (%. "id") >>= asString
385+ bindResponse (getUsersId OwnDomain [scimUserId]) $ \res -> do
386+ res.status `shouldMatchInt` 200
387+ asString (res.json %. "[0].id") `shouldMatch` [scimUserId]
388+ pure scimUserId
389+
390+ -}
391+
392+ let f1 :: App String
393+ f1 = do
394+ assertSuccess =<< setTeamFeatureStatus owner tid " validateSAMLemails" " disabled"
395+ assertSuccess =<< setTeamFeatureStatus owner tid " sso" " enabled"
396+ void $ registerTestIdPWithMetaWithPrivateCreds owner
397+
398+ scimUser <-
399+ randomScimUserWith
400+ def
401+ { mkExternalId = randomEmail,
402+ prependExternalIdToEmails = False ,
403+ mkOtherEmails = pure []
404+ }
405+ uid <- createScimUser owner tok scimUser >>= getJSON 201 >>= (%. " id" ) >>= asString
406+
407+ getScimUser OwnDomain tok uid `bindResponse` \ res -> do
408+ res. status `shouldMatchInt` 200
409+ res. json %. " id" `shouldMatch` uid
410+ traceM (show owner)
411+ traceM (show tid)
412+ traceM . show =<< res. json -- if this looks right (team,
413+ -- id), then maybe there is another bug in scim group
414+ -- creation, not the test?
415+ pure uid
416+
417+ scimUserId :: String <- f1
372418 let scimUserGroup =
373419 object
374420 [ " schemas" .= [" urn:ietf:params:scim:schemas:core:2.0:Group" ],
375421 " displayName" .= " ze groop" ,
376422 " members"
377423 .= [ object
378424 [ " type" .= " User" ,
379- " $ref" .= " https://example.org/v2/scim/User/ea2e4bf0-aa5e-11f0-96ad-e776a606779b" , -- TODO: or something imilar. we should probably validate these? or just ignore them?
380- " value" .= " ea2e4bf0-aa5e-11f0-96ad-e776a606779b"
425+ " $ref" .= " ..." , -- something like
426+ -- "https://example.org/v2/scim/User/ea2e4bf0-aa5e-11f0-96ad-e776a606779b"?
427+ -- but since we're just receiving this it's ok
428+ -- to ignore.
429+ " value" .= scimUserId
381430 ]
382431 ]
383432 ]
0 commit comments