Skip to content

Commit

Permalink
Test: A provider creation helper
Browse files Browse the repository at this point in the history
  • Loading branch information
mdimjasevic committed Dec 20, 2023
1 parent 2d7fe9a commit d9848e7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
25 changes: 25 additions & 0 deletions integration/test/SetupHelpers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,28 @@ getOne2OneConversation user1 user2 cnvState = do
qIds <- for others (%. "qualified_id")
pure $ qIds == users && t
head <$> filterM (isWith [user2]) l

-- | Create a provider, get an activation code, activate the provider and log it
-- in. The return value is the created provider.
setupProvider ::
( HasCallStack,
MakesValue user
) =>
user ->
NewProvider ->
App Value
setupProvider u np@(NewProvider {..}) = do
dom <- objDomain u
provider <- newProvider u np
pass <- provider %. "password" & asString
(key, code) <- do
pair <-
getProviderActivationCodeInternal dom newProviderEmail `bindResponse` \resp -> do
resp.status `shouldMatchInt` 200
resp.json
k <- pair %. "key" & asString
c <- pair %. "code" & asString
pure (k, c)
activateProvider dom key code
void $ loginProvider dom newProviderEmail pass
pure provider
14 changes: 1 addition & 13 deletions integration/test/Test/Services.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
module Test.Services where

import API.Brig
import API.BrigInternal
import API.Common
import SetupHelpers
import Testlib.Prelude
Expand All @@ -28,19 +27,8 @@ testUpdateServiceUpdateAcceptHeader = do
let dom = OwnDomain
email <- randomEmail
alice <- randomUser dom def
provider <- newProvider alice def {newProviderEmail = email}
provider <- setupProvider alice def {newProviderEmail = email}
providerId <- provider %. "id" & asString
pass <- provider %. "password" & asString
(key, code) <- do
pair <-
getProviderActivationCodeInternal dom email `bindResponse` \resp -> do
resp.status `shouldMatchInt` 200
resp.json
k <- pair %. "key" & asString
c <- pair %. "code" & asString
pure (k, c)
activateProvider dom key code
void $ loginProvider dom email pass
service <- newService dom providerId def
serviceId <- service %. "id"
void $
Expand Down

0 comments on commit d9848e7

Please sign in to comment.