Skip to content

Commit

Permalink
Fix integration test.
Browse files Browse the repository at this point in the history
  • Loading branch information
fisx committed Aug 7, 2019
1 parent dc12ddb commit 875d833
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 1 addition & 3 deletions services/spar/test-integration/Test/Spar/APISpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import Util.Types
import qualified Data.ByteString.Builder as LB
import qualified Data.ZAuth.Token as ZAuth
import qualified Galley.Types.Teams as Galley
import qualified Galley.Types.Teams.SSO as Galley
import qualified Spar.Intra.Brig as Intra
import qualified Util.Scim as ScimT
import qualified Web.Cookie as Cky
Expand Down Expand Up @@ -608,8 +607,7 @@ specCRUDIdentityProvider = do
context "sso disabled for team" $ do
it "responds with 403 forbidden" $ do
env <- ask
(uid, tid) <- call $ createUserWithTeam (env ^. teBrig) (env ^. teGalley)
call $ putSSOEnabledInternal (env ^. teGalley) tid Galley.SSODisabled
(uid, _tid) <- call $ createUserWithTeamDisableSSO (env ^. teBrig) (env ^. teGalley)
(callIdpCreate' (env ^. teSpar) (Just uid) =<< makeTestIdPMetadata)
`shouldRespondWith` checkErr (== 403) "sso-disabled"

Expand Down
8 changes: 7 additions & 1 deletion services/spar/test-integration/Util/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module Util.Core
-- * Other
, defPassword
, createUserWithTeam
, createUserWithTeamDisableSSO
, getSSOEnabledInternal
, putSSOEnabledInternal
, createTeamMember
Expand Down Expand Up @@ -227,6 +228,12 @@ aFewTimes action good = do

createUserWithTeam :: (HasCallStack, MonadHttp m, MonadIO m) => BrigReq -> GalleyReq -> m (UserId, TeamId)
createUserWithTeam brg gly = do
(uid, tid) <- createUserWithTeamDisableSSO brg gly
putSSOEnabledInternal gly tid Galley.SSOEnabled
pure (uid, tid)

createUserWithTeamDisableSSO :: (HasCallStack, MonadHttp m, MonadIO m) => BrigReq -> GalleyReq -> m (UserId, TeamId)
createUserWithTeamDisableSSO brg gly = do
e <- randomEmail
n <- UUID.toString <$> liftIO UUID.nextRandom
let p = RequestBodyLBS . Aeson.encode $ object
Expand All @@ -243,7 +250,6 @@ createUserWithTeam brg gly = do
selfTeam <- Brig.userTeam . Brig.selfUser <$> getSelfProfile brg uid
() <- Control.Exception.assert {- "Team ID in self profile and team table do not match" -} (selfTeam == Just tid)
$ pure ()
putSSOEnabledInternal gly tid Galley.SSOEnabled
return (uid, tid)

getSSOEnabledInternal :: (HasCallStack, MonadHttp m, MonadIO m) => GalleyReq -> TeamId -> m ResponseLBS
Expand Down

0 comments on commit 875d833

Please sign in to comment.