Skip to content

Commit

Permalink
Add end2end test for adding remote users to a conversation
Browse files Browse the repository at this point in the history
  • Loading branch information
pcapriotti committed May 27, 2021
1 parent 7984fcd commit 9ba22ae
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
39 changes: 36 additions & 3 deletions services/brig/test/integration/Federation/End2end.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import Data.ByteString.Conversion (toByteString')
import Data.Domain (Domain)
import Data.Handle
import Data.Id (ClientId)
import Data.List.NonEmpty (NonEmpty ((:|)))
import qualified Data.Map as Map
import Data.Qualified
import qualified Data.Set as Set
Expand All @@ -38,6 +39,8 @@ import Test.Tasty
import Test.Tasty.HUnit
import Util
import Util.Options (Endpoint)
import Wire.API.Conversation (InviteQualified (..), NewConv (..), NewConvUnmanaged (..), cnvId)
import Wire.API.Conversation.Role (roleNameWireAdmin)
import Wire.API.Message (UserClients (UserClients))
import Wire.API.User (ListUsersQuery (ListUsersByIds))
import Wire.API.User.Client (QualifiedUserClients (..), mkQualifiedUserClientPrekeyMap, mkUserClientPrekeyMap)
Expand All @@ -54,8 +57,8 @@ import Wire.API.User.Client (QualifiedUserClients (..), mkQualifiedUserClientPre
-- - Remote discovery succeeds but server doesn't exist
-- - Remote federator fails to respond in many ways (protocol error, timeout, etc.)
-- - SRV record has two servers but higher priority one always fails
spec :: BrigOpts.Opts -> Manager -> Brig -> Endpoint -> Brig -> IO TestTree
spec _brigOpts mg brig _federator brigTwo =
spec :: BrigOpts.Opts -> Manager -> Brig -> Galley -> Endpoint -> Brig -> IO TestTree
spec _brigOpts mg brig galley _federator brigTwo =
pure $
testGroup
"federation-end2end-user"
Expand All @@ -64,7 +67,8 @@ spec _brigOpts mg brig _federator brigTwo =
test mg "get users by ids on multiple backends" $ testGetUsersById brig brigTwo,
test mg "claim client prekey" $ testClaimPrekeySuccess brig brigTwo,
test mg "claim prekey bundle" $ testClaimPrekeyBundleSuccess brig brigTwo,
test mg "claim multi-prekey bundle" $ testClaimMultiPrekeyBundleSuccess brig brigTwo
test mg "claim multi-prekey bundle" $ testClaimMultiPrekeyBundleSuccess brig brigTwo,
test mg "add remote users to local conversation" $ testAddRemoteUsersToLocalConv brig galley brigTwo
]

-- | Path covered by this test:
Expand Down Expand Up @@ -202,3 +206,32 @@ testClaimMultiPrekeyBundleSuccess brig1 brig2 = do
!!! do
const 200 === statusCode
const (Just ucm) === responseJsonMaybe

testAddRemoteUsersToLocalConv :: Brig -> Galley -> Brig -> Http ()
testAddRemoteUsersToLocalConv brig1 galley1 brig2 = do
alice <- randomUser brig1
bob <- randomUser brig2

let conv = NewConvUnmanaged $ NewConv [] (Just "gossip") mempty Nothing Nothing Nothing Nothing roleNameWireAdmin
convId <-
cnvId . responseJsonUnsafe
<$> post
( galley1
. path "/conversations"
. zUser (userId alice)
. zConn "conn"
. header "Z-Type" "access"
. json conv
)

let invite = InviteQualified (userQualifiedId bob :| []) roleNameWireAdmin
post
( galley1
-- FUTUREWORK: use an endpoint without /i/ once it's ready.
. paths ["i", "conversations", toByteString' convId, "members", "v2"]
. zUser (userId alice)
. zConn "conn"
. header "Z-Type" "access"
. json invite
)
!!! (const 200 === statusCode)
2 changes: 1 addition & 1 deletion services/brig/test/integration/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ runTests iConf brigOpts otherArgs = do
createIndex <- Index.Create.spec brigOpts
browseTeam <- TeamUserSearch.tests brigOpts mg g b
userPendingActivation <- UserPendingActivation.tests brigOpts mg db b g s
federationEnd2End <- Federation.End2end.spec brigOpts mg b f brigTwo
federationEnd2End <- Federation.End2end.spec brigOpts mg b g f brigTwo
federationEndpoints <- API.Federation.tests mg b fedBrigClient
includeFederationTests <- (== Just "1") <$> Blank.getEnv "INTEGRATION_FEDERATION_TESTS"
internalApi <- API.Internal.tests brigOpts mg b (brig iConf) gd
Expand Down

0 comments on commit 9ba22ae

Please sign in to comment.