[fix] important fix for argument handling

This commit is contained in:
Maxime Alves LIRMM@home 2022-09-05 10:18:57 +02:00
parent 039bc2c8fe
commit d0ec030ce9
2 changed files with 25 additions and 6 deletions

View File

@ -101,12 +101,12 @@ def args_check(fct):
for key in optional:
if key in data_:
data[key] = data_[key]
else:
""" Unsafe mode, without specified arguments, or plain text mode
"""
data = data_
else:
""" Unsafe mode, without specified arguments, or plain text mode
"""
data = data_
kwargs['data'] = data
kwargs['data'] = data
out_s = req.scope.get('out')
if out_s:

View File

@ -38,6 +38,10 @@ class TestDummyDomain(TestDomain):
assert res.headers['content-type'].split(';')[0] == 'text/html'
def test_arguments__get_routes(self):
res = self.client.post('/arguments?foo=1&x=3')
assert res.status_code == 400
arg_dict = {'foo': '1', 'bar': '2', 'x': '3'}
res = self.client.get('/arguments?foo=1&bar=2&x=3')
assert res.json() == arg_dict
@ -46,7 +50,22 @@ class TestDummyDomain(TestDomain):
assert res.json() == arg_dict
def test_arguments_post_routes(self):
arg_dict = {'foo': '1', 'bar': '2', 'baz': '3'}
arg_dict = {}
res = self.client.post('/arguments', arg_dict)
assert res.status_code == 400
arg_dict = {'foo': '1', 'bar': '3'}
res = self.client.post('/arguments', arg_dict)
assert res.status_code == 400
arg_dict = {'foo': '1', 'baz': '3'}
res = self.client.post('/arguments', arg_dict)
assert res.json() == arg_dict
arg_dict = {'foo': '1', 'baz': '3', 'truebidoo': '4'}
res = self.client.post('/arguments', arg_dict)
assert res.json() == arg_dict