Skip to content

Commit

Permalink
Add notification test for remote join event
Browse files Browse the repository at this point in the history
  • Loading branch information
pcapriotti committed May 31, 2021
1 parent 4d51f97 commit e7eac8a
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions services/galley/test/integration/API/Federation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ import API.Util
import Bilge
import Bilge.Assert
import qualified Cassandra as Cql
import Control.Lens
import Control.Lens hiding ((#))
import Data.Domain
import Data.Id (Id (..), randomId)
import Data.List1
import Data.Qualified (Qualified (..))
import Data.Time.Clock
import Data.Timeout (TimeoutUnit (..), (#))
import Data.UUID.V4 (nextRandom)
import qualified Galley.Data.Queries as Cql
import Galley.Types
import Imports
import Test.Tasty
import qualified Test.Tasty.Cannon as WS
import Test.Tasty.HUnit
import TestHelpers
import TestSetup
Expand All @@ -45,7 +47,14 @@ tests s =
"federation"
[ test s "POST /federation/get-conversations : All Found" getConversationsAllFound,
test s "POST /federation/get-conversations : Conversations user is not a part of are excluded from result" getConversationsNotPartOf,
test s "POST /federation/update-conversation-memberships : Add local user" addLocalUser
test
s
"POST /federation/update-conversation-memberships : Add local user"
addLocalUser,
test
s
"POST /federation/update-conversation-memberships : Notify local user"
notifyLocalUser
]

getConversationsAllFound :: TestM ()
Expand Down Expand Up @@ -133,3 +142,32 @@ addLocalUser = do
. Cql.query Cql.selectUserRemoteConvs
$ Cql.params Cql.Quorum (Identity alice)
liftIO $ [(dom, conv)] @?= convs

notifyLocalUser :: TestM ()
notifyLocalUser = do
c <- view tsCannon
alice <- randomUser
bob <- randomId
charlie <- randomId
conv <- randomId
let bdom = Domain "bob.example.com"
cdom = Domain "charlie.example.com"
qbob = Qualified bob bdom
qconv = Qualified conv bdom
qcharlie = Qualified charlie cdom
fedGalleyClient <- view tsFedGalleyClient
now <- liftIO getCurrentTime
let cmu =
FedGalley.ConversationMemberUpdate
{ FedGalley.cmuTime = now,
FedGalley.cmuOrigUserId = qbob,
FedGalley.cmuConvId = qconv,
FedGalley.cmuAlreadyPresentUsers = [alice],
FedGalley.cmuUsersAdd = [(qcharlie, roleNameWireMember)],
FedGalley.cmuUsersRemove = []
}
WS.bracketR c alice $ \ws -> do
FedGalley.updateConversationMemberships fedGalleyClient cmu
void . liftIO $
WS.assertMatch (5 # Second) ws $
wsAssertMemberJoinWithRole conv bob [charlie] roleNameWireMember

0 comments on commit e7eac8a

Please sign in to comment.