Skip to content

Commit 7c95cbe

Browse files
committed
use /login endpoint for /i/metrics test
1 parent a477226 commit 7c95cbe

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

libs/wire-api/src/Wire/API/Routes/Public/Brig.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,6 @@ type AccountAPI =
493493
:> ReqBody '[JSON] PasswordReset
494494
:> MultiVerb 'POST '[JSON] '[RespondEmpty 200 "Password reset successful."] ()
495495
)
496-
-- This endpoint is used to test /i/metrics, when this is servantified, please
497-
-- make sure some other endpoint is used to test that routes defined in this
498-
-- function are recorded and reported correctly in /i/metrics.
499-
-- see test/integration/API/Metrics.hs
500496
:<|> Named
501497
"onboarding"
502498
( Summary "Upload contacts and invoke matching."

services/brig/src/Brig/User/API/Auth.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ routesPublic = do
110110
Doc.errorResponse passwordExists
111111
Doc.errorResponse' loginCodePending Doc.pendingLoginError
112112

113+
-- This endpoint is used to test /i/metrics, when this is servantified, please
114+
-- make sure some other wai-route endpoint is used to test that routes defined in
115+
-- this function ('Brig.API.Public.sitemap') are recorded and reported correctly in /i/metrics.
116+
-- see test/integration/API/Metrics.hs
113117
post "/login" (continue loginH) $
114118
jsonRequest @Public.Login
115119
.&. def False (query "persist")

services/brig/test/integration/API/Metrics.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,23 @@ testMetricsEndpoint :: Brig -> Http ()
5454
testMetricsEndpoint brig = do
5555
let p1 = "/self"
5656
p2 uid = "/users/" <> uid <> "/clients"
57-
p3 = "/onboarding/v3"
57+
p3 = "/login"
5858
beforeSelf <- getCount "/self" "GET"
5959
beforeClients <- getCount "/users/:uid/clients" "GET"
60-
beforeProperties <- getCount "/onboarding/v3" "POST"
61-
uid <- userId <$> randomUser brig
60+
beforeProperties <- getCount "/login" "POST"
61+
(uid, Just email) <- (\u -> (userId u, userEmail u)) <$> randomUser brig
6262
uid' <- userId <$> randomUser brig
6363
_ <- get (brig . path p1 . zAuthAccess uid "conn" . expect2xx)
6464
_ <- get (brig . path (p2 $ toByteString' uid) . zAuthAccess uid "conn" . expect2xx)
6565
_ <- get (brig . path (p2 $ toByteString' uid') . zAuthAccess uid "conn" . expect2xx)
66-
_ <- post (brig . path p3 . zAuthAccess uid "conn" . json 'x' . expect2xx)
67-
_ <- post (brig . path p3 . zAuthAccess uid "conn" . json 'x' . expect2xx)
66+
_ <- post (brig . path p3 . contentJson . queryItem "persist" "true" . json (defEmailLogin email) . expect2xx)
67+
_ <- post (brig . path p3 . contentJson . queryItem "persist" "true" . json (defEmailLogin email) . expect2xx)
6868
countSelf <- getCount "/self" "GET"
6969
liftIO $ assertEqual "/self was called once" (beforeSelf + 1) countSelf
7070
countClients <- getCount "/users/:uid/clients" "GET"
7171
liftIO $ assertEqual "/users/:uid/clients was called twice" (beforeClients + 2) countClients
72-
countProperties <- getCount "/onboarding/v3" "POST"
73-
liftIO $ assertEqual "/onboarding/v3 was called twice" (beforeProperties + 2) countProperties
72+
countProperties <- getCount "/login" "POST"
73+
liftIO $ assertEqual "/login was called twice" (beforeProperties + 2) countProperties
7474
where
7575
getCount endpoint m = do
7676
rsp <- responseBody <$> get (brig . path "i/metrics")

0 commit comments

Comments
 (0)