Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/5-internal/WPB-7021
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
port more of the legalhold test-suite from galley-integration to /integration and get rid of the need for startDynamicBackends
1 change: 1 addition & 0 deletions charts/integration/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,4 @@ data:
stern:
host: stern.wire-federation-v0.svc.cluster.local
port: 8080
integrationTestHostName: integration-headless.{{ .Release.Namespace }}.svc.cluster.local
11 changes: 11 additions & 0 deletions charts/integration/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
{{- $newLabels := eq (include "integrationTestHelperNewLabels" .) "true" -}}
---
apiVersion: v1
kind: Service
metadata:
name: integration-headless
spec:
selector:
app: integration-integration
type: ClusterIP
clusterIP: None

---
apiVersion: v1
kind: Service
Expand Down
45 changes: 42 additions & 3 deletions integration/test/Notifications.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import API.Gundeck
import Control.Error (lastMay)
import Control.Monad.Extra
import Control.Monad.Reader (asks)
import Control.Monad.Trans.Maybe (MaybeT (..))
import Testlib.Prelude
import UnliftIO (timeout)
import UnliftIO.Concurrent
Expand Down Expand Up @@ -115,6 +116,11 @@ isMemberJoinNotif n = fieldEquals n "payload.0.type" "conversation.member-join"
isConvLeaveNotif :: MakesValue a => a -> App Bool
isConvLeaveNotif n = fieldEquals n "payload.0.type" "conversation.member-leave"

isConvLeaveNotifWithLeaver :: (MakesValue user, MakesValue a) => user -> a -> App Bool
isConvLeaveNotifWithLeaver user n =
fieldEquals n "payload.0.type" "conversation.member-leave"
&&~ (n %. "payload.0.data.user_ids.0") `isEqual` (user %. "id")

isNotifConv :: (MakesValue conv, MakesValue a, HasCallStack) => conv -> a -> App Bool
isNotifConv conv n = fieldEquals n "payload.0.qualified_conversation" (objQidObject conv)

Expand Down Expand Up @@ -145,6 +151,12 @@ isConvAccessUpdateNotif n =
isConvCreateNotif :: MakesValue a => a -> App Bool
isConvCreateNotif n = fieldEquals n "payload.0.type" "conversation.create"

-- | like 'isConvCreateNotif' but excludes self conversations
isConvCreateNotifNotSelf :: MakesValue a => a -> App Bool
isConvCreateNotifNotSelf n =
fieldEquals n "payload.0.type" "conversation.create"
&&~ do not <$> fieldEquals n "payload.0.data.access" ["private"]

isConvDeleteNotif :: MakesValue a => a -> App Bool
isConvDeleteNotif n = fieldEquals n "payload.0.type" "conversation.delete"

Expand Down Expand Up @@ -177,9 +189,36 @@ isUserConnectionNotif = notifTypeIsEqual "user.connection"

isConnectionNotif :: MakesValue a => String -> a -> App Bool
isConnectionNotif status n =
(&&)
<$> nPayload n %. "type" `isEqual` "user.connection"
<*> nPayload n %. "connection.status" `isEqual` status
nPayload n %. "type" `isEqual` "user.connection"
&&~ nPayload n %. "connection.status" `isEqual` status

-- NB:
-- (&&) <$> (print "hello" *> pure False) <*> fail "bla" === _|_
-- runMaybeT $ (lift (print "hello") *> MaybeT (pure Nothing)) *> lift (fail "bla") === pure Nothing
Comment thread
MangoIV marked this conversation as resolved.
Outdated

-- | make Bool lazy
liftBool :: Functor f => f Bool -> BoolT f
liftBool = MaybeT . fmap (bool Nothing (Just ()))

-- | make Bool strict
unliftBool :: Functor f => BoolT f -> f Bool
unliftBool = fmap isJust . runMaybeT

-- | lazy (&&)
(&&~) :: App Bool -> App Bool -> App Bool
Comment thread
MangoIV marked this conversation as resolved.
Outdated
b1 &&~ b2 = unliftBool $ liftBool b1 *> liftBool b2

infixr 3 &&~

-- | lazy (||)
(||~) :: App Bool -> App Bool -> App Bool
b1 ||~ b2 = unliftBool $ liftBool b1 <|> liftBool b2

infixr 2 ||~

-- | lazy (&&): (*>)
-- lazy (||): (<|>)
type BoolT f = MaybeT f ()

assertLeaveNotification ::
( HasCallStack,
Expand Down
4 changes: 2 additions & 2 deletions integration/test/SetupHelpers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ setUpLHDevice ::
tid ->
owner ->
uid ->
-- | the port the LH service is running on
Int ->
-- | the host and port the LH service is running on
(String, Int) ->
App ()
setUpLHDevice tid alice bob lhPort = do
legalholdWhitelistTeam tid alice
Expand Down
Loading