Skip to content

Commit

Permalink
[WPB-5687] more legalhold tests (#3966)
Browse files Browse the repository at this point in the history
- [feat] port more legalhold tests to /integration
- [feat] introduce combinators for lazy Notifications in App 
---------

Co-authored-by: Marko Dimjašević <marko.dimjasevic@wire.com>
Co-authored-by: Igor Ranieri <igor@elland.me>
Co-authored-by: Akshay Mankar <akshay@wire.com>
  • Loading branch information
4 people authored Apr 10, 2024
1 parent 057af45 commit dce1e8f
Show file tree
Hide file tree
Showing 15 changed files with 811 additions and 911 deletions.
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
19 changes: 16 additions & 3 deletions integration/test/Notifications.hs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,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 +150,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 +188,11 @@ 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
-- NB:
-- (&&) <$> (print "hello" *> pure False) <*> fail "bla" === _|_
-- runMaybeT $ (lift (print "hello") *> MaybeT (pure Nothing)) *> lift (fail "bla") === pure Nothing
nPayload n %. "type" `isEqual` "user.connection"
&&~ nPayload n %. "connection.status" `isEqual` status

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

0 comments on commit dce1e8f

Please sign in to comment.