"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "services/galley/test/integration/API.hs" between
wire-server-2020-06-10.tar.gz and wire-server-2020-06-19.tar.gz

About: Wire (server) offers end-to-end encrypted messaging, file-sharing, video and voice calls, and guest rooms for external communication (back-end server).

API.hs  (wire-server-2020-06-10):API.hs  (wire-server-2020-06-19)
skipping to change at line 30 skipping to change at line 30
module API module API
( tests, ( tests,
) )
where where
import qualified API.CustomBackend as CustomBackend import qualified API.CustomBackend as CustomBackend
import qualified API.MessageTimer as MessageTimer import qualified API.MessageTimer as MessageTimer
import qualified API.Roles as Roles import qualified API.Roles as Roles
import API.SQS import API.SQS
import qualified API.Teams as Teams import qualified API.Teams as Teams
import qualified API.Teams.Feature as TeamFeature
import qualified API.Teams.LegalHold as Teams.LegalHold import qualified API.Teams.LegalHold as Teams.LegalHold
import API.Util import API.Util
import Bilge hiding (timeout) import Bilge hiding (timeout)
import Bilge.Assert import Bilge.Assert
import Brig.Types import Brig.Types
import qualified Control.Concurrent.Async as Async import qualified Control.Concurrent.Async as Async
import Control.Lens (view) import Control.Lens (view)
import Data.Aeson hiding (json) import Data.Aeson hiding (json)
import Data.ByteString.Conversion import Data.ByteString.Conversion
import qualified Data.Code as Code import qualified Data.Code as Code
import Data.Id import Data.Id
import Data.List1 import Data.List1
import qualified Data.List1 as List1 import qualified Data.List1 as List1
import qualified Data.Map.Strict as Map import qualified Data.Map.Strict as Map
import Data.Range import Data.Range
import qualified Data.Set as Set import qualified Data.Set as Set
import qualified Data.Text as T import qualified Data.Text as T
import qualified Data.Text.Ascii as Ascii import qualified Data.Text.Ascii as Ascii
import Galley.Types import Galley.Types hiding (InternalMember (..), Member)
import Galley.Types.Conversations.Roles import Galley.Types.Conversations.Roles
import qualified Galley.Types.Teams as Teams import qualified Galley.Types.Teams as Teams
import Gundeck.Types.Notification import Gundeck.Types.Notification
import Imports import Imports
import Network.Wai.Utilities.Error import Network.Wai.Utilities.Error
import Test.Tasty import Test.Tasty
import Test.Tasty.Cannon ((#), TimeoutUnit (..)) import Test.Tasty.Cannon ((#), TimeoutUnit (..))
import qualified Test.Tasty.Cannon as WS import qualified Test.Tasty.Cannon as WS
import Test.Tasty.HUnit import Test.Tasty.HUnit
import TestHelpers import TestHelpers
import TestSetup import TestSetup
import Wire.API.Conversation.Member (Member (..))
tests :: IO TestSetup -> TestTree tests :: IO TestSetup -> TestTree
tests s = tests s =
testGroup testGroup
"Galley integration tests" "Galley integration tests"
[ Teams.LegalHold.tests s, [ Teams.LegalHold.tests s,
mainTests, mainTests,
Teams.tests s, Teams.tests s,
MessageTimer.tests s, MessageTimer.tests s,
Roles.tests s, Roles.tests s,
CustomBackend.tests s CustomBackend.tests s,
TeamFeature.tests s
] ]
where where
mainTests = mainTests =
testGroup testGroup
"Main API" "Main API"
[ test s "status" status, [ test s "status" status,
test s "metrics" metrics, test s "metrics" metrics,
test s "create conversation" postConvOk, test s "create conversation" postConvOk,
test s "get empty conversations" getConvsOk, test s "get empty conversations" getConvsOk,
test s "get conversations by ids" getConvsOk2, test s "get conversations by ids" getConvsOk2,
skipping to change at line 874 skipping to change at line 877
postMembersOk2 = do postMembersOk2 = do
alice <- randomUser alice <- randomUser
bob <- randomUser bob <- randomUser
chuck <- randomUser chuck <- randomUser
connectUsers alice (list1 bob [chuck]) connectUsers alice (list1 bob [chuck])
connectUsers bob (singleton chuck) connectUsers bob (singleton chuck)
conv <- decodeConvId <$> postConv alice [bob, chuck] Nothing [] Nothing Nothin g conv <- decodeConvId <$> postConv alice [bob, chuck] Nothing [] Nothing Nothin g
postMembers bob (singleton chuck) conv !!! const 204 === statusCode postMembers bob (singleton chuck) conv !!! const 204 === statusCode
chuck' <- responseJsonUnsafe <$> (getSelfMember chuck conv <!! const 200 === s tatusCode) chuck' <- responseJsonUnsafe <$> (getSelfMember chuck conv <!! const 200 === s tatusCode)
liftIO $ liftIO $
assertEqual "wrong self member" (memId <$> chuck') (Just chuck) assertEqual "wrong self member" (Just (makeIdOpaque chuck)) (memId <$> chuck ')
postMembersOk3 :: TestM () postMembersOk3 :: TestM ()
postMembersOk3 = do postMembersOk3 = do
alice <- randomUser alice <- randomUser
bob <- randomUser bob <- randomUser
eve <- randomUser eve <- randomUser
connectUsers alice (list1 bob [eve]) connectUsers alice (list1 bob [eve])
conv <- decodeConvId <$> postConv alice [bob, eve] (Just "gossip") [] Nothing Nothing conv <- decodeConvId <$> postConv alice [bob, eve] (Just "gossip") [] Nothing Nothing
-- Bob leaves -- Bob leaves
deleteMember bob bob conv !!! const 200 === statusCode deleteMember bob bob conv !!! const 200 === statusCode
skipping to change at line 1014 skipping to change at line 1017
putMemberOk update = do putMemberOk update = do
c <- view tsCannon c <- view tsCannon
alice <- randomUser alice <- randomUser
bob <- randomUser bob <- randomUser
connectUsers alice (singleton bob) connectUsers alice (singleton bob)
conv <- decodeConvId <$> postO2OConv alice bob (Just "gossip") conv <- decodeConvId <$> postO2OConv alice bob (Just "gossip")
getConv alice conv !!! const 200 === statusCode getConv alice conv !!! const 200 === statusCode
-- Expected member state -- Expected member state
let memberBob = let memberBob =
Member Member
{ memId = bob, { memId = makeIdOpaque bob,
memService = Nothing, memService = Nothing,
memOtrMuted = fromMaybe False (mupOtrMute update), memOtrMuted = fromMaybe False (mupOtrMute update),
memOtrMutedStatus = mupOtrMuteStatus update, memOtrMutedStatus = mupOtrMuteStatus update,
memOtrMutedRef = mupOtrMuteRef update, memOtrMutedRef = mupOtrMuteRef update,
memOtrArchived = fromMaybe False (mupOtrArchive update), memOtrArchived = fromMaybe False (mupOtrArchive update),
memOtrArchivedRef = mupOtrArchiveRef update, memOtrArchivedRef = mupOtrArchiveRef update,
memHidden = fromMaybe False (mupHidden update), memHidden = fromMaybe False (mupHidden update),
memHiddenRef = mupHiddenRef update, memHiddenRef = mupHiddenRef update,
memConvRoleName = fromMaybe roleNameWireAdmin (mupConvRoleName updat e) memConvRoleName = fromMaybe roleNameWireAdmin (mupConvRoleName updat e)
} }
skipping to change at line 1147 skipping to change at line 1150
WS.bracketR3 c alice bob carl $ \(wsA, wsB, wsC) -> do WS.bracketR3 c alice bob carl $ \(wsA, wsB, wsC) -> do
deleteUser bob deleteUser bob
void . liftIO $ WS.assertMatchN (5 # Second) [wsA, wsB] $ void . liftIO $ WS.assertMatchN (5 # Second) [wsA, wsB] $
matchMemberLeave conv1 bob matchMemberLeave conv1 bob
void . liftIO $ WS.assertMatchN (5 # Second) [wsA, wsB, wsC] $ void . liftIO $ WS.assertMatchN (5 # Second) [wsA, wsB, wsC] $
matchMemberLeave conv2 bob matchMemberLeave conv2 bob
-- Check memberships -- Check memberships
mems1 <- fmap cnvMembers . responseJsonUnsafe <$> getConv alice conv1 mems1 <- fmap cnvMembers . responseJsonUnsafe <$> getConv alice conv1
mems2 <- fmap cnvMembers . responseJsonUnsafe <$> getConv alice conv2 mems2 <- fmap cnvMembers . responseJsonUnsafe <$> getConv alice conv2
mems3 <- fmap cnvMembers . responseJsonUnsafe <$> getConv alice conv3 mems3 <- fmap cnvMembers . responseJsonUnsafe <$> getConv alice conv3
let other u = find ((== u) . omId) . cmOthers let other u = find ((== makeIdOpaque u) . omId) . cmOthers
liftIO $ do liftIO $ do
(mems1 >>= other bob) @?= Nothing (mems1 >>= other bob) @?= Nothing
(mems2 >>= other bob) @?= Nothing (mems2 >>= other bob) @?= Nothing
(mems2 >>= other carl) @?= Just (OtherMember carl Nothing roleNameWireAdmin) (mems2 >>= other carl) @?= Just (OtherMember (makeIdOpaque carl) Nothing rol eNameWireAdmin)
(mems3 >>= other bob) @?= Nothing (mems3 >>= other bob) @?= Nothing
(mems3 >>= other carl) @?= Just (OtherMember carl Nothing roleNameWireAdmin) (mems3 >>= other carl) @?= Just (OtherMember (makeIdOpaque carl) Nothing rol eNameWireAdmin)
where where
matchMemberLeave conv u n = do matchMemberLeave conv u n = do
let e = List1.head (WS.unpackPayload n) let e = List1.head (WS.unpackPayload n)
ntfTransient n @?= False ntfTransient n @?= False
evtConv e @?= conv evtConv e @?= conv
evtType e @?= MemberLeave evtType e @?= MemberLeave
evtFrom e @?= u evtFrom e @?= u
evtData e @?= Just (EdMembersLeave (UserIdList [u])) evtData e @?= Just (EdMembersLeave (UserIdList [u]))
 End of changes. 9 change blocks. 
7 lines changed or deleted 10 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)