@@ -38,20 +38,22 @@ tests :: ConnectionLimit -> Opt.Timeout -> Maybe Opt.Opts -> Manager -> Brig ->
38
38
tests _cl _at _conf p b c g = testGroup " client"
39
39
[ test p " get /users/:user/prekeys - 200" $ testGetUserPrekeys b
40
40
, test p " get /users/:user/prekeys/:client - 200" $ testGetClientPrekey b
41
- , test p " post /clients - 201" $ testAddGetClient b c
41
+ , test p " post /clients - 201 (pwd)" $ testAddGetClient True b c
42
+ , test p " post /clients - 201 (no pwd)" $ testAddGetClient False b c
42
43
, test p " post /clients - 403" $ testClientReauthentication b
43
44
, test p " get /clients - 200" $ testListClients b
44
45
, test p " get /clients/:client/prekeys - 200" $ testListPrekeyIds b
45
46
, test p " post /clients - 400" $ testTooManyClients b
46
- , test p " delete /clients/:client - 200" $ testRemoveClient b c
47
+ , test p " delete /clients/:client - 200 (pwd)" $ testRemoveClient True b c
48
+ -- , test p "delete /clients/:client - 200 (no pwd)" $ testRemoveClient False b c -- TODO: is there an easy way with phone user?
47
49
, test p " put /clients/:client - 200" $ testUpdateClient b
48
50
, test p " post /clients - 200 multiple temporary" $ testAddMultipleTemporary b g
49
51
, test p " client/prekeys/race" $ testPreKeyRace b
50
52
]
51
53
52
- testAddGetClient :: Brig -> Cannon -> Http ()
53
- testAddGetClient brig cannon = do
54
- uid <- userId <$> randomUser brig
54
+ testAddGetClient :: Bool -> Brig -> Cannon -> Http ()
55
+ testAddGetClient hasPwd brig cannon = do
56
+ uid <- userId <$> randomUser' hasPwd brig
55
57
let rq = addClientReq brig uid (defNewClient TemporaryClient [somePrekeys !! 0 ] (someLastPrekeys !! 0 ))
56
58
. header " X-Forwarded-For" " 127.0.0.1" -- Fake IP to test IpAddr parsing.
57
59
c <- WS. bracketR cannon uid $ \ ws -> do
@@ -182,9 +184,12 @@ testTooManyClients brig = do
182
184
const 403 === statusCode
183
185
const (Just " too-many-clients" ) === fmap Error. label . decodeBody
184
186
185
- testRemoveClient :: Brig -> Cannon -> Http ()
186
- testRemoveClient brig cannon = do
187
- u <- randomUser brig
187
+ testRemoveClient :: Bool -> Brig -> Cannon -> Http ()
188
+ testRemoveClient hasPwd brig cannon = do
189
+ unless hasPwd $ error
190
+ " not implemented: for password-less users, we need to figure out another way to login."
191
+
192
+ u <- randomUser' hasPwd brig
188
193
let uid = userId u
189
194
let Just email = userEmail u
190
195
@@ -194,12 +199,13 @@ testRemoveClient brig cannon = do
194
199
numCookies <- countCookies brig uid defCookieLabel
195
200
liftIO $ Just 1 @=? numCookies
196
201
c <- decodeBody =<< addClient brig uid (client PermanentClient (someLastPrekeys !! 10 ))
197
- -- Missing password
198
- deleteClient brig uid (clientId c) Nothing !!! const 403 === statusCode
202
+ when hasPwd $ do
203
+ -- Missing password
204
+ deleteClient brig uid (clientId c) Nothing !!! const 403 === statusCode
199
205
200
206
-- Success
201
207
WS. bracketR cannon uid $ \ ws -> do
202
- deleteClient brig uid (clientId c) (Just defPassword)
208
+ deleteClient brig uid (clientId c) (if hasPwd then Just defPassword else Nothing )
203
209
!!! const 200 === statusCode
204
210
void . liftIO $ WS. assertMatch (5 # Second ) ws $ \ n -> do
205
211
let j = Object $ List1. head (ntfPayload n)
0 commit comments