mirror of
https://0xacab.org/jvoisin/mat2-web.git
synced 2025-05-12 11:12:17 -04:00
catch no bulk post body
This commit is contained in:
parent
5d1e6b3235
commit
2ba8d74fa7
2 changed files with 10 additions and 0 deletions
|
@ -106,6 +106,8 @@ class APIBulkDownloadCreator(Resource):
|
||||||
def post(self):
|
def post(self):
|
||||||
utils.check_upload_folder(current_app.config['UPLOAD_FOLDER'])
|
utils.check_upload_folder(current_app.config['UPLOAD_FOLDER'])
|
||||||
data = request.json
|
data = request.json
|
||||||
|
if not data:
|
||||||
|
abort(400, message="Post Body Required")
|
||||||
if not self.v.validate(data):
|
if not self.v.validate(data):
|
||||||
abort(400, message=self.v.errors)
|
abort(400, message=self.v.errors)
|
||||||
# prevent the zip file from being overwritten
|
# prevent the zip file from being overwritten
|
||||||
|
|
|
@ -263,6 +263,14 @@ class Mat2APITestCase(unittest.TestCase):
|
||||||
request = self.app.get(upload_two['download_link'])
|
request = self.app.get(upload_two['download_link'])
|
||||||
self.assertEqual(request.status_code, 404)
|
self.assertEqual(request.status_code, 404)
|
||||||
|
|
||||||
|
def test_api_bulk_empty_body(self):
|
||||||
|
request = self.app.post(
|
||||||
|
'/api/download/bulk',
|
||||||
|
)
|
||||||
|
self.assertEqual(400, request.status_code)
|
||||||
|
error_message = request.get_json()['message']
|
||||||
|
self.assertEqual("Post Body Required", error_message)
|
||||||
|
|
||||||
def test_api_bulk_download_validation(self):
|
def test_api_bulk_download_validation(self):
|
||||||
post_body = {
|
post_body = {
|
||||||
u'download_list': [
|
u'download_list': [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue