Skip to content

Commit 82afaa2

Browse files
authored
More stern integration tests and fixes (#3232)
1 parent f922e65 commit 82afaa2

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

changelog.d/5-internal/pr-3232

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
More backoffice/stern integration tests and fixes

tools/stern/src/Stern/API.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import Stern.Types
6060
import System.Logger.Class hiding (Error, name, trace, (.=))
6161
import Util.Options
6262
import Wire.API.Connection
63+
import Wire.API.Internal.Notification (QueuedNotification)
6364
import Wire.API.Routes.Internal.Brig.Connection (ConnectionStatus)
6465
import qualified Wire.API.Routes.Internal.Brig.EJPD as EJPD
6566
import qualified Wire.API.Routes.Internal.Galley.TeamsIntra as Team
@@ -397,7 +398,7 @@ getUserData uid = do
397398
conns <- Intra.getUserConnections uid
398399
convs <- Intra.getUserConversations uid
399400
clts <- Intra.getUserClients uid
400-
notfs <- Intra.getUserNotifications uid
401+
notfs <- (Intra.getUserNotifications uid <&> toJSON @[QueuedNotification]) `catchE` (pure . String . cs . show)
401402
consent <- (Intra.getUserConsentValue uid <&> toJSON @ConsentValue) `catchE` (pure . String . cs . show)
402403
consentLog <- (Intra.getUserConsentLog uid <&> toJSON @ConsentLog) `catchE` (pure . String . cs . show)
403404
cookies <- Intra.getUserCookies uid

tools/stern/src/Stern/Intra.hs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ putUser uid upd = do
138138
"brig"
139139
b
140140
( method PUT
141-
. versionedPath "/self"
141+
. versionedPath "self"
142142
. header "Z-User" (toByteString' uid)
143143
. header "Z-Connection" (toByteString' "")
144144
. lbytes (encode upd)
@@ -374,6 +374,7 @@ changeEmail u upd = do
374374
. Bilge.path "i/self/email"
375375
. header "Z-User" (toByteString' u)
376376
. header "Z-Connection" (toByteString' "")
377+
. queryItem "validate" "true"
377378
. lbytes (encode upd)
378379
. contentJson
379380
. expect2xx
@@ -388,7 +389,7 @@ changePhone u upd = do
388389
"brig"
389390
b
390391
( method PUT
391-
. versionedPath "/self/phone"
392+
. versionedPath "self/phone"
392393
. header "Z-User" (toByteString' u)
393394
. header "Z-Connection" (toByteString' "")
394395
. lbytes (encode upd)
@@ -680,7 +681,7 @@ getUserConsentValue uid = do
680681
g
681682
( method GET
682683
. header "Z-User" (toByteString' uid)
683-
. versionedPath "/self/consent"
684+
. versionedPath "self/consent"
684685
. expect2xx
685686
)
686687
parseResponse (mkError status502 "bad-upstream") r
@@ -732,7 +733,7 @@ getUserCookies uid = do
732733
g
733734
( method GET
734735
. header "Z-User" (toByteString' uid)
735-
. versionedPath "/cookies"
736+
. versionedPath "cookies"
736737
. expect2xx
737738
)
738739
parseResponse (mkError status502 "bad-upstream") r
@@ -777,7 +778,7 @@ getUserClients uid = do
777778
b
778779
( method GET
779780
. header "Z-User" (toByteString' uid)
780-
. versionedPath "/clients"
781+
. versionedPath "clients"
781782
. expect2xx
782783
)
783784
info $ msg ("Response" ++ show r)
@@ -794,7 +795,7 @@ getUserProperties uid = do
794795
b
795796
( method GET
796797
. header "Z-User" (toByteString' uid)
797-
. versionedPath "/properties"
798+
. versionedPath "properties"
798799
. expect2xx
799800
)
800801
info $ msg ("Response" ++ show r)
@@ -838,7 +839,7 @@ getUserNotifications uid = do
838839
b
839840
( method GET
840841
. header "Z-User" (toByteString' uid)
841-
. versionedPath "/notifications"
842+
. versionedPath "notifications"
842843
. queryItem "size" (toByteString' batchSize)
843844
. maybe id (queryItem "since" . toByteString') start
844845
. expectStatus (`elem` [200, 404])

tools/stern/test/integration/API.hs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,16 @@ tests s =
9292
test s "PUT /teams/:tid/billing" testPutTeamBillingInfo,
9393
test s "POST /teams/:tid/billing" testPostTeamBillingInfo,
9494
test s "GET /i/consent" testGetConsentLog,
95-
test s "GET /teams/:id" testGetTeamInfo
95+
test s "GET /teams/:id" testGetTeamInfo,
96+
test s "GET i/user/meta-info?id=..." testGetUserMetaInfo
9697
]
9798

99+
testGetUserMetaInfo :: TestM ()
100+
testGetUserMetaInfo = do
101+
uid <- randomUser
102+
-- Just make sure this returns a 200
103+
void $ getUserMetaInfo uid
104+
98105
testPutPhone :: TestM ()
99106
testPutPhone = pure ()
100107

0 commit comments

Comments
 (0)