"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "services/galley/test/integration/API/Util.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).

Util.hs  (wire-server-2020-06-10):Util.hs  (wire-server-2020-06-19)
skipping to change at line 55 skipping to change at line 55
import Data.Range import Data.Range
import Data.Serialize (runPut) import Data.Serialize (runPut)
import qualified Data.Set as Set import qualified Data.Set as Set
import Data.String.Conversions (ST, cs) import Data.String.Conversions (ST, cs)
import qualified Data.Text.Encoding as Text import qualified Data.Text.Encoding as Text
import Data.Text.Encoding (decodeUtf8) import Data.Text.Encoding (decodeUtf8)
import qualified Data.UUID as UUID import qualified Data.UUID as UUID
import Data.UUID.V4 import Data.UUID.V4
import qualified Galley.Options as Opts import qualified Galley.Options as Opts
import qualified Galley.Run as Run import qualified Galley.Run as Run
import Galley.Types import Galley.Types hiding (InternalMember (..), Member)
import Galley.Types.Conversations.Roles hiding (DeleteConversation) import Galley.Types.Conversations.Roles hiding (DeleteConversation)
import qualified Galley.Types.Teams as Team import qualified Galley.Types.Teams as Team
import Galley.Types.Teams hiding (Event, EventType (..)) import Galley.Types.Teams hiding (Event, EventType (..))
import Galley.Types.Teams.Intra import Galley.Types.Teams.Intra
import Gundeck.Types.Notification import Gundeck.Types.Notification
( Notification (..), ( Notification (..),
NotificationId, NotificationId,
QueuedNotification, QueuedNotification,
QueuedNotificationList, QueuedNotificationList,
queuedHasMore, queuedHasMore,
skipping to change at line 80 skipping to change at line 80
) )
import Imports import Imports
import qualified Network.Wai.Test as WaiTest import qualified Network.Wai.Test as WaiTest
import qualified Test.QuickCheck as Q import qualified Test.QuickCheck as Q
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 TestSetup import TestSetup
import UnliftIO.Timeout import UnliftIO.Timeout
import Web.Cookie import Web.Cookie
import Wire.API.Conversation.Member (Member (..))
import qualified Wire.API.Event.Team as TE import qualified Wire.API.Event.Team as TE
import qualified Wire.API.Message.Proto as Proto import qualified Wire.API.Message.Proto as Proto
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- API Operations -- API Operations
symmPermissions :: [Perm] -> Permissions symmPermissions :: [Perm] -> Permissions
symmPermissions p = let s = Set.fromList p in fromJust (newPermissions s s) symmPermissions p = let s = Set.fromList p in fromJust (newPermissions s s)
createBindingTeam :: HasCallStack => TestM (UserId, TeamId) createBindingTeam :: HasCallStack => TestM (UserId, TeamId)
skipping to change at line 880 skipping to change at line 881
] ]
) )
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- Common Assertions -- Common Assertions
assertConvMemberWithRole :: HasCallStack => RoleName -> ConvId -> UserId -> Test M () assertConvMemberWithRole :: HasCallStack => RoleName -> ConvId -> UserId -> Test M ()
assertConvMemberWithRole r c u = assertConvMemberWithRole r c u =
getSelfMember u c !!! do getSelfMember u c !!! do
const 200 === statusCode const 200 === statusCode
const (Right u) === (fmap memId <$> responseJsonEither) const (Right (makeIdOpaque u)) === (fmap memId <$> responseJsonEither)
const (Right r) === (fmap memConvRoleName <$> responseJsonEither) const (Right r) === (fmap memConvRoleName <$> responseJsonEither)
assertConvMember :: HasCallStack => UserId -> ConvId -> TestM () assertConvMember :: HasCallStack => UserId -> ConvId -> TestM ()
assertConvMember u c = assertConvMember u c =
getSelfMember u c !!! do getSelfMember u c !!! do
const 200 === statusCode const 200 === statusCode
const (Right u) === (fmap memId <$> responseJsonEither) const (Right (makeIdOpaque u)) === (fmap memId <$> responseJsonEither)
assertNotConvMember :: HasCallStack => UserId -> ConvId -> TestM () assertNotConvMember :: HasCallStack => UserId -> ConvId -> TestM ()
assertNotConvMember u c = assertNotConvMember u c =
getSelfMember u c !!! do getSelfMember u c !!! do
const 200 === statusCode const 200 === statusCode
const (Right Null) === responseJsonEither const (Right Null) === responseJsonEither
assertConvEquals :: (HasCallStack, MonadIO m) => Conversation -> Conversation -> m () assertConvEquals :: (HasCallStack, MonadIO m) => Conversation -> Conversation -> m ()
assertConvEquals c1 c2 = liftIO $ do assertConvEquals c1 c2 = liftIO $ do
assertEqual "id" (cnvId c1) (cnvId c2) assertEqual "id" (cnvId c1) (cnvId c2)
skipping to change at line 943 skipping to change at line 944
cId <- fromBS $ getHeader' "Location" r cId <- fromBS $ getHeader' "Location" r
let cnv = responseJsonMaybe @Conversation r let cnv = responseJsonMaybe @Conversation r
let _self = cmSelf . cnvMembers <$> cnv let _self = cmSelf . cnvMembers <$> cnv
let others = cmOthers . cnvMembers <$> cnv let others = cmOthers . cnvMembers <$> cnv
liftIO $ do liftIO $ do
assertEqual "id" (Just cId) (cnvId <$> cnv) assertEqual "id" (Just cId) (cnvId <$> cnv)
assertEqual "name" n (cnv >>= cnvName) assertEqual "name" n (cnv >>= cnvName)
assertEqual "type" (Just t) (cnvType <$> cnv) assertEqual "type" (Just t) (cnvType <$> cnv)
assertEqual "creator" (Just c) (cnvCreator <$> cnv) assertEqual "creator" (Just c) (cnvCreator <$> cnv)
assertEqual "message_timer" (Just mt) (cnvMessageTimer <$> cnv) assertEqual "message_timer" (Just mt) (cnvMessageTimer <$> cnv)
assertEqual "self" (Just s) (memId <$> _self) assertEqual "self" (Just (makeIdOpaque s)) (memId <$> _self)
assertEqual "others" (Just $ Set.fromList us) (Set.fromList . map omId . toL assertEqual "others" (Just . Set.fromList $ makeIdOpaque <$> us) (Set.fromLi
ist <$> others) st . map omId . toList <$> others)
assertEqual "creator is always and admin" (Just roleNameWireAdmin) (memConvR oleName <$> _self) assertEqual "creator is always and admin" (Just roleNameWireAdmin) (memConvR oleName <$> _self)
assertBool "others role" (all (\x -> x == role) $ fromMaybe (error "Cannot b e null") ((map omConvRoleName . toList <$> others))) assertBool "others role" (all (\x -> x == role) $ fromMaybe (error "Cannot b e null") ((map omConvRoleName . toList <$> others)))
assertBool "otr muted not false" (Just False == (memOtrMuted <$> _self)) assertBool "otr muted not false" (Just False == (memOtrMuted <$> _self))
assertBool "otr muted ref not empty" (isNothing (memOtrMutedRef =<< _self)) assertBool "otr muted ref not empty" (isNothing (memOtrMutedRef =<< _self))
assertBool "otr archived not false" (Just False == (memOtrArchived <$> _self )) assertBool "otr archived not false" (Just False == (memOtrArchived <$> _self ))
assertBool "otr archived ref not empty" (isNothing (memOtrArchivedRef =<< _s elf)) assertBool "otr archived ref not empty" (isNothing (memOtrArchivedRef =<< _s elf))
case t of case t of
SelfConv -> assertEqual "access" (Just privateAccess) (cnvAccess <$> cnv) SelfConv -> assertEqual "access" (Just privateAccess) (cnvAccess <$> cnv)
ConnectConv -> assertEqual "access" (Just privateAccess) (cnvAccess <$> cn v) ConnectConv -> assertEqual "access" (Just privateAccess) (cnvAccess <$> cn v)
One2OneConv -> assertEqual "access" (Just privateAccess) (cnvAccess <$> cn v) One2OneConv -> assertEqual "access" (Just privateAccess) (cnvAccess <$> cn v)
 End of changes. 5 change blocks. 
6 lines changed or deleted 7 lines changed or added

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