module Test.TOTP.VersionGate where
import SetupHelpers
import Test.TOTP.Helpers (credentialIdPlaceholder)
import Testlib.Prelude
testTotpNotOnV18 :: (HasCallStack) => App ()
testTotpNotOnV18 :: HasCallStack => App ()
testTotpNotOnV18 = 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
let routes =
[ (String
"POST", String
"/self/totp"),
(String
"GET", String
"/self/totp"),
(String
"POST", String
"/self/totp/" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
credentialIdPlaceholder String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"/activate"),
(String
"PUT", String
"/self/totp/" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
credentialIdPlaceholder),
(String
"DELETE", String
"/self/totp/" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
credentialIdPlaceholder)
]
for_ routes $ \(String
method, String
path) -> do
req <- Value -> Service -> Versioned -> String -> App Request
forall user.
(HasCallStack, MakesValue user) =>
user -> Service -> Versioned -> String -> App Request
baseRequest Value
alice Service
Brig (Int -> Versioned
ExplicitVersion Int
18) String
path
bindResponse (submit method (req & addJSONObject ["name" .= ("work phone" :: String)])) $ \Response
resp ->
Response
resp.status Int -> [Value] -> App ()
forall a b.
(MakesValue a, MakesValue b, HasCallStack) =>
a -> b -> App ()
`shouldMatchOneOf` [Scientific -> Value
Number Scientific
404, Scientific -> Value
Number Scientific
405]