module Test.TOTP.Login where
import qualified API.Brig as Brig
import API.Common (defPassword)
import SetupHelpers
import Test.TOTP.MockBodies
import Testlib.Prelude
testLoginWithValidTotpCode :: (HasCallStack) => App ()
testLoginWithValidTotpCode :: HasCallStack => App ()
testLoginWithValidTotpCode = 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
email <- asString (alice %. "email")
Brig.loginWithTotp alice email defPassword mockLoginTotpCode >>= assertStatus 200
testLoginWithInvalidTotpCode :: (HasCallStack) => App ()
testLoginWithInvalidTotpCode :: HasCallStack => App ()
testLoginWithInvalidTotpCode = 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
email <- asString (alice %. "email")
req <- baseRequest alice Brig Versioned "login"
submit
"POST"
( req
& addJSONObject ["email" .= email, "password" .= defPassword, "totp_code" .= ("not-a-valid-totp-code" :: String)]
& addQueryParams [("persist", "true")]
)
>>= assertStatus 400