Skip to content

Commit 9a1c4c4

Browse files
committed
WIP
1 parent 3b24d85 commit 9a1c4c4

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

services/galley/test/integration/API/MLS.hs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ tests s =
113113
test s "admin removes user from a conversation" testAdminRemovesUserFromConv,
114114
test s "admin removes user from a conversation but doesn't list all clients" testRemoveClientsIncomplete
115115
],
116+
testGroup
117+
"External commit"
118+
[ test s "attempt to join a conversation a user is not part of" testExternalCommitOtherConversation,
119+
test s "join a conversation with the same client" testExternalCommitSameClient,
120+
test s "join a conversation with a new client" (pure ())
121+
],
116122
testGroup
117123
"Application Message"
118124
[ testGroup
@@ -983,6 +989,24 @@ testLocalToRemoteNonMember = do
983989
const (Just "no-conversation-member")
984990
=== fmap Wai.label . responseJsonError
985991

992+
testExternalCommitOtherConversation :: TestM ()
993+
testExternalCommitOtherConversation = pure ()
994+
995+
testExternalCommitSameClient :: TestM ()
996+
testExternalCommitSameClient = do
997+
[alice, bob] <- createAndConnectUsers (replicate 2 Nothing)
998+
999+
runMLSTest $ do
1000+
[alice1, bob1] <- traverse createMLSClient [alice, bob]
1001+
void $ uploadNewKeyPackage bob1
1002+
(_, qcnv) <- setupMLSGroup alice1
1003+
void $ createAddCommit alice1 [bob] >>= sendAndConsumeCommit
1004+
1005+
_events <- createExternalCommit alice1 qcnv >>= sendAndConsumeCommitBundle
1006+
pure ()
1007+
1008+
-- the list of members should be [alice1, bob1]
1009+
9861010
testAppMessage :: TestM ()
9871011
testAppMessage = do
9881012
users@(alice : _) <- createAndConnectUsers (replicate 4 Nothing)

services/galley/test/integration/API/MLS/Util.hs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import qualified Data.ByteArray as BA
3535
import qualified Data.ByteString as BS
3636
import qualified Data.ByteString.Base64.URL as B64U
3737
import Data.ByteString.Conversion
38+
import qualified Data.ByteString.Lazy as LBS
3839
import Data.Domain
3940
import Data.Hex
4041
import Data.Id
@@ -510,6 +511,46 @@ createAddCommit cid users = do
510511
kps <- concat <$> traverse (bundleKeyPackages <=< claimKeyPackages cid) users
511512
createAddCommitWithKeyPackages cid kps
512513

514+
createExternalCommit ::
515+
HasCallStack =>
516+
ClientIdentity ->
517+
Qualified ConvId ->
518+
MLSTest MessagePackage
519+
createExternalCommit qcid qcnv = do
520+
bd <- State.gets mlsBaseDir
521+
gNew <- nextGroupFile qcid
522+
-- welcomeFile <- liftIO $ emptyTempFile bd "welcome"
523+
pgsFile <- liftIO $ emptyTempFile bd "pgs"
524+
pgs <-
525+
LBS.toStrict . fromJust . responseBody
526+
<$> getGroupInfo (ciUser qcid) qcnv
527+
commit <-
528+
mlscli
529+
qcid
530+
[ "external-commit",
531+
"--group-state-in",
532+
"-",
533+
"--group-state-out",
534+
pgsFile,
535+
"--group-out",
536+
gNew
537+
]
538+
(Just pgs)
539+
540+
State.modify $ \mls ->
541+
mls
542+
{ mlsNewMembers = Set.singleton qcid
543+
}
544+
545+
newPgs <- liftIO $ BS.readFile pgsFile
546+
pure $
547+
MessagePackage
548+
{ mpSender = qcid,
549+
mpMessage = commit,
550+
mpWelcome = Nothing,
551+
mpPublicGroupState = Just newPgs
552+
}
553+
513554
createAddProposals :: HasCallStack => ClientIdentity -> [Qualified UserId] -> MLSTest [MessagePackage]
514555
createAddProposals cid users = do
515556
kps <- concat <$> traverse (bundleKeyPackages <=< claimKeyPackages cid) users

0 commit comments

Comments
 (0)