diff --git a/changelog.d/1-api-changes/get-mls-self-conversation b/changelog.d/1-api-changes/get-mls-self-conversation new file mode 100644 index 0000000000..27ea693dcd --- /dev/null +++ b/changelog.d/1-api-changes/get-mls-self-conversation @@ -0,0 +1 @@ +Support MLS self-conversations via a new endpoint `GET /conversations/mls-self`. This removes the `PUT` counterpart introduced in #2730 diff --git a/libs/wire-api/src/Wire/API/Error/Galley.hs b/libs/wire-api/src/Wire/API/Error/Galley.hs index 171f894b3d..c53fa996b6 100644 --- a/libs/wire-api/src/Wire/API/Error/Galley.hs +++ b/libs/wire-api/src/Wire/API/Error/Galley.hs @@ -83,6 +83,7 @@ data GalleyError | MLSClientSenderUserMismatch | MLSWelcomeMismatch | MLSMissingGroupInfo + | MLSMissingSenderClient | -- NoBindingTeamMembers | NoBindingTeam @@ -206,6 +207,8 @@ type instance MapError 'MLSWelcomeMismatch = 'StaticError 400 "mls-welcome-misma type instance MapError 'MLSMissingGroupInfo = 'StaticError 404 "mls-missing-group-info" "The conversation has no group information" +type instance MapError 'MLSMissingSenderClient = 'StaticError 403 "mls-missing-sender-client" "The client has to refresh their access token and provide their client ID" + type instance MapError 'NoBindingTeamMembers = 'StaticError 403 "non-binding-team-members" "Both users must be members of the same binding team" type instance MapError 'NoBindingTeam = 'StaticError 403 "no-binding-team" "Operation allowed only on binding teams" diff --git a/libs/wire-api/src/Wire/API/Routes/Public/Galley/Conversation.hs b/libs/wire-api/src/Wire/API/Routes/Public/Galley/Conversation.hs index 9cb3caaf7d..7e945ea4c5 100644 --- a/libs/wire-api/src/Wire/API/Routes/Public/Galley/Conversation.hs +++ b/libs/wire-api/src/Wire/API/Routes/Public/Galley/Conversation.hs @@ -43,9 +43,9 @@ type ConversationResponse = ResponseForExistedCreated Conversation type ConversationHeaders = '[DescHeader "Location" "Conversation ID" ConvId] -type ConversationVerbWithMethod (m :: StdMethod) = +type ConversationVerb = MultiVerb - m + 'POST '[JSON] '[ WithHeaders ConversationHeaders @@ -58,10 +58,6 @@ type ConversationVerbWithMethod (m :: StdMethod) = ] ConversationResponse -type ConversationVerb = ConversationVerbWithMethod 'POST - -type ConversationPutVerb = ConversationVerbWithMethod 'PUT - type CreateConversationCodeVerb = MultiVerb 'POST @@ -275,13 +271,19 @@ type ConversationAPI = :> ConversationVerb ) :<|> Named - "create-mls-self-conversation" - ( Summary "Create the user's MLS self-conversation" + "get-mls-self-conversation" + ( Summary "Get the user's MLS self-conversation" :> ZLocalUser :> "conversations" :> "mls-self" - :> ZClient - :> ConversationPutVerb + :> MultiVerb1 + 'GET + '[JSON] + ( Respond + 200 + "The MLS self-conversation" + Conversation + ) ) -- This endpoint can lead to the following events being sent: -- - ConvCreate event to members diff --git a/libs/wire-api/src/Wire/API/Routes/Public/Galley/MLS.hs b/libs/wire-api/src/Wire/API/Routes/Public/Galley/MLS.hs index 961668ec82..6b3666208e 100644 --- a/libs/wire-api/src/Wire/API/Routes/Public/Galley/MLS.hs +++ b/libs/wire-api/src/Wire/API/Routes/Public/Galley/MLS.hs @@ -62,6 +62,7 @@ type MLSMessagingAPI = :> CanThrow 'MLSUnsupportedProposal :> CanThrow 'MLSClientSenderUserMismatch :> CanThrow 'MLSGroupConversationMismatch + :> CanThrow 'MLSMissingSenderClient :> CanThrow 'MissingLegalholdConsent :> CanThrow MLSProposalFailure :> "messages" @@ -89,6 +90,7 @@ type MLSMessagingAPI = :> CanThrow 'MLSUnsupportedProposal :> CanThrow 'MLSClientSenderUserMismatch :> CanThrow 'MLSGroupConversationMismatch + :> CanThrow 'MLSMissingSenderClient :> CanThrow 'MissingLegalholdConsent :> CanThrow MLSProposalFailure :> "messages" @@ -116,6 +118,7 @@ type MLSMessagingAPI = :> CanThrow 'MLSUnsupportedProposal :> CanThrow 'MLSClientSenderUserMismatch :> CanThrow 'MLSGroupConversationMismatch + :> CanThrow 'MLSMissingSenderClient :> CanThrow 'MLSWelcomeMismatch :> CanThrow 'MissingLegalholdConsent :> CanThrow MLSProposalFailure diff --git a/services/galley/src/Galley/API/Create.hs b/services/galley/src/Galley/API/Create.hs index ed93dca566..b8233a3c70 100644 --- a/services/galley/src/Galley/API/Create.hs +++ b/services/galley/src/Galley/API/Create.hs @@ -25,7 +25,6 @@ module Galley.API.Create ( createGroupConversation, createProteusSelfConversation, - createMLSSelfConversation, createOne2OneConversation, createConnectConversation, ) @@ -214,42 +213,6 @@ createProteusSelfConversation lusr = do c <- E.createConversation lcnv nc conversationCreated lusr c -createMLSSelfConversation :: - forall r. - Members - '[ ConversationStore, - Error InternalError, - MemberStore, - P.TinyLog, - Input Env - ] - r => - Local UserId -> - ClientId -> - Sem r ConversationResponse -createMLSSelfConversation lusr clientId = do - let selfConvId = mlsSelfConvId <$> lusr - mconv <- E.getConversation (tUnqualified selfConvId) - maybe (create selfConvId) (conversationExisted lusr) mconv - where - create :: Local ConvId -> Sem r ConversationResponse - create lcnv = do - unlessM (isJust <$> getMLSRemovalKey) $ - throw (InternalErrorWithDescription "No backend removal key is configured (See 'mlsPrivateKeyPaths' in galley's config). Refusing to create MLS conversation.") - let nc = - NewConversation - { ncMetadata = - (defConversationMetadata (tUnqualified lusr)) - { cnvmType = SelfConv - }, - ncUsers = ulFromLocals [toUserRole (tUnqualified lusr)], - ncProtocol = ProtocolMLSTag - } - conv <- E.createConversation lcnv nc - -- FUTUREWORK: remove this. we are planning to remove the need for a nullKeyPackageRef - E.addMLSClients lcnv (qUntagged lusr) (Set.singleton (clientId, nullKeyPackageRef)) - conversationCreated lusr conv - createOne2OneConversation :: forall r. Members diff --git a/services/galley/src/Galley/API/MLS/Message.hs b/services/galley/src/Galley/API/MLS/Message.hs index 0cce7c3d23..6e2a04aaf2 100644 --- a/services/galley/src/Galley/API/MLS/Message.hs +++ b/services/galley/src/Galley/API/MLS/Message.hs @@ -105,7 +105,8 @@ type MLSMessageStaticErrors = ErrorS 'MLSCommitMissingReferences, ErrorS 'MLSSelfRemovalNotAllowed, ErrorS 'MLSClientSenderUserMismatch, - ErrorS 'MLSGroupConversationMismatch + ErrorS 'MLSGroupConversationMismatch, + ErrorS 'MLSMissingSenderClient ] type MLSBundleStaticErrors = @@ -125,6 +126,7 @@ postMLSMessageFromLocalUserV1 :: ErrorS 'MLSClientSenderUserMismatch, ErrorS 'MLSCommitMissingReferences, ErrorS 'MLSGroupConversationMismatch, + ErrorS 'MLSMissingSenderClient, ErrorS 'MLSProposalNotFound, ErrorS 'MLSSelfRemovalNotAllowed, ErrorS 'MLSStaleMessage, @@ -159,6 +161,7 @@ postMLSMessageFromLocalUser :: ErrorS 'MLSClientSenderUserMismatch, ErrorS 'MLSCommitMissingReferences, ErrorS 'MLSGroupConversationMismatch, + ErrorS 'MLSMissingSenderClient, ErrorS 'MLSProposalNotFound, ErrorS 'MLSSelfRemovalNotAllowed, ErrorS 'MLSStaleMessage, @@ -366,6 +369,7 @@ postMLSMessage :: ErrorS 'MLSClientSenderUserMismatch, ErrorS 'MLSCommitMissingReferences, ErrorS 'MLSGroupConversationMismatch, + ErrorS 'MLSMissingSenderClient, ErrorS 'MLSProposalNotFound, ErrorS 'MLSSelfRemovalNotAllowed, ErrorS 'MLSStaleMessage, @@ -441,7 +445,7 @@ getSenderIdentity qusr mc fmt msg = do -- one contained in the message. We throw an error if the two don't match. when (((==) <$> mc <*> mSender) == Just False) $ throwS @'MLSClientSenderUserMismatch - pure (mkClientIdentity qusr <$> mSender) + pure (mkClientIdentity qusr <$> (mc <|> mSender)) postMLSMessageToLocalConv :: ( HasProposalEffects r, @@ -452,6 +456,7 @@ postMLSMessageToLocalConv :: ErrorS 'MissingLegalholdConsent, ErrorS 'MLSClientSenderUserMismatch, ErrorS 'MLSCommitMissingReferences, + ErrorS 'MLSMissingSenderClient, ErrorS 'MLSProposalNotFound, ErrorS 'MLSSelfRemovalNotAllowed, ErrorS 'MLSStaleMessage, @@ -618,6 +623,7 @@ processCommit :: Member (ErrorS 'ConvNotFound) r, Member (ErrorS 'MLSClientSenderUserMismatch) r, Member (ErrorS 'MLSCommitMissingReferences) r, + Member (ErrorS 'MLSMissingSenderClient) r, Member (ErrorS 'MLSProposalNotFound) r, Member (ErrorS 'MLSSelfRemovalNotAllowed) r, Member (ErrorS 'MLSStaleMessage) r, @@ -752,6 +758,7 @@ processCommitWithAction :: Member (ErrorS 'ConvNotFound) r, Member (ErrorS 'MLSClientSenderUserMismatch) r, Member (ErrorS 'MLSCommitMissingReferences) r, + Member (ErrorS 'MLSMissingSenderClient) r, Member (ErrorS 'MLSProposalNotFound) r, Member (ErrorS 'MLSSelfRemovalNotAllowed) r, Member (ErrorS 'MLSStaleMessage) r, @@ -786,6 +793,7 @@ processInternalCommit :: Member (ErrorS 'ConvNotFound) r, Member (ErrorS 'MLSClientSenderUserMismatch) r, Member (ErrorS 'MLSCommitMissingReferences) r, + Member (ErrorS 'MLSMissingSenderClient) r, Member (ErrorS 'MLSProposalNotFound) r, Member (ErrorS 'MLSSelfRemovalNotAllowed) r, Member (ErrorS 'MLSStaleMessage) r, @@ -813,10 +821,28 @@ processInternalCommit qusr senderClient con lconv cm epoch groupId action sender postponedKeyPackageRefUpdate <- if epoch == Epoch 0 then do - -- this is a newly created conversation, and it should contain exactly one - -- client (the creator) - case (self, cmAssocs cm) of - (Left lm, [(qu, (creatorClient, _))]) + let cType = cnvmType . convMetadata . tUnqualified $ lconv + case (self, cType, cmAssocs cm) of + (Left _, SelfConv, []) -> do + creatorClient <- noteS @'MLSMissingSenderClient senderClient + creatorRef <- + maybe + (pure senderRef) + ( note (mlsProtocolError "Could not compute key package ref") + . kpRef' + . upLeaf + ) + $ cPath commit + addMLSClients + (convId <$> lconv) + qusr + (Set.singleton (creatorClient, creatorRef)) + (Left _, SelfConv, _) -> + throw . InternalErrorWithDescription $ + "Unexpected creator client set in a self-conversation" + -- this is a newly created conversation, and it should contain exactly one + -- client (the creator) + (Left lm, _, [(qu, (creatorClient, _))]) | qu == qUntagged (qualifyAs lconv (lmId lm)) -> do -- use update path as sender reference and if not existing fall back to sender senderRef' <- @@ -830,9 +856,9 @@ processInternalCommit qusr senderClient con lconv cm epoch groupId action sender -- register the creator client updateKeyPackageMapping lconv qusr creatorClient Nothing senderRef' -- remote clients cannot send the first commit - (Right _, _) -> throwS @'MLSStaleMessage + (Right _, _, _) -> throwS @'MLSStaleMessage -- uninitialised conversations should contain exactly one client - (_, _) -> + (_, _, _) -> throw (InternalErrorWithDescription "Unexpected creator client set") pure $ pure () -- no key package ref update necessary else case upLeaf <$> cPath commit of diff --git a/services/galley/src/Galley/API/Public/Conversation.hs b/services/galley/src/Galley/API/Public/Conversation.hs index 6bff31d00d..8e7d0ab959 100644 --- a/services/galley/src/Galley/API/Public/Conversation.hs +++ b/services/galley/src/Galley/API/Public/Conversation.hs @@ -41,7 +41,7 @@ conversationAPI = <@> mkNamedAPI @"get-conversation-by-reusable-code" (getConversationByReusableCode @Cassandra) <@> mkNamedAPI @"create-group-conversation" createGroupConversation <@> mkNamedAPI @"create-self-conversation" createProteusSelfConversation - <@> mkNamedAPI @"create-mls-self-conversation" createMLSSelfConversation + <@> mkNamedAPI @"get-mls-self-conversation" getMLSSelfConversation <@> mkNamedAPI @"create-one-to-one-conversation" createOne2OneConversation <@> mkNamedAPI @"add-members-to-conversation-unqualified" addMembersUnqualified <@> mkNamedAPI @"add-members-to-conversation-unqualified2" addMembersUnqualifiedV2 diff --git a/services/galley/src/Galley/API/Query.hs b/services/galley/src/Galley/API/Query.hs index 0e13e6d4c6..8b6b19ca72 100644 --- a/services/galley/src/Galley/API/Query.hs +++ b/services/galley/src/Galley/API/Query.hs @@ -50,6 +50,7 @@ module Galley.API.Query ensureGuestLinksEnabled, getConversationGuestLinksStatus, ensureConvAdmin, + getMLSSelfConversation, ) where @@ -66,6 +67,8 @@ import Data.Qualified import Data.Range import qualified Data.Set as Set import Galley.API.Error +import Galley.API.MLS.Keys +import Galley.API.Mapping import qualified Galley.API.Mapping as Mapping import Galley.API.Util import qualified Galley.Data.Conversation as Data @@ -77,6 +80,7 @@ import qualified Galley.Effects.ListItems as E import qualified Galley.Effects.MemberStore as E import Galley.Effects.TeamFeatureStore (FeaturePersistentConstraint) import qualified Galley.Effects.TeamFeatureStore as TeamFeatures +import Galley.Env import Galley.Options import Galley.Types.Conversations.Members import Galley.Types.Teams @@ -605,6 +609,39 @@ getConversationGuestLinksFeatureStatus mbTid = do mbLockStatus <- TeamFeatures.getFeatureLockStatus @db (Proxy @GuestLinksConfig) tid pure $ computeFeatureConfigForTeamUser mbConfigNoLock mbLockStatus defaultStatus +-- | Get an MLS self conversation. In case it does not exist, it is partially +-- created in the database. The part that is not written is the epoch number; +-- the number is inserted only upon the first commit. With this we avoid race +-- conditions where two clients concurrently try to create or update the self +-- conversation, where the only thing that can be updated is bumping the epoch +-- number. +getMLSSelfConversation :: + forall r. + Members + '[ ConversationStore, + Error InternalError, + P.TinyLog, + Input Env + ] + r => + Local UserId -> + Sem r Conversation +getMLSSelfConversation lusr = do + let selfConvId = mlsSelfConvId usr + mconv <- E.getConversation selfConvId + cnv <- maybe create pure mconv + conversationView lusr cnv + where + usr = tUnqualified lusr + create :: Sem r Data.Conversation + create = do + unlessM (isJust <$> getMLSRemovalKey) $ + throw (InternalErrorWithDescription noKeyMsg) + E.createMLSSelfConversation lusr + noKeyMsg = + "No backend removal key is configured (See 'mlsPrivateKeyPaths'" + <> "in galley's config). Refusing to create MLS conversation." + ------------------------------------------------------------------------------- -- Helpers diff --git a/services/galley/src/Galley/Cassandra/Conversation.hs b/services/galley/src/Galley/Cassandra/Conversation.hs index 81f25951d4..9c670a017c 100644 --- a/services/galley/src/Galley/Cassandra/Conversation.hs +++ b/services/galley/src/Galley/Cassandra/Conversation.hs @@ -43,6 +43,7 @@ import Galley.Data.Conversation import Galley.Data.Conversation.Types import Galley.Effects.ConversationStore (ConversationStore (..)) import Galley.Types.Conversations.Members +import Galley.Types.ToUserRole import Galley.Types.UserList import Imports import Polysemy @@ -56,6 +57,63 @@ import Wire.API.MLS.CipherSuite import Wire.API.MLS.Group import Wire.API.MLS.PublicGroupState +createMLSSelfConversation :: + Local UserId -> + Client Conversation +createMLSSelfConversation lusr = do + let cnv = mlsSelfConvId . tUnqualified $ lusr + usr = tUnqualified lusr + nc = + NewConversation + { ncMetadata = + (defConversationMetadata usr) {cnvmType = SelfConv}, + ncUsers = ulFromLocals [toUserRole usr], + ncProtocol = ProtocolMLSTag + } + meta = ncMetadata nc + gid = convToGroupId . qualifyAs lusr $ cnv + -- FUTUREWORK: Stop hard-coding the cipher suite + -- + -- 'CipherSuite 1' corresponds to + -- 'MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519'. + cs = MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519 + proto = + ProtocolMLS + ConversationMLSData + { cnvmlsGroupId = gid, + cnvmlsEpoch = Epoch 0, + cnvmlsCipherSuite = cs + } + retry x5 . batch $ do + setType BatchLogged + setConsistency LocalQuorum + addPrepQuery + Cql.insertMLSSelfConv + ( cnv, + cnvmType meta, + cnvmCreator meta, + Cql.Set (cnvmAccess meta), + Cql.Set (toList (cnvmAccessRoles meta)), + cnvmName meta, + cnvmTeam meta, + cnvmMessageTimer meta, + cnvmReceiptMode meta, + Just gid, + Just cs + ) + addPrepQuery Cql.insertGroupId (gid, cnv, tDomain lusr) + + (lmems, rmems) <- addMembers cnv (ncUsers nc) + pure + Conversation + { convId = cnv, + convLocalMembers = lmems, + convRemoteMembers = rmems, + convDeleted = False, + convMetadata = meta, + convProtocol = proto + } + createConversation :: Local ConvId -> NewConversation -> Client Conversation createConversation lcnv nc = do let meta = ncMetadata nc @@ -266,7 +324,13 @@ toProtocol :: toProtocol Nothing _ _ _ = Just ProtocolProteus toProtocol (Just ProtocolProteusTag) _ _ _ = Just ProtocolProteus toProtocol (Just ProtocolMLSTag) mgid mepoch mcs = - ProtocolMLS <$> (ConversationMLSData <$> mgid <*> mepoch <*> mcs) + ProtocolMLS + <$> ( ConversationMLSData + <$> mgid + -- If there is no epoch in the database, assume the epoch is 0 + <*> (mepoch <|> Just (Epoch 0)) + <*> mcs + ) toConv :: ConvId -> @@ -314,6 +378,7 @@ interpretConversationStoreToCassandra :: interpretConversationStoreToCassandra = interpret $ \case CreateConversationId -> Id <$> embed nextRandom CreateConversation loc nc -> embedClient $ createConversation loc nc + CreateMLSSelfConversation lusr -> embedClient $ createMLSSelfConversation lusr GetConversation cid -> embedClient $ getConversation cid GetConversationIdByGroupId gId -> embedClient $ lookupGroupId gId GetConversations cids -> localConversations cids diff --git a/services/galley/src/Galley/Cassandra/Instances.hs b/services/galley/src/Galley/Cassandra/Instances.hs index 4860fdd3e1..1c4c5aaa40 100644 --- a/services/galley/src/Galley/Cassandra/Instances.hs +++ b/services/galley/src/Galley/Cassandra/Instances.hs @@ -182,13 +182,14 @@ instance Cql Public.EnforceAppLock where instance Cql ProtocolTag where ctype = Tagged IntColumn - toCql ProtocolProteusTag = CqlInt 0 - toCql ProtocolMLSTag = CqlInt 1 - - fromCql (CqlInt i) = case i of - 0 -> pure ProtocolProteusTag - 1 -> pure ProtocolMLSTag - n -> Left $ "unexpected protocol: " ++ show n + toCql = CqlInt . fromIntegral . fromEnum + + fromCql (CqlInt i) = do + let i' = fromIntegral i + if i' < fromEnum @ProtocolTag minBound + || i' > fromEnum @ProtocolTag maxBound + then Left $ "unexpected protocol: " ++ show i + else Right $ toEnum i' fromCql _ = Left "protocol: int expected" instance Cql GroupId where diff --git a/services/galley/src/Galley/Cassandra/Queries.hs b/services/galley/src/Galley/Cassandra/Queries.hs index 9e50d5808e..4ba7f3b76f 100644 --- a/services/galley/src/Galley/Cassandra/Queries.hs +++ b/services/galley/src/Galley/Cassandra/Queries.hs @@ -25,6 +25,7 @@ import Data.Json.Util import Data.LegalHold import Data.Misc import qualified Data.Text.Lazy as LT +import Galley.Cassandra.Instances () import Galley.Data.Scope import Galley.Types.Teams.Intra import Imports @@ -209,6 +210,31 @@ isConvDeleted = "select deleted from conversation where conv = ?" insertConv :: PrepQuery W (ConvId, ConvType, UserId, C.Set Access, C.Set AccessRoleV2, Maybe Text, Maybe TeamId, Maybe Milliseconds, Maybe ReceiptMode, ProtocolTag, Maybe GroupId, Maybe Epoch, Maybe CipherSuiteTag) () insertConv = "insert into conversation (conv, type, creator, access, access_roles_v2, name, team, message_timer, receipt_mode, protocol, group_id, epoch, cipher_suite) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" +insertMLSSelfConv :: + PrepQuery + W + ( ConvId, + ConvType, + UserId, + C.Set Access, + C.Set AccessRoleV2, + Maybe Text, + Maybe TeamId, + Maybe Milliseconds, + Maybe ReceiptMode, + Maybe GroupId, + Maybe CipherSuiteTag + ) + () +insertMLSSelfConv = + fromString $ + "insert into conversation (conv, type, creator, access, \ + \ access_roles_v2, name, team, message_timer, receipt_mode,\ + \ protocol, group_id, cipher_suite) values \ + \ (?, ?, ?, ?, ?, ?, ?, ?, ?, " + <> show (fromEnum ProtocolMLSTag) + <> ", ?, ?)" + updateConvAccess :: PrepQuery W (C.Set Access, C.Set AccessRoleV2, ConvId) () updateConvAccess = "update conversation set access = ?, access_roles_v2 = ? where conv = ?" diff --git a/services/galley/src/Galley/Effects/ConversationStore.hs b/services/galley/src/Galley/Effects/ConversationStore.hs index 8a4b699a72..1660c2f689 100644 --- a/services/galley/src/Galley/Effects/ConversationStore.hs +++ b/services/galley/src/Galley/Effects/ConversationStore.hs @@ -24,6 +24,7 @@ module Galley.Effects.ConversationStore -- * Create conversation createConversationId, createConversation, + createMLSSelfConversation, -- * Read conversation getConversation, @@ -72,6 +73,9 @@ import Wire.API.MLS.PublicGroupState data ConversationStore m a where CreateConversationId :: ConversationStore m ConvId CreateConversation :: Local ConvId -> NewConversation -> ConversationStore m Conversation + CreateMLSSelfConversation :: + Local UserId -> + ConversationStore m Conversation DeleteConversation :: ConvId -> ConversationStore m () GetConversation :: ConvId -> ConversationStore m (Maybe Conversation) GetConversationIdByGroupId :: GroupId -> ConversationStore m (Maybe (Qualified ConvId)) diff --git a/services/galley/test/integration/API/MLS.hs b/services/galley/test/integration/API/MLS.hs index 19972cdd91..5de91f2a38 100644 --- a/services/galley/test/integration/API/MLS.hs +++ b/services/galley/test/integration/API/MLS.hs @@ -247,7 +247,7 @@ testSenderNotInConversation = do -- send the message as bob, who is not in the conversation err <- responseJsonError - =<< postMessage (qUnqualified bob) (mpMessage message) + =<< postMessage bob1 (mpMessage message) do err <- responseJsonError - =<< postMessage (ciUser (mpSender commit)) (mpMessage commit) + =<< postMessage (mpSender commit) (mpMessage commit) >= sendAndConsumeCommit prop <- createExternalAddProposal bob2 - postMessage (qUnqualified charlie) (mpMessage prop) + postMessage charlie1 (mpMessage prop) !!! do const 422 === statusCode const (Just "mls-unsupported-proposal") === fmap Wai.label . responseJsonError @@ -1527,7 +1527,7 @@ testExternalAddProposalWrongClient = do -- charlie attempts to join with an external add proposal testExternalAddProposalWrongUser :: TestM () testExternalAddProposalWrongUser = do - users@[_, bob, charlie] <- createAndConnectUsers (replicate 3 Nothing) + users@[_, bob, _charlie] <- createAndConnectUsers (replicate 3 Nothing) runMLSTest $ do -- setup clients @@ -1540,7 +1540,7 @@ testExternalAddProposalWrongUser = do >>= sendAndConsumeCommit prop <- createExternalAddProposal charlie1 - postMessage (qUnqualified charlie) (mpMessage prop) + postMessage charlie1 (mpMessage prop) !!! do const 404 === statusCode const (Just "no-conversation") === fmap Wai.label . responseJsonError @@ -1598,7 +1598,7 @@ propUnsupported = do -- we cannot use sendAndConsumeMessage here, because openmls does not yet -- support AppAck proposals - postMessage (ciUser alice1) msgData !!! const 201 === statusCode + postMessage alice1 msgData !!! const 201 === statusCode testBackendRemoveProposalLocalConvLocalUser :: TestM () testBackendRemoveProposalLocalConvLocalUser = do @@ -2163,7 +2163,7 @@ testSelfConversationOtherUser = do void $ setupMLSSelfGroup alice1 commit <- createAddCommit alice1 [bob] mlsBracket [alice1, bob1] $ \wss -> do - postMessage (ciUser (mpSender commit)) (mpMessage commit) + postMessage (mpSender commit) (mpMessage commit) !!! do const 403 === statusCode const (Just "invalid-op") === fmap Wai.label . responseJsonError diff --git a/services/galley/test/integration/API/MLS/Util.hs b/services/galley/test/integration/API/MLS/Util.hs index 81543f9d3f..5e2c332550 100644 --- a/services/galley/test/integration/API/MLS/Util.hs +++ b/services/galley/test/integration/API/MLS/Util.hs @@ -107,7 +107,7 @@ postMessage :: MonadHttp m, HasGalley m ) => - UserId -> + ClientIdentity -> ByteString -> m ResponseLBS postMessage sender msg = do @@ -115,7 +115,8 @@ postMessage sender msg = do post ( galley . paths ["mls", "messages"] - . zUser sender + . zUser (ciUser sender) + . zClient (ciClient sender) . zConn "conn" . content "message/mls" . bytes msg @@ -430,11 +431,8 @@ setupMLSSelfGroup creator = setupMLSGroupWithConv action creator action = responseJsonError =<< liftTest - ( putSelfConv - (ciUser creator) - (ciClient creator) - ) - GroupId -> MLSTest () createGroup cid gid = do @@ -834,7 +832,7 @@ sendAndConsumeMessage :: HasCallStack => MessagePackage -> MLSTest [Event] sendAndConsumeMessage mp = do events <- fmap mmssEvents . responseJsonError - =<< postMessage (ciUser (mpSender mp)) (mpMessage mp) + =<< postMessage (mpSender mp) (mpMessage mp) - ClientId -> TestM ResponseLBS -putSelfConv u c = do +getSelfConv u = do g <- viewGalley - put $ + get $ g . paths ["/conversations", "mls-self"] . zUser u - . zClient c . zConn "conn" . zType "access"