0001-api-add-basic-format-check-for-submit-API-64328.patch
tests/api/test_carddef.py | ||
---|---|---|
748 | 748 |
) |
749 | 749 |
assert resp.json['data']['url'] |
750 | 750 | |
751 |
# check some invalid content |
|
752 |
resp = post_json_url('/api/cards/test/submit', {'data': None}, status=400) |
|
753 |
resp = post_json_url('/api/cards/test/submit', {'data': 'foobar'}, status=400) |
|
754 |
resp = post_json_url('/api/cards/test/submit', {'data': []}, status=400) |
|
755 | ||
751 | 756 | |
752 | 757 |
def test_carddef_submit_with_varname(pub, local_user): |
753 | 758 |
NamedDataSource.wipe() |
tests/api/test_formdef.py | ||
---|---|---|
677 | 677 |
assert data_class.get(resp.json['data']['id']).submission_context == {'comments': 'blah'} |
678 | 678 |
assert data_class.get(resp.json['data']['id']).submission_channel == 'mail' |
679 | 679 | |
680 |
# check some invalid content |
|
681 |
resp = post_json_url('/api/formdefs/test/submit', params={'data': None}, status=400) |
|
682 |
resp = post_json_url('/api/formdefs/test/submit', params={'data': 'foobar'}, status=400) |
|
683 |
resp = post_json_url('/api/formdefs/test/submit', params={'data': []}, status=400) |
|
684 | ||
680 | 685 |
data_class.wipe() |
681 | 686 | |
682 | 687 |
wcs/api.py | ||
---|---|---|
335 | 335 |
else: |
336 | 336 |
data = {} |
337 | 337 | |
338 |
if not isinstance(data, dict): |
|
339 |
raise RequestError('invalid data parameter') |
|
340 | ||
338 | 341 |
formdata.data = posted_json_data_to_formdata_data(self.formdef, data) |
339 | 342 | |
340 | 343 |
if 'user' in json_input: |
... | ... | |
582 | 585 |
else: |
583 | 586 |
data = {} |
584 | 587 | |
588 |
if not isinstance(data, dict): |
|
589 |
raise RequestError('invalid data parameter') |
|
590 | ||
585 | 591 |
formdata.data = posted_json_data_to_formdata_data(self.formdef, data) |
586 | 592 | |
587 | 593 |
meta = json_input.get('meta') or {} |
588 |
- |