Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block and kick users in case of LH no_consent conflict (1:1 convs). #1507

Merged
merged 58 commits into from
May 26, 2021
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
2ced774
...
fisx May 14, 2021
9117e7e
fix incorrect test env
smatting May 21, 2021
716c358
block accepted connections
smatting May 21, 2021
6672735
work on integration tests.
fisx May 23, 2021
04a6795
Catch lh policy conflicts when creating connections.
fisx May 23, 2021
2486b37
Introduce 'Relation' state "blocked for missing legalhold consent".
fisx May 23, 2021
7a14260
...
fisx May 23, 2021
34ee2a8
...
fisx May 23, 2021
51b4b63
...
fisx May 23, 2021
4e39bd8
Remove `_'` refactoring suffix from 'Relation'.
fisx May 23, 2021
6b5b8ed
I don't know!
fisx May 23, 2021
d25fd7d
...
fisx May 24, 2021
7baccdd
...
fisx May 24, 2021
906b08d
Better failure messages in test helpers.
fisx May 24, 2021
a1b8429
updateConnectionInternal.
fisx May 24, 2021
572e575
fix compilation
smatting May 24, 2021
56a8b14
Implement LH block/unblock for connections
smatting May 24, 2021
92879d7
move to brig-types wip
smatting May 24, 2021
d50848f
...
fisx May 24, 2021
6dcfd29
...
fisx May 24, 2021
f6297aa
use new internal funtion
smatting May 24, 2021
7092c1f
galley: use new endpoint
smatting May 24, 2021
5aedc50
galley: handle errors in batch
smatting May 24, 2021
b763a2e
fix rpc path
smatting May 24, 2021
3aadce2
changeLegalholdStatus: add old status as arg
smatting May 24, 2021
7bc2575
toApsData: Fix and TODO
smatting May 24, 2021
0d3ca39
test: disable message testing
smatting May 24, 2021
c77087a
changeLegalholdStatus: implement unblock
smatting May 24, 2021
13e8592
fix bug: remove not
smatting May 24, 2021
cf9465f
bench hack.
fisx May 24, 2021
d1da59c
set bench hack to pending.
fisx May 24, 2021
edc6d03
Merge branch 'SQSERVICES-402-block-and-kick' of ssh://github.com/wire…
fisx May 24, 2021
f236ec1
Fixup
fisx May 24, 2021
16561d3
brig: update updateConnectionInternal
smatting May 24, 2021
92bc9ab
refactor & and unblock in changeLHStatus
smatting May 24, 2021
6dcec75
enable all tests
smatting May 24, 2021
1b4a4e1
fix unit test
smatting May 25, 2021
48b66e1
Fix: log messages.
fisx May 25, 2021
b23ab55
Fix: names.
fisx May 25, 2021
e19ca19
Remove bogus condition.
fisx May 25, 2021
8a6ec4b
TODOs.
fisx May 25, 2021
e8d17af
Remove focus markers in integration tests.
fisx May 25, 2021
528db20
Fix: names.
fisx May 25, 2021
f69c515
Fix: TODOs
fisx May 25, 2021
dee9c6d
Fix: TODOs
fisx May 25, 2021
5a7d789
Resolve outdated TODO; fix pattern match priorities.
fisx May 25, 2021
d33e5b4
Fixup
fisx May 25, 2021
14cb8f6
Resolve outdated TODO.
fisx May 25, 2021
43e3fa7
Make pattern match more robust (avoid catch-all).
fisx May 25, 2021
788345d
De-prioritize TODO.
fisx May 25, 2021
127eef9
Document implicit json instances.
fisx May 25, 2021
2cddef4
Fixup.
fisx May 25, 2021
d35ea14
Hi CI
jschaul May 25, 2021
690b67a
Update services/brig/src/Brig/API/Connection.hs
fisx May 26, 2021
da45b70
Process review feedback.
fisx May 26, 2021
d28161e
Fix: granting consent.
fisx May 26, 2021
08750d4
Refactor: mv function to top-level scope.
fisx May 26, 2021
4aef9e9
Fix: (again) changing LH state.
fisx May 26, 2021
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
3 changes: 2 additions & 1 deletion libs/brig-types/brig-types.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
-- hash: b653eba4d855ab6675efd3519d4259c9bb49379e92b15fb7f4f9080eac634bb1
-- hash: 2b3c91a37e09e61ca32cf32ab80c46e8f019926c78165bec82d9c84a5b8d20a6

name: brig-types
version: 1.35.0
Expand Down Expand Up @@ -89,6 +89,7 @@ test-suite brig-types-tests
, attoparsec >=0.10
, base ==4.*
, brig-types
, bytestring-conversion >=0.3.1
, containers >=0.5
, imports
, swagger2 >=2.5
Expand Down
1 change: 1 addition & 0 deletions libs/brig-types/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies:
- aeson >=0.11
- attoparsec >=0.10
- base ==4.*
- bytestring-conversion >=0.3.1
- containers >=0.5
- imports
- QuickCheck >=2.9
Expand Down
13 changes: 13 additions & 0 deletions libs/brig-types/src/Brig/Types/Connection.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module Brig.Types.Connection
( module C,
UserIds (..),
ConnectionsStatusRequest (..),
UpdateConnectionsInternal (..),

-- * re-exports
Message (..),
Expand All @@ -41,6 +42,7 @@ import Brig.Types.Common as C
import Data.Aeson
import Data.Id (UserId)
import Imports
import Wire.API.Arbitrary
import Wire.API.Connection

-- | Response type for endpoints returning lists of users with a specific connection state.
Expand All @@ -57,6 +59,17 @@ data ConnectionsStatusRequest = ConnectionsStatusRequest
}
deriving (Eq, Show, Generic)

data UpdateConnectionsInternal
= BlockForMissingLHConsent UserId [UserId]
| RemoveLHBlocksInvolving UserId
deriving (Eq, Show, Generic)
jschaul marked this conversation as resolved.
Show resolved Hide resolved
deriving (Arbitrary) via (GenericUniform UpdateConnectionsInternal)

instance FromJSON UpdateConnectionsInternal

-- | `{"tag":"BlockForMissingLHConsent","contents":["3ae7f23a-bd47-11eb-932d-5fccbbcde454",["3ae7f23a-bd47-11eb-932d-5fccbbcde454"]]}`
fisx marked this conversation as resolved.
Show resolved Hide resolved
instance ToJSON UpdateConnectionsInternal

----------------------------------------------------------------------------
-- JSON instances

Expand Down
12 changes: 12 additions & 0 deletions libs/brig-types/test/unit/Test/Brig/Roundtrip.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module Test.Brig.Roundtrip where

import Data.Aeson (FromJSON, ToJSON, parseJSON, toJSON)
import Data.Aeson.Types (parseEither)
import Data.ByteString.Conversion
import Data.Swagger (ToSchema, validatePrettyToJSON)
import Imports
import Test.Tasty (TestTree)
Expand Down Expand Up @@ -55,3 +56,14 @@ testRoundTripWithSwagger = testProperty msg (trip .&&. scm)
validatePrettyToJSON v
)
$ isNothing (validatePrettyToJSON v)

testRoundTripByteString ::
fisx marked this conversation as resolved.
Show resolved Hide resolved
forall a.
(Arbitrary a, Typeable a, ToByteString a, FromByteString a, Eq a, Show a) =>
TestTree
testRoundTripByteString = testProperty msg trip
where
msg = show (typeRep @a)
trip (v :: a) =
counterexample (show $ toByteString' v) $
Just v === (fromByteString . toByteString') v
4 changes: 3 additions & 1 deletion libs/brig-types/test/unit/Test/Brig/Types/User.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

module Test.Brig.Types.User where

import Brig.Types.Connection (UpdateConnectionsInternal (..))
import Brig.Types.Intra (NewUserScimInvitation (..), ReAuthUser (..))
import Brig.Types.User (ManagedByUpdate (..), RichInfoUpdate (..))
import Brig.Types.User.EJPD (EJPDRequestBody (..), EJPDResponseBody (..))
Expand All @@ -45,7 +46,8 @@ roundtripTests =
testRoundTrip @RichInfoUpdate,
testRoundTrip @NewUserScimInvitation,
testRoundTripWithSwagger @EJPDRequestBody,
testRoundTripWithSwagger @EJPDResponseBody
testRoundTripWithSwagger @EJPDResponseBody,
testRoundTrip @UpdateConnectionsInternal
]

instance Arbitrary ManagedByUpdate where
Expand Down
30 changes: 26 additions & 4 deletions libs/wire-api/src/Wire/API/Connection.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import Data.Range
import qualified Data.Swagger.Build.Api as Doc
import Data.Swagger.Schema
import Data.Text as Text
import Deriving.Swagger (CamelToSnake, ConstructorTagModifier, CustomSwagger)
import Deriving.Swagger (CamelToKebab, ConstructorTagModifier, CustomSwagger)
import Imports
import Wire.API.Arbitrary (Arbitrary (arbitrary), GenericUniform (..))

Expand Down Expand Up @@ -159,9 +159,11 @@ data Relation
| Ignored
| Sent
| Cancelled
| -- | behaves like blocked, the extra constructor is just to inform why.
MissingLegalholdConsent
deriving stock (Eq, Ord, Show, Generic)
deriving (Arbitrary) via (GenericUniform Relation)
deriving (ToSchema) via (CustomSwagger '[ConstructorTagModifier CamelToSnake] Relation)
deriving (ToSchema) via (CustomSwagger '[ConstructorTagModifier CamelToKebab] Relation)

typeRelation :: Doc.DataType
typeRelation =
Expand All @@ -172,11 +174,19 @@ typeRelation =
"pending",
"ignored",
"sent",
"cancelled"
"cancelled",
"missing-legalhold-consent"
]

instance ToJSON Relation where
toJSON = String . Text.toLower . pack . show
toJSON = \case
Accepted -> "accepted"
Blocked -> "blocked"
Pending -> "pending"
Ignored -> "ignored"
Sent -> "sent"
Cancelled -> "cancelled"
MissingLegalholdConsent -> "missing-legalhold-consent"

instance FromJSON Relation where
parseJSON (String "accepted") = return Accepted
Expand All @@ -185,6 +195,7 @@ instance FromJSON Relation where
parseJSON (String "ignored") = return Ignored
parseJSON (String "sent") = return Sent
parseJSON (String "cancelled") = return Cancelled
parseJSON (String "missing-legalhold-consent") = return MissingLegalholdConsent
parseJSON _ = mzero

instance FromByteString Relation where
Expand All @@ -196,8 +207,19 @@ instance FromByteString Relation where
"ignored" -> return Ignored
"sent" -> return Sent
"cancelled" -> return Cancelled
"missing-legalhold-consent" -> return MissingLegalholdConsent
x -> fail $ "Invalid relation-type " <> show x

instance ToByteString Relation where
builder = \case
Accepted -> "accepted"
Blocked -> "blocked"
Pending -> "pending"
Ignored -> "ignored"
Sent -> "sent"
Cancelled -> "cancelled"
MissingLegalholdConsent -> "missing-legalhold-consent"

--------------------------------------------------------------------------------
-- Message

Expand Down
2 changes: 1 addition & 1 deletion libs/wire-api/test/golden/testObject_Relation_user_20.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"ignored"
"missing-legalhold-consent"
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ testObject_Relation_user_19 :: Relation
testObject_Relation_user_19 = Cancelled

testObject_Relation_user_20 :: Relation
testObject_Relation_user_20 = Ignored
testObject_Relation_user_20 = MissingLegalholdConsent
2 changes: 2 additions & 0 deletions libs/wire-api/test/unit/Test/Wire/API/Roundtrip/ByteString.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import qualified Wire.API.Arbitrary as Arbitrary ()
import qualified Wire.API.Asset.V3 as Asset.V3
import qualified Wire.API.Asset.V3.Resumable as Asset.V3.Resumable
import qualified Wire.API.Call.Config as Call.Config
import qualified Wire.API.Connection as Connection
import qualified Wire.API.Conversation.Code as Conversation.Code
import qualified Wire.API.Conversation.Role as Conversation.Role
import qualified Wire.API.Properties as Properties
Expand Down Expand Up @@ -56,6 +57,7 @@ tests =
testRoundTrip @Call.Config.Transport,
testRoundTrip @Call.Config.TurnHost,
testRoundTrip @Call.Config.TurnURI,
testRoundTrip @Connection.Relation,
testRoundTrip @Conversation.Code.Key,
testRoundTrip @Conversation.Code.Value,
testRoundTrip @Conversation.Role.RoleName,
Expand Down
Loading