module Test.MLS.Clients where
import qualified API.BrigInternal as I
import MLS.Util
import SetupHelpers
import Testlib.Prelude
testGetMLSClients :: (HasCallStack) => App ()
testGetMLSClients :: HasCallStack => App ()
testGetMLSClients = do
alice <- Domain -> CreateUser -> App Value
forall domain.
(HasCallStack, MakesValue domain) =>
domain -> CreateUser -> App Value
randomUser Domain
OwnDomain CreateUser
forall a. Default a => a
def
alice1 <- createWireClient alice def
bindResponse (I.getMLSClients alice def) $ \Response
resp -> do
Response
resp.status Int -> Int -> App ()
forall a. (MakesValue a, HasCallStack) => a -> Int -> App ()
`shouldMatchInt` Int
200
cs <- Response
resp.json App Value -> (App Value -> App [Value]) -> App [Value]
forall a b. a -> (a -> b) -> b
& App Value -> App [Value]
forall a. (HasCallStack, MakesValue a) => a -> App [Value]
asList
c <- assertOne cs
c
`shouldMatch` object
[ "mls" .= False,
"id" .= alice1.client
]
keys <- initMLSClient def alice1
ss <- keys %. csSignatureScheme def
bindResponse (I.getMLSClients alice def) $ \Response
resp -> do
Response
resp.status Int -> Int -> App ()
forall a. (MakesValue a, HasCallStack) => a -> Int -> App ()
`shouldMatchInt` Int
200
cs <- Response
resp.json App Value -> (App Value -> App [Value]) -> App [Value]
forall a b. a -> (a -> b) -> b
& App Value -> App [Value]
forall a. (HasCallStack, MakesValue a) => a -> App [Value]
asList
c <- assertOne cs
c
`shouldMatch` object
[ "mls" .= False,
"id" .= alice1.client,
"mls_signature_key" .= ss
]
void $ uploadNewKeyPackage def alice1
bindResponse (I.getMLSClients alice def) $ \Response
resp -> do
Response
resp.status Int -> Int -> App ()
forall a. (MakesValue a, HasCallStack) => a -> Int -> App ()
`shouldMatchInt` Int
200
cs <- Response
resp.json App Value -> (App Value -> App [Value]) -> App [Value]
forall a b. a -> (a -> b) -> b
& App Value -> App [Value]
forall a. (HasCallStack, MakesValue a) => a -> App [Value]
asList
c <- assertOne cs
c
`shouldMatch` object
[ "mls" .= True,
"id" .= alice1.client,
"mls_signature_key" .= ss
]