diff --git a/halfapi/lib/acl.py b/halfapi/lib/acl.py index ba507e9..82ab900 100644 --- a/halfapi/lib/acl.py +++ b/halfapi/lib/acl.py @@ -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: diff --git a/tests/test_domain.py b/tests/test_domain.py index 1c873bb..68b627b 100644 --- a/tests/test_domain.py +++ b/tests/test_domain.py @@ -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