module Test.AssetUpload where import API.BrigInternal import API.Cargohold import SetupHelpers import Testlib.Prelude testAssetUploadUnverifiedUser :: (HasCallStack) => App () testAssetUploadUnverifiedUser :: HasCallStack => App () testAssetUploadUnverifiedUser = do Value 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} App Response -> (Response -> App ()) -> App () forall a. HasCallStack => App Response -> (Response -> App a) -> App a bindResponse (Value -> App Response forall user. (HasCallStack, MakesValue user) => user -> App Response uploadAsset Value user) ((Response -> App ()) -> App ()) -> (Response -> App ()) -> App () forall a b. (a -> b) -> a -> b $ \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 Value user <- Domain -> CreateUser -> App Value forall domain. (HasCallStack, MakesValue domain) => domain -> CreateUser -> App Value randomUser Domain OwnDomain CreateUser forall a. Default a => a def App Response -> (Response -> App ()) -> App () forall a. HasCallStack => App Response -> (Response -> App a) -> App a bindResponse (Value -> App Response forall user. (HasCallStack, MakesValue user) => user -> App Response uploadAsset Value user) ((Response -> App ()) -> App ()) -> (Response -> App ()) -> App () forall a b. (a -> b) -> a -> b $ \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 String uid <- App String HasCallStack => App String randomId Value domain <- Domain -> App Value forall a. (MakesValue a, HasCallStack) => a -> App Value make Domain OwnDomain let user :: Value 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 ] ] App Response -> (Response -> App ()) -> App () forall a. HasCallStack => App Response -> (Response -> App a) -> App a bindResponse (Value -> App Response forall user. (HasCallStack, MakesValue user) => user -> App Response uploadAsset Value user) ((Response -> App ()) -> App ()) -> (Response -> App ()) -> App () forall a b. (a -> b) -> a -> b $ \Response resp -> do Response resp.status Int -> Int -> App () forall a. (MakesValue a, HasCallStack) => a -> Int -> App () `shouldMatchInt` Int 403