Skip to content

Commit

Permalink
Test: happy case of deleting and getting
Browse files Browse the repository at this point in the history
  • Loading branch information
mdimjasevic committed Jan 6, 2023
1 parent 0b376a3 commit 905bb3d
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
39 changes: 38 additions & 1 deletion services/galley/test/integration/API/MLS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import Wire.API.Federation.API.Common
import Wire.API.Federation.API.Galley
import Wire.API.MLS.CipherSuite
import Wire.API.MLS.Credential
import Wire.API.MLS.Epoch
import Wire.API.MLS.Keys
import Wire.API.MLS.Serialisation
import Wire.API.MLS.SubConversation
Expand Down Expand Up @@ -217,7 +218,8 @@ tests s =
test s "join subconversation with a client that is not in the main conv" testJoinSubNonMemberClient,
test s "add another client to a subconversation" testAddClientSubConv,
test s "remove another client from a subconversation" testRemoveClientSubConv,
test s "send an application message in a subconversation" testSendMessageSubConv
test s "send an application message in a subconversation" testSendMessageSubConv,
test s "reset a subconversation" testDeleteSubConv
],
testGroup
"Local Sender/Remote Subconversation"
Expand Down Expand Up @@ -2508,3 +2510,38 @@ testRemoteMemberGetSubConv isAMember = do
expectSubConvError :: GalleyError -> GetSubConversationsResponse -> TestM ()
expectSubConvError _errExpected (GetSubConversationsResponseSuccess _) = liftIO $ assertFailure "Unexpected GetSubConversationsResponseSuccess"
expectSubConvError errExpected (GetSubConversationsResponseError err) = liftIO $ err @?= errExpected

testDeleteSubConv :: TestM ()
testDeleteSubConv = do
alice <- randomQualifiedUser
let sconv = SubConvId "conference"
(qcnv, sub) <- runMLSTest $ do
alice1 <- createMLSClient alice
(_, qcnv) <- setupMLSGroup alice1
sub <-
liftTest $
responseJsonError
=<< getSubConv (qUnqualified alice) qcnv sconv
<!! do const 200 === statusCode

resetGroup alice1 (pscGroupId sub)

void $
createPendingProposalCommit alice1 >>= sendAndConsumeCommitBundle
pure (qcnv, sub)

let epoch = addToEpoch @Word64 1 $ pscEpoch sub
dsc =
DeleteSubConversation
(pscGroupId sub)
epoch
deleteSubConv (qUnqualified alice) qcnv sconv dsc
!!! do const 200 === statusCode

newSub <-
responseJsonError
=<< getSubConv (qUnqualified alice) qcnv sconv
<!! do const 200 === statusCode

liftIO $
assertBool "Old and new subconversation are equal" (sub /= newSub)
21 changes: 21 additions & 0 deletions services/galley/test/integration/API/MLS/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,27 @@ getSubConv u qcnv sconv = do
]
. zUser u

deleteSubConv ::
UserId ->
Qualified ConvId ->
SubConvId ->
DeleteSubConversation ->
TestM ResponseLBS
deleteSubConv u qcnv sconv dsc = do
g <- viewGalley
delete $
g
. paths
[ "conversations",
toByteString' (qDomain qcnv),
toByteString' (qUnqualified qcnv),
"subconversations",
LBS.toStrict (toLazyByteString (toEncodedUrlPiece sconv))
]
. zUser u
. contentJson
. json dsc

convsub :: Qualified ConvId -> Maybe Text -> Qualified ConvOrSubConvId
convsub qcnv Nothing = Conv <$> qcnv
convsub qcnv (Just subname) = flip SubConv (SubConvId subname) <$> qcnv

0 comments on commit 905bb3d

Please sign in to comment.