Skip to content

Commit da07445

Browse files
authored
add test for team settings auth (#3851)
1 parent f34a8e8 commit da07445

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

integration/integration.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ library
137137
Test.Search
138138
Test.Services
139139
Test.Swagger
140+
Test.TeamSettings
140141
Test.User
141142
Test.Version
142143
Testlib.App

integration/test/API/Galley.hs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,39 @@ getTeamMembers user tid = do
515515
req <- baseRequest user Galley Versioned (joinHttpPath ["teams", tidStr, "members"])
516516
submit "GET" req
517517

518+
data AppLockSettings = AppLockSettings
519+
{ status :: String,
520+
enforce :: Bool,
521+
inactivityTimeoutSecs :: Int
522+
}
523+
524+
instance Default AppLockSettings where
525+
def = AppLockSettings "disabled" False 60
526+
527+
-- | https://staging-nginz-https.zinfra.io/v6/api/swagger-ui/#/default/put_teams__tid__features_appLock
528+
putAppLockSettings ::
529+
(HasCallStack, MakesValue tid, MakesValue caller) =>
530+
tid ->
531+
caller ->
532+
AppLockSettings ->
533+
App Response
534+
putAppLockSettings tid caller settings = do
535+
tidStr <- asString tid
536+
req <- baseRequest caller Galley Versioned (joinHttpPath ["teams", tidStr, "features", "appLock"])
537+
submit
538+
"PUT"
539+
( addJSONObject
540+
[ "status" .= settings.status,
541+
"ttl" .= "unlimited",
542+
"config"
543+
.= object
544+
[ "enforceAppLock" .= settings.enforce,
545+
"inactivityTimeoutSecs" .= settings.inactivityTimeoutSecs
546+
]
547+
]
548+
req
549+
)
550+
518551
-- | https://staging-nginz-https.zinfra.io/v5/api/swagger-ui/#/default/post_teams__tid__legalhold_settings
519552
enableLegalHold :: (HasCallStack, MakesValue tid, MakesValue ownerid) => tid -> ownerid -> App Response
520553
enableLegalHold tid ownerid = do
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{-# OPTIONS_GHC -Wno-ambiguous-fields #-}
2+
3+
-- This file is part of the Wire Server implementation.
4+
--
5+
-- Copyright (C) 2023 Wire Swiss GmbH <[email protected]>
6+
--
7+
-- This program is free software: you can redistribute it and/or modify it under
8+
-- the terms of the GNU Affero General Public License as published by the Free
9+
-- Software Foundation, either version 3 of the License, or (at your option) any
10+
-- later version.
11+
--
12+
-- This program is distributed in the hope that it will be useful, but WITHOUT
13+
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14+
-- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
15+
-- details.
16+
--
17+
-- You should have received a copy of the GNU Affero General Public License along
18+
-- with this program. If not, see <https://www.gnu.org/licenses/>.
19+
20+
module Test.TeamSettings where
21+
22+
import API.Galley
23+
import SetupHelpers
24+
import Testlib.Prelude
25+
26+
testTeamSettingsUpdate :: HasCallStack => App ()
27+
testTeamSettingsUpdate = do
28+
(owner, tid, [mem]) <- createTeam OwnDomain 2
29+
partner <- createTeamMemberWithRole owner tid "partner"
30+
31+
bindResponse (putAppLockSettings tid owner def) $ \resp -> do
32+
resp.status `shouldMatchInt` 200
33+
bindResponse (putAppLockSettings tid mem def) $ \resp -> do
34+
resp.status `shouldMatchInt` 403
35+
resp.json %. "label" `shouldMatch` "operation-denied"
36+
bindResponse (putAppLockSettings tid partner def) $ \resp -> do
37+
resp.status `shouldMatchInt` 403
38+
resp.json %. "label" `shouldMatch` "operation-denied"

0 commit comments

Comments
 (0)