fix validation throwing 403 rather than 400; enable extra test
This commit is contained in:
parent
cea0e75b70
commit
fdf0472592
@ -6,10 +6,10 @@ import json
|
||||
def _validate(data, *args, **kwargs):
|
||||
for key in itertools.chain(args, kwargs.keys()):
|
||||
if not key in data:
|
||||
flask.abort(403, json.dumps({'error': 'missing parameter',
|
||||
flask.abort(400, json.dumps({'error': 'missing parameter',
|
||||
'param': key}))
|
||||
for key, val in kwargs.iteritems():
|
||||
flask.abort(403, json.dumps({'error': 'validation failed',
|
||||
flask.abort(400, json.dumps({'error': 'validation failed',
|
||||
'param': key}))
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ def json_must(*args, **kwargs):
|
||||
def unpack(func):
|
||||
def dejson(f, *iargs):
|
||||
if flask.request.headers.get('content-type', '') != "application/json":
|
||||
flask.abort(403, json.dumps({"error": "must be in JSON format"}))
|
||||
flask.abort(400, json.dumps({"error": "must be in JSON format"}))
|
||||
# todo -- parse_float was handled specially
|
||||
_validate(flask.request.json, *args, **kwargs)
|
||||
return func(*iargs)
|
||||
|
@ -96,8 +96,7 @@ class TestApi(test_interface.TestInterface):
|
||||
self.assertTrue(resp_json['tenants'][0]['generated'])
|
||||
self.assertEquals(resp_json['tenants'][0]['id'], 'tenant_id_0')
|
||||
|
||||
@unittest.skip
|
||||
def test_sales_raises_400(self):
|
||||
"""Assertion that 400 is being thrown if content is not json."""
|
||||
resp = self.app.post("/sales_order")
|
||||
resp = self.app.post("/sales_order", expect_errors=True)
|
||||
self.assertTrue(resp.status_int, 400)
|
||||
|
Loading…
x
Reference in New Issue
Block a user