Skip to content

Commit 4ae72e5

Browse files
committed
Adapt to new version of crypto-cli
1 parent ca4aa74 commit 4ae72e5

File tree

1 file changed

+25
-17
lines changed
  • services/brig/test/integration/API

1 file changed

+25
-17
lines changed

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

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Imports
1414
import System.Process
1515
import Test.Tasty
1616
import Test.Tasty.HUnit
17+
import UnliftIO.Temporary
1718
import Util
1819
import Wire.API.MLS.KeyPackage
1920
import Wire.API.User
@@ -31,8 +32,9 @@ tests m b _opts =
3132
testKeyPackageUpload :: Brig -> Http ()
3233
testKeyPackageUpload brig = do
3334
u <- userQualifiedId <$> randomUser brig
34-
c <- randomClient
35-
uploadKeyPackages brig u c 5
35+
c <- createClient brig u 0
36+
withSystemTempFile "store.db" $ \store _ ->
37+
uploadKeyPackages brig store u c 5
3638

3739
count :: KeyPackageCount <-
3840
responseJsonError
@@ -61,16 +63,10 @@ testKeyPackageClaim brig = do
6163
-- setup a user u with two clients c1 and c2
6264
u <- userQualifiedId <$> randomUser brig
6365
[c1, c2] <- for [0, 1] $ \i -> do
64-
c <-
65-
fmap clientId $
66-
responseJsonError
67-
=<< addClient
68-
brig
69-
(qUnqualified u)
70-
(defNewClient PermanentClientType [somePrekeys !! i] (someLastPrekeys !! i))
71-
<!! const 201 === statusCode
66+
c <- createClient brig u i
7267
-- upload 5 key packages for each client
73-
uploadKeyPackages brig u c 5
68+
withSystemTempFile "store.db" $ \store _ ->
69+
uploadKeyPackages brig store u c 5
7470
pure c
7571

7672
-- claim packages for both clients of u
@@ -98,16 +94,28 @@ testKeyPackageClaim brig = do
9894

9995
--------------------------------------------------------------------------------
10096

101-
uploadKeyPackages :: Brig -> Qualified UserId -> ClientId -> Int -> Http ()
102-
uploadKeyPackages brig u c n = do
103-
let cmd =
104-
"crypto-cli key-package "
105-
<> show (qUnqualified u)
97+
createClient :: Brig -> Qualified UserId -> Int -> Http ClientId
98+
createClient brig u i =
99+
fmap clientId $
100+
responseJsonError
101+
=<< addClient
102+
brig
103+
(qUnqualified u)
104+
(defNewClient PermanentClientType [somePrekeys !! i] (someLastPrekeys !! i))
105+
<!! const 201 === statusCode
106+
107+
uploadKeyPackages :: Brig -> FilePath -> Qualified UserId -> ClientId -> Int -> Http ()
108+
uploadKeyPackages brig store u c n = do
109+
let cmd0 = ["crypto-cli", "--store", store, "--enc-key", "test"]
110+
clientId =
111+
show (qUnqualified u)
106112
<> ":"
107113
<> T.unpack (client c)
108114
<> "@"
109115
<> T.unpack (domainText (qDomain u))
110-
kps <- replicateM n . liftIO . fmap (KeyPackageData . LBS.fromStrict) . spawn $ shell cmd
116+
kps <-
117+
replicateM n . liftIO . fmap (KeyPackageData . LBS.fromStrict) . spawn . shell . unwords $
118+
cmd0 <> ["key-package", clientId]
111119
let upload = KeyPackageUpload kps
112120
post
113121
( brig

0 commit comments

Comments
 (0)