-
Notifications
You must be signed in to change notification settings - Fork 332
[WPB-5103] Add users to MLS conversation when some backends are unreachable #3673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mdimjasevic
merged 4 commits into
develop
from
wpb-5103/add-to-mls-conv-unreachable-backends
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
changelog.d/6-federation/wpb-5103-add-to-mls-conv-unreachable-backends
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Define a few tests for adding members to an MLS conversation when unreachable backends are involved |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| -- This file is part of the Wire Server implementation. | ||
| -- | ||
| -- Copyright (C) 2023 Wire Swiss GmbH <opensource@wire.com> | ||
| -- | ||
| -- This program is free software: you can redistribute it and/or modify it under | ||
| -- the terms of the GNU Affero General Public License as published by the Free | ||
| -- Software Foundation, either version 3 of the License, or (at your option) any | ||
| -- later version. | ||
| -- | ||
| -- This program is distributed in the hope that it will be useful, but WITHOUT | ||
| -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| -- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
| -- details. | ||
| -- | ||
| -- You should have received a copy of the GNU Affero General Public License along | ||
| -- with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| module Test.MLS.Unreachable where | ||
|
|
||
| import API.Galley | ||
| import Control.Monad.Codensity | ||
| import Control.Monad.Reader | ||
| import MLS.Util | ||
| import Notifications | ||
| import SetupHelpers | ||
| import Testlib.Prelude | ||
| import Testlib.ResourcePool | ||
|
|
||
| testAddUsersSomeReachable :: HasCallStack => App () | ||
| testAddUsersSomeReachable = do | ||
| (addCommit, d) <- startDynamicBackends [mempty] $ \[thirdDomain] -> do | ||
| ownDomain <- make OwnDomain & asString | ||
| otherDomain <- make OtherDomain & asString | ||
| [alice, bob, charlie] <- createAndConnectUsers [ownDomain, otherDomain, thirdDomain] | ||
|
|
||
| [alice1, bob1, charlie1] <- traverse (createMLSClient def) [alice, bob, charlie] | ||
| traverse_ uploadNewKeyPackage [bob1, charlie1] | ||
| void $ createNewGroup alice1 | ||
| void $ withWebSocket bob $ \ws -> do | ||
| void $ createAddCommit alice1 [bob] >>= sendAndConsumeCommitBundle | ||
| awaitMatch 10 isMemberJoinNotif ws | ||
| mp <- createAddCommit alice1 [charlie] | ||
| pure (mp, thirdDomain) | ||
|
|
||
| -- try adding Charlie now that his backend is unreachable | ||
| bindResponse (postMLSCommitBundle addCommit.sender (mkBundle addCommit)) $ \resp -> do | ||
| resp.status `shouldMatchInt` 533 | ||
| (resp.json %. "unreachable_backends" & asList) `shouldMatch` [d] | ||
|
|
||
| -- There is analogous counterpart for Proteus in the 'Test.Conversation' module. | ||
| testAddReachableWithUnreachableRemoteUsers :: HasCallStack => App () | ||
| testAddReachableWithUnreachableRemoteUsers = do | ||
| resourcePool <- asks resourcePool | ||
| runCodensity (acquireResources 1 resourcePool) $ \[cDom] -> do | ||
| (alice1, bob) <- runCodensity (startDynamicBackend cDom mempty) $ \_ -> do | ||
| ownDomain <- make OwnDomain & asString | ||
| [alice, charlie] <- createAndConnectUsers [ownDomain, cDom.berDomain] | ||
|
|
||
| [alice1, charlie1] <- traverse (createMLSClient def) [alice, charlie] | ||
| void $ uploadNewKeyPackage charlie1 | ||
| void $ createNewGroup alice1 | ||
| void $ withWebSocket charlie $ \ws -> do | ||
| void $ createAddCommit alice1 [charlie] >>= sendAndConsumeCommitBundle | ||
| awaitMatch 10 isMemberJoinNotif ws | ||
| otherDomain <- make OtherDomain & asString | ||
| bob <- randomUser otherDomain def | ||
| forM_ [alice, charlie] $ connectTwoUsers bob | ||
| pure (alice1, bob) | ||
|
|
||
| bob1 <- createMLSClient def bob | ||
| void $ uploadNewKeyPackage bob1 | ||
| mp <- createAddCommit alice1 [bob] | ||
| bindResponse (postMLSCommitBundle mp.sender (mkBundle mp)) $ \resp -> do | ||
| resp.status `shouldMatchInt` 533 | ||
| resp.jsonBody %. "unreachable_backends" `shouldMatchSet` [cDom.berDomain] | ||
|
|
||
| testAddUnreachableUserFromFederatingBackend :: HasCallStack => App () | ||
| testAddUnreachableUserFromFederatingBackend = do | ||
| resourcePool <- asks resourcePool | ||
| runCodensity (acquireResources 1 resourcePool) $ \[cDom] -> do | ||
| mp <- runCodensity (startDynamicBackend cDom mempty) $ \_ -> do | ||
| ownDomain <- make OwnDomain & asString | ||
| otherDomain <- make OtherDomain & asString | ||
| [alice, bob, charlie, chad] <- | ||
| createAndConnectUsers [ownDomain, otherDomain, cDom.berDomain, cDom.berDomain] | ||
|
|
||
| [alice1, bob1, charlie1, chad1] <- traverse (createMLSClient def) [alice, bob, charlie, chad] | ||
| traverse_ uploadNewKeyPackage [bob1, charlie1, chad1] | ||
| void $ createNewGroup alice1 | ||
| withWebSockets [bob, charlie] $ \wss -> do | ||
| void $ createAddCommit alice1 [bob, charlie] >>= sendAndConsumeCommitBundle | ||
| forM_ wss $ awaitMatch 5 isMemberJoinNotif | ||
| createAddCommit alice1 [chad] | ||
|
|
||
| bindResponse (postMLSCommitBundle mp.sender (mkBundle mp)) $ \resp -> do | ||
| resp.status `shouldMatchInt` 533 | ||
| resp.jsonBody %. "unreachable_backends" `shouldMatchSet` [cDom.berDomain] | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not
shouldMatchSetas below?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For no particular reason.
I believe this way it is fine because it's only one list element so there's no concern about what element comes where.