module Test.Cargohold.AssetUpload where
import API.BrigInternal
import API.Cargohold
import SetupHelpers
import Testlib.Prelude
testAssetUploadUnverifiedUser :: (HasCallStack) => App ()
testAssetUploadUnverifiedUser :: HasCallStack => App ()
testAssetUploadUnverifiedUser = do
user <- Domain -> CreateUser -> App Value
forall domain.
(HasCallStack, MakesValue domain) =>
domain -> CreateUser -> App Value
randomUser Domain
OwnDomain (CreateUser -> App Value) -> CreateUser -> App Value
forall a b. (a -> b) -> a -> b
$ CreateUser
forall a. Default a => a
def {activate = False}
bindResponse (uploadSomeAsset user) $ \Response
resp -> do
Response
resp.status Int -> Int -> App ()
forall a. (MakesValue a, HasCallStack) => a -> Int -> App ()
`shouldMatchInt` Int
403
testAssetUploadVerifiedUser :: (HasCallStack) => App ()
testAssetUploadVerifiedUser :: HasCallStack => App ()
testAssetUploadVerifiedUser = do
user <- Domain -> CreateUser -> App Value
forall domain.
(HasCallStack, MakesValue domain) =>
domain -> CreateUser -> App Value
randomUser Domain
OwnDomain CreateUser
forall a. Default a => a
def
bindResponse (uploadSomeAsset user) $ \Response
resp -> do
Response
resp.status Int -> Int -> App ()
forall a. (MakesValue a, HasCallStack) => a -> Int -> App ()
`shouldMatchInt` Int
201
testAssetUploadUnknownUser :: (HasCallStack) => App ()
testAssetUploadUnknownUser :: HasCallStack => App ()
testAssetUploadUnknownUser = do
uid <- App String
HasCallStack => App String
randomId
domain <- make OwnDomain
let user =
[Pair] -> Value
object
[ String
"id" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= String
uid,
String
"qualified_id"
String -> Value -> Pair
forall a. ToJSON a => String -> a -> Pair
.= [Pair] -> Value
object
[ String
"domain" String -> Value -> Pair
forall a. ToJSON a => String -> a -> Pair
.= Value
domain,
String
"id" String -> String -> Pair
forall a. ToJSON a => String -> a -> Pair
.= String
uid
]
]
bindResponse (uploadSomeAsset user) $ \Response
resp -> do
Response
resp.status Int -> Int -> App ()
forall a. (MakesValue a, HasCallStack) => a -> Int -> App ()
`shouldMatchInt` Int
403