diff --git a/integration/test/Test/Conversation.hs b/integration/test/Test/Conversation.hs index e1855965d55..18eb6bdbd63 100644 --- a/integration/test/Test/Conversation.hs +++ b/integration/test/Test/Conversation.hs @@ -308,24 +308,38 @@ testAddUnreachableUserFromFederatingBackend :: HasCallStack => App () testAddUnreachableUserFromFederatingBackend = do resourcePool <- asks resourcePool runCodensity (acquireResources 1 resourcePool) $ \[cDom] -> do - (alice, chadId, conv) <- runCodensity (startDynamicBackend cDom mempty) $ \_ -> do + (alice, chad, chad1, qcnv) <- runCodensity (startDynamicBackend cDom mempty) $ \_ -> do ownDomain <- make OwnDomain & asString otherDomain <- make OtherDomain & asString [alice, bob, charlie, chad] <- createAndConnectUsers [ownDomain, otherDomain, cDom.berDomain, cDom.berDomain] + chad1 <- objId $ bindResponse (addClient chad def) $ getJSON 201 - conv <- withWebSockets [bob, charlie] $ \wss -> do + qcnv <- withWebSockets [bob, charlie] $ \wss -> do conv <- postConversation alice (defProteus {qualifiedUsers = [bob, charlie]}) >>= getJSON 201 forM_ wss $ awaitMatch 5 isMemberJoinNotif - pure conv - chadId <- chad %. "qualified_id" - pure (alice, chadId, conv) + let qcnv = conv %. "qualified_id" + pure qcnv + pure (alice, chad, chad1, qcnv) - bindResponse (addMembers alice conv def {users = [chadId]}) $ \resp -> do - resp.status `shouldMatchInt` 533 - resp.jsonBody %. "unreachable_backends" `shouldMatchSet` [cDom.berDomain] + chadId <- chad %. "qualified_id" + bindResponse (addMembers alice qcnv def {users = [chad]}) $ \resp -> do + resp.status `shouldMatchInt` 200 + let event = resp.jsonBody + shouldMatch (event %. "qualified_conversation") qcnv + shouldMatch (event %. "type") "conversation.member-join" + shouldMatch (event %. "from") (objId alice) + members <- event %. "data.users" & asList + memberQids <- for members (%. "qualified_id") + memberQids `shouldMatch` [chadId] + + runCodensity (startDynamicBackend cDom mempty) $ \_ -> do + n <- awaitNotification chad chad1 noValue 10 isMemberJoinNotif + members <- n %. "payload.0.data.users" & asList + memberQids <- for members (%. "qualified_id") + memberQids `shouldMatch` [chadId] testAddUnreachable :: HasCallStack => App () testAddUnreachable = do diff --git a/integration/test/Test/MLS/Unreachable.hs b/integration/test/Test/MLS/Unreachable.hs index 16f8c6acc55..f4a58af4288 100644 --- a/integration/test/Test/MLS/Unreachable.hs +++ b/integration/test/Test/MLS/Unreachable.hs @@ -78,7 +78,7 @@ testAddUnreachableUserFromFederatingBackend :: HasCallStack => App () testAddUnreachableUserFromFederatingBackend = do resourcePool <- asks resourcePool runCodensity (acquireResources 1 resourcePool) $ \[cDom] -> do - mp <- runCodensity (startDynamicBackend cDom mempty) $ \_ -> do + ((alice, chad), mp, qcnv) <- runCodensity (startDynamicBackend cDom mempty) $ \_ -> do ownDomain <- make OwnDomain & asString otherDomain <- make OtherDomain & asString [alice, bob, charlie, chad] <- @@ -86,12 +86,26 @@ testAddUnreachableUserFromFederatingBackend = do [alice1, bob1, charlie1, chad1] <- traverse (createMLSClient def) [alice, bob, charlie, chad] traverse_ uploadNewKeyPackage [bob1, charlie1, chad1] - void $ createNewGroup alice1 + qcnv <- snd <$> createNewGroup alice1 withWebSockets [bob, charlie] $ \wss -> do void $ createAddCommit alice1 [bob, charlie] >>= sendAndConsumeCommitBundle forM_ wss $ awaitMatch 5 isMemberJoinNotif - createAddCommit alice1 [chad] + mp <- createAddCommit alice1 [chad] + pure ((alice, chad), mp, qcnv) - bindResponse (postMLSCommitBundle mp.sender (mkBundle mp)) $ \resp -> do - resp.status `shouldMatchInt` 533 - resp.jsonBody %. "unreachable_backends" `shouldMatchSet` [cDom.berDomain] + resp <- sendAndConsumeCommitBundle mp + chadId <- chad %. "qualified_id" + events <- resp %. "events" & asList + do + event <- assertOne events + shouldMatch (event %. "qualified_conversation") qcnv + shouldMatch (event %. "type") "conversation.member-join" + shouldMatch (event %. "from") (objId alice) + members <- event %. "data" %. "users" & asList + memberQids <- for members $ \mem -> mem %. "qualified_id" + shouldMatch memberQids [chadId] + + runCodensity (startDynamicBackend cDom mempty) $ \_ -> + withWebSocket chad $ \ws -> do + n <- awaitMatch 10 isMemberJoinNotif ws + n %. "data.qualified_target" `shouldMatch` chadId