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

WPB-6269 add test for team settings auth #3851

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 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"
Loading