Skip to content

Commit

Permalink
add test for team settings auth (#3851)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanwire authored Jan 31, 2024
1 parent f34a8e8 commit da07445
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
1 change: 1 addition & 0 deletions integration/integration.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ library
Test.Search
Test.Services
Test.Swagger
Test.TeamSettings
Test.User
Test.Version
Testlib.App
Expand Down
33 changes: 33 additions & 0 deletions integration/test/API/Galley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,39 @@ getTeamMembers user tid = do
req <- baseRequest user Galley Versioned (joinHttpPath ["teams", tidStr, "members"])
submit "GET" req

data AppLockSettings = AppLockSettings
{ status :: String,
enforce :: Bool,
inactivityTimeoutSecs :: Int
}

instance Default AppLockSettings where
def = AppLockSettings "disabled" False 60

-- | https://staging-nginz-https.zinfra.io/v6/api/swagger-ui/#/default/put_teams__tid__features_appLock
putAppLockSettings ::
(HasCallStack, MakesValue tid, MakesValue caller) =>
tid ->
caller ->
AppLockSettings ->
App Response
putAppLockSettings tid caller settings = do
tidStr <- asString tid
req <- baseRequest caller Galley Versioned (joinHttpPath ["teams", tidStr, "features", "appLock"])
submit
"PUT"
( addJSONObject
[ "status" .= settings.status,
"ttl" .= "unlimited",
"config"
.= object
[ "enforceAppLock" .= settings.enforce,
"inactivityTimeoutSecs" .= settings.inactivityTimeoutSecs
]
]
req
)

-- | https://staging-nginz-https.zinfra.io/v5/api/swagger-ui/#/default/post_teams__tid__legalhold_settings
enableLegalHold :: (HasCallStack, MakesValue tid, MakesValue ownerid) => tid -> ownerid -> App Response
enableLegalHold tid ownerid = do
Expand Down
38 changes: 38 additions & 0 deletions integration/test/Test/TeamSettings.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{-# OPTIONS_GHC -Wno-ambiguous-fields #-}

-- This file is part of the Wire Server implementation.
--
-- Copyright (C) 2023 Wire Swiss GmbH <opensource@wire.com>
--
-- This program is free software: you can redistribute it and/or modify it under
-- the terms of the GNU Affero General Public License as published by the Free
-- Software Foundation, either version 3 of the License, or (at your option) any
-- later version.
--
-- This program is distributed in the hope that it will be useful, but WITHOUT
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
-- details.
--
-- You should have received a copy of the GNU Affero General Public License along
-- with this program. If not, see <https://www.gnu.org/licenses/>.

module Test.TeamSettings where

import API.Galley
import SetupHelpers
import Testlib.Prelude

testTeamSettingsUpdate :: HasCallStack => App ()
testTeamSettingsUpdate = do
(owner, tid, [mem]) <- createTeam OwnDomain 2
partner <- createTeamMemberWithRole owner tid "partner"

bindResponse (putAppLockSettings tid owner def) $ \resp -> do
resp.status `shouldMatchInt` 200
bindResponse (putAppLockSettings tid mem def) $ \resp -> do
resp.status `shouldMatchInt` 403
resp.json %. "label" `shouldMatch` "operation-denied"
bindResponse (putAppLockSettings tid partner def) $ \resp -> do
resp.status `shouldMatchInt` 403
resp.json %. "label" `shouldMatch` "operation-denied"

0 comments on commit da07445

Please sign in to comment.