Skip to content

Commit

Permalink
Test temp events with explicit client lists
Browse files Browse the repository at this point in the history
  • Loading branch information
pcapriotti committed Dec 11, 2024
1 parent 444f13d commit 07f3f73
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions integration/test/Test/Events.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Control.Retry
import Data.ByteString.Conversion (toByteString')
import qualified Data.Text as Text
import Data.Timeout
import MLS.Util
import Network.AMQP.Extended
import Network.RabbitMqAdmin
import qualified Network.WebSockets as WS
Expand Down Expand Up @@ -89,6 +90,45 @@ testConsumeTempEvents = do

assertNoEvent_ ws

testMLSTempEvents :: (HasCallStack) => App ()
testMLSTempEvents = do
[alice, bob] <- createAndConnectUsers [OwnDomain, OwnDomain]
clients@[alice1, _, _] <-
traverse
( createMLSClient
def
def
{ clientArgs =
def
{ acapabilities = Just ["consumable-notifications"]
}
}
)
[alice, bob, bob]

traverse_ (uploadNewKeyPackage def) clients
convId <- createNewGroup def alice1

runCodensity (createEventsWebSocket bob Nothing) $ \ws -> do
commit <- createAddCommit alice1 convId [bob]
void $ postMLSCommitBundle commit.sender (mkBundle commit) >>= getJSON 201

-- FUTUREWORK: we should not rely on events arriving in this particular order

void $ assertEvent ws $ \e -> do
e %. "type" `shouldMatch` "event"
e %. "data.event.payload.0.type" `shouldMatch` "conversation.member-join"
user <- assertOne =<< (e %. "data.event.payload.0.data.users" & asList)
user %. "qualified_id" `shouldMatch` (bob %. "qualified_id")
ackEvent ws e

void $ assertEvent ws $ \e -> do
e %. "type" `shouldMatch` "event"
e %. "data.event.payload.0.type" `shouldMatch` "conversation.mls-welcome"
ackEvent ws e

assertNoEvent_ ws

testConsumeEventsForDifferentUsers :: (HasCallStack) => App ()
testConsumeEventsForDifferentUsers = do
alice <- randomUser OwnDomain def
Expand Down

0 comments on commit 07f3f73

Please sign in to comment.