Skip to content

Commit

Permalink
Missed another spot.
Browse files Browse the repository at this point in the history
  • Loading branch information
fisx committed May 19, 2021
1 parent c4e40b8 commit 3cd136c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions services/brig/src/Brig/API/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ updateClient u c r = do
unless ok $
throwE ClientNotFound
for_ (updateClientLabel r) $ lift . Data.updateClientLabel u c . Just
for_ (updateClientCapabilities r) $ \features' -> do
features <- fromMaybe mempty <$> Data.lookupClientCapabilities u c
if features `Set.isSubsetOf` features'
then lift . Data.updateClientCapabilities u c . Just $ features'
for_ (updateClientCapabilities r) $ \caps' -> do
caps <- fromMaybe mempty <$> Data.lookupClientCapabilities u c
if caps `Set.isSubsetOf` caps'
then lift . Data.updateClientCapabilities u c . Just $ caps'
else throwE ClientCapabilitiesCannotBeRemoved
let lk = maybeToList (unpackLastPrekey <$> updateClientLastKey r)
Data.updatePrekeys u c (lk ++ updateClientPrekeys r) !>> ClientDataError
Expand Down
2 changes: 1 addition & 1 deletion services/brig/src/Brig/API/Public.hs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ sitemap o = do
Doc.returns (Doc.ref Public.modelClient)
Doc.response 200 "Client" Doc.end

get "/clients/:client/supported-features" (continue getClientCapabilitiesH) $
get "/clients/:client/capabilities" (continue getClientCapabilitiesH) $
zauthUserId
.&. capture "client"
.&. accept "application" "json"
Expand Down
16 changes: 8 additions & 8 deletions services/brig/test/integration/API/User/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -535,10 +535,10 @@ testUpdateClient opts brig = do
const 200 === statusCode
const (Just "label") === (clientLabel <=< responseJsonMaybe)

-- update supported client features work
-- update supported client capabilities work
let checkUpdate :: HasCallStack => Maybe [ClientCapability] -> Bool -> [ClientCapability] -> Http ()
checkUpdate featuresIn respStatusOk featuresOut = do
let update'' = UpdateClient [] Nothing Nothing (Set.fromList <$> featuresIn)
checkUpdate capsIn respStatusOk capsOut = do
let update'' = UpdateClient [] Nothing Nothing (Set.fromList <$> capsIn)
put
( brig
. paths ["clients", toByteString' (clientId c)]
Expand All @@ -553,15 +553,15 @@ testUpdateClient opts brig = do
const 409 === statusCode
const (Just "client-capabilities-cannot-be-removed") === fmap Error.label . responseJsonMaybe

getClientSupportedFeatures brig uid (clientId c) !!! do
getClientCapabilities brig uid (clientId c) !!! do
const 200 === statusCode
const (Just (ClientCapabilityList (Set.fromList featuresOut))) === responseJsonMaybe
const (Just (ClientCapabilityList (Set.fromList capsOut))) === responseJsonMaybe

checkUpdate (Just [ClientSupportsLegalholdImplicitConsent]) True [ClientSupportsLegalholdImplicitConsent]
checkUpdate Nothing True [ClientSupportsLegalholdImplicitConsent]
checkUpdate (Just []) False [ClientSupportsLegalholdImplicitConsent]

-- update supported client features don't break prekeys or label
-- update supported client capabilities don't break prekeys or label
do
let checkClientLabel :: HasCallStack => Http ()
checkClientLabel = do
Expand All @@ -586,7 +586,7 @@ testUpdateClient opts brig = do
assertEqual "" (clientId c) cid'
assertEqual "" expectedPrekey prekey'

clientfeatures = Just $ Set.fromList [ClientSupportsLegalholdImplicitConsent]
caps = Just $ Set.fromList [ClientSupportsLegalholdImplicitConsent]

label = "label-bc1b7b0c-b7bf-11eb-9a1d-233d397f934a"
prekey = somePrekeys !! 4
Expand All @@ -607,7 +607,7 @@ testUpdateClient opts brig = do
. paths ["clients", toByteString' (clientId c)]
. zUser uid
. contentJson
. (body . RequestBodyLBS . encode $ UpdateClient [] Nothing Nothing clientfeatures)
. (body . RequestBodyLBS . encode $ UpdateClient [] Nothing Nothing caps)
)
!!! const 200 === statusCode
checkClientLabel
Expand Down
6 changes: 3 additions & 3 deletions services/brig/test/integration/API/User/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ getClient brig u c =
. paths ["clients", toByteString' c]
. zUser u

getClientSupportedFeatures :: Brig -> UserId -> ClientId -> (MonadIO m, MonadHttp m) => m ResponseLBS
getClientSupportedFeatures brig u c =
getClientCapabilities :: Brig -> UserId -> ClientId -> (MonadIO m, MonadHttp m) => m ResponseLBS
getClientCapabilities brig u c =
get $
brig
. paths ["clients", toByteString' c, "supported-features"]
. paths ["clients", toByteString' c, "capabilities"]
. zUser u

getUserClientsUnqualified :: Brig -> UserId -> (MonadIO m, MonadHttp m) => m ResponseLBS
Expand Down

0 comments on commit 3cd136c

Please sign in to comment.