|
19 | 19 |
|
20 | 20 | module API.Federation where |
21 | 21 |
|
22 | | -import API.MLS.Util |
23 | 22 | import API.Util |
24 | 23 | import Bilge hiding (head) |
25 | 24 | import Bilge.Assert |
26 | 25 | import Control.Lens hiding ((#)) |
27 | 26 | import Data.Aeson (ToJSON (..)) |
28 | 27 | import qualified Data.Aeson as A |
29 | 28 | import Data.ByteString.Conversion (toByteString') |
30 | | -import Data.Default |
31 | 29 | import Data.Domain |
32 | 30 | import Data.Id (ConvId, Id (..), UserId, newClientId, randomId) |
33 | 31 | import Data.Json.Util hiding ((#)) |
@@ -90,9 +88,7 @@ tests s = |
90 | 88 | test s "POST /federation/on-message-sent : Receive a message from another backend" onMessageSent, |
91 | 89 | test s "POST /federation/send-message : Post a message sent from another backend" sendMessage, |
92 | 90 | test s "POST /federation/on-user-deleted-conversations : Remove deleted remote user from local conversations" onUserDeleted, |
93 | | - test s "POST /federation/update-conversation : Update local conversation by a remote admin " updateConversationByRemoteAdmin, |
94 | | - test s "POST /federation/mls-welcome : Post an MLS welcome message received from another backend" sendMLSWelcome, |
95 | | - test s "POST /federation/mls-welcome : Post an MLS welcome message (key package ref not found)" sendMLSWelcomeKeyPackageNotFound |
| 91 | + test s "POST /federation/update-conversation : Update local conversation by a remote admin " updateConversationByRemoteAdmin |
96 | 92 | ] |
97 | 93 |
|
98 | 94 | getConversationsAllFound :: TestM () |
@@ -1134,55 +1130,6 @@ updateConversationByRemoteAdmin = do |
1134 | 1130 | let convUpdate :: ConversationUpdate = fromRight (error $ "Could not parse ConversationUpdate from " <> show (frBody rpc)) $ A.eitherDecode (frBody rpc) |
1135 | 1131 | pure (rpc, convUpdate) |
1136 | 1132 |
|
1137 | | -sendMLSWelcome :: TestM () |
1138 | | -sendMLSWelcome = do |
1139 | | - let aliceDomain = Domain "a.far-away.example.com" |
1140 | | - -- Alice is from the originating domain and Bob is local, i.e., on the receiving domain |
1141 | | - MessagingSetup {..} <- aliceInvitesBob (1, LocalUser) def {creatorOrigin = RemoteUser aliceDomain} |
1142 | | - let bob = head users |
1143 | | - |
1144 | | - fedGalleyClient <- view tsFedGalleyClient |
1145 | | - cannon <- view tsCannon |
1146 | | - |
1147 | | - WS.bracketR cannon (qUnqualified (pUserId bob)) $ \wsB -> do |
1148 | | - -- send welcome message |
1149 | | - void $ |
1150 | | - runFedClient @"mls-welcome" fedGalleyClient aliceDomain $ |
1151 | | - MLSWelcomeRequest |
1152 | | - (Base64ByteString welcome) |
1153 | | - |
1154 | | - -- check that the corresponding event is received |
1155 | | - liftIO $ do |
1156 | | - WS.assertMatch_ (5 # WS.Second) wsB $ |
1157 | | - wsAssertMLSWelcome (pUserId bob) welcome |
1158 | | - |
1159 | | -sendMLSWelcomeKeyPackageNotFound :: TestM () |
1160 | | -sendMLSWelcomeKeyPackageNotFound = do |
1161 | | - let aliceDomain = Domain "a.far-away.example.com" |
1162 | | - -- Alice is from the originating domain and Bob is local, i.e., on the receiving domain |
1163 | | - MessagingSetup {..} <- |
1164 | | - aliceInvitesBob |
1165 | | - (1, LocalUser) |
1166 | | - def |
1167 | | - { creatorOrigin = RemoteUser aliceDomain, |
1168 | | - createClients = DontCreateClients -- no key package upload will happen |
1169 | | - } |
1170 | | - let bob = head users |
1171 | | - |
1172 | | - fedGalleyClient <- view tsFedGalleyClient |
1173 | | - cannon <- view tsCannon |
1174 | | - |
1175 | | - WS.bracketR cannon (qUnqualified (pUserId bob)) $ \wsB -> do |
1176 | | - -- send welcome message |
1177 | | - void $ |
1178 | | - runFedClient @"mls-welcome" fedGalleyClient aliceDomain $ |
1179 | | - MLSWelcomeRequest |
1180 | | - (Base64ByteString welcome) |
1181 | | - |
1182 | | - liftIO $ do |
1183 | | - -- check that no event is received |
1184 | | - WS.assertNoEvent (1 # Second) [wsB] |
1185 | | - |
1186 | 1133 | getConvAction :: Sing tag -> SomeConversationAction -> Maybe (ConversationAction tag) |
1187 | 1134 | getConvAction tquery (SomeConversationAction tag action) = |
1188 | 1135 | case (tag, tquery) of |
|
0 commit comments