-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial endpoint skeleton * Set up finalisation for CSV streaming * Implement internal API to get user activity * Test activity endpoint * Initial refactoring of CSV export * getUserRecord implemented * fix integration package * New implementation of getTeamMembersCSV * Implement inviter handle cache * Remove old CSV export handler * Add activity timestamp to csv export * Regenerate nix packages * Linter * Remove new stern endpoint * Add status field to CSV export * Remove new brig internal endpoint This is not needed anymore since the stern endpoint to get user activity has been removed. * Add CHANGELOG entry * Regenerate nix packages * Fix CSV roundtrip test * Remove lookupRichInfo * Remove stern endpoint test * Simplify SCIM user info lookup * fixup! Simplify SCIM user info lookup --------- Co-authored-by: Leif Battermann <[email protected]>
- Loading branch information
1 parent
0290140
commit d70fcee
Showing
44 changed files
with
580 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The team CSV export endpoint has gained two extra columns: `last_active` and `status`. The streaming behaviour has also been improved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,7 @@ library | |
API.GundeckInternal | ||
API.Nginz | ||
API.Spar | ||
API.Stern | ||
MLS.Util | ||
Notifications | ||
RunAllTests | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module API.Stern where | ||
|
||
import Testlib.Prelude | ||
|
||
getTeamActivity :: (HasCallStack, MakesValue domain) => domain -> String -> App Response | ||
getTeamActivity domain tid = | ||
baseRequest domain Stern Unversioned (joinHttpPath ["team-activity-info", tid]) | ||
>>= submit "GET" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{-# OPTIONS -Wno-ambiguous-fields #-} | ||
-- This file is part of the Wire Server implementation. | ||
-- | ||
-- Copyright (C) 2024 Wire Swiss GmbH <[email protected]> | ||
|
@@ -22,6 +23,7 @@ import qualified API.BrigInternal as I | |
import API.Common | ||
import API.Galley (getTeam, getTeamMembers, getTeamMembersCsv, getTeamNotifications) | ||
import API.GalleyInternal (setTeamFeatureStatus) | ||
import API.Gundeck | ||
import Control.Monad.Codensity (Codensity (runCodensity)) | ||
import Control.Monad.Extra (findM) | ||
import Control.Monad.Reader (asks) | ||
|
@@ -284,16 +286,28 @@ testUpgradePersonalToTeamAlreadyInATeam = do | |
-- for additional tests of the CSV download particularly with SCIM users, please refer to 'Test.Spar.Scim.UserSpec' | ||
testTeamMemberCsvExport :: (HasCallStack) => App () | ||
testTeamMemberCsvExport = do | ||
(owner, tid, members) <- createTeam OwnDomain 10 | ||
let numClients = [0, 1, 2] <> repeat 0 | ||
modifiedMembers <- for (zip numClients (owner : members)) $ \(n, m) -> do | ||
handle <- randomHandle | ||
putHandle m handle >>= assertSuccess | ||
replicateM_ n $ addClient m def | ||
void $ I.putSSOId m def {I.scimExternalId = Just "foo"} >>= getBody 200 | ||
setField "handle" handle m | ||
>>= setField "role" (if m == owner then "owner" else "member") | ||
>>= setField "num_clients" (show n) | ||
(owner, tid, members) <- createTeam OwnDomain 5 | ||
|
||
modifiedMembers <- for | ||
( zip | ||
([0, 1, 2] <> repeat 0) | ||
(owner : members) | ||
) | ||
$ \(n, m) -> do | ||
handle <- randomHandle | ||
putHandle m handle >>= assertSuccess | ||
clients <- | ||
replicateM n | ||
$ addClient m def | ||
>>= getJSON 201 | ||
>>= (%. "id") | ||
>>= asString | ||
for_ (listToMaybe clients) $ \c -> | ||
getNotifications m def {client = Just c} | ||
void $ I.putSSOId m def {I.scimExternalId = Just "foo"} >>= getBody 200 | ||
setField "handle" handle m | ||
>>= setField "role" (if m == owner then "owner" else "member") | ||
>>= setField "num_clients" n | ||
|
||
memberMap :: Map.Map String Value <- fmap Map.fromList $ for (modifiedMembers) $ \m -> do | ||
uid <- m %. "id" & asString | ||
|
@@ -302,14 +316,16 @@ testTeamMemberCsvExport = do | |
bindResponse (getTeamMembersCsv owner tid) $ \resp -> do | ||
resp.status `shouldMatchInt` 200 | ||
let rows = sort $ tail $ B8.lines $ resp.body | ||
length rows `shouldMatchInt` 10 | ||
length rows `shouldMatchInt` 5 | ||
for_ rows $ \row -> do | ||
let cols = B8.split ',' row | ||
let uid = read $ B8.unpack $ cols !! 11 | ||
let mem = memberMap Map.! uid | ||
|
||
ownerId <- owner %. "id" & asString | ||
let ownerMember = memberMap Map.! ownerId | ||
now <- formatTime defaultTimeLocale "%Y-%m-%d" <$> liftIO getCurrentTime | ||
numClients <- mem %. "num_clients" & asInt | ||
|
||
let parseField = unquote . read . B8.unpack . (cols !!) | ||
|
||
|
@@ -319,12 +335,15 @@ testTeamMemberCsvExport = do | |
role <- mem %. "role" & asString | ||
parseField 3 `shouldMatch` role | ||
when (role /= "owner") $ do | ||
now <- formatTime defaultTimeLocale "%Y-%m-%d" <$> liftIO getCurrentTime | ||
take 10 (parseField 4) `shouldMatch` now | ||
parseField 5 `shouldMatch` (ownerMember %. "handle") | ||
parseField 7 `shouldMatch` "wire" | ||
parseField 9 `shouldMatch` "foo" | ||
parseField 12 `shouldMatch` (mem %. "num_clients") | ||
parseField 12 `shouldMatch` show numClients | ||
(if numClients > 0 then shouldNotMatch else shouldMatch) | ||
(parseField 13) | ||
"" | ||
parseField 14 `shouldMatch` "active" | ||
where | ||
unquote :: String -> String | ||
unquote ('\'' : x) = x | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.