[lib.acl] fixes #20

This commit is contained in:
Maxime Alves LIRMM@home 2021-06-25 12:20:25 +02:00
parent 0c3aeb532f
commit bb50fae186
3 changed files with 18 additions and 3 deletions

View File

@ -51,14 +51,16 @@ def args_check(fct):
# Check query param should not read the "args" # Check query param should not read the "args"
return await fct(req, *args, **kwargs) return await fct(req, *args, **kwargs)
data_ = {}
if req.method == 'GET': if req.method == 'GET':
data_ = req.query_params data_ = req.query_params
if req.method == 'POST': if req.method in ['POST', 'PATCH', 'PUT', 'DELETE']:
try: try:
data_ = await req.json() data_ = await req.json()
except JSONDecodeError as exc: except JSONDecodeError as exc:
data_ = {} logger.debug('Posted data was not JSON')
pass
def plural(array: list) -> str: def plural(array: list) -> str:
return 's' if len(array) > 1 else '' return 's' if len(array) > 1 else ''

View File

@ -3,7 +3,8 @@ ACLS = {
'GET': [{'acl':acl.public}], 'GET': [{'acl':acl.public}],
'POST': [{'acl':acl.public}], 'POST': [{'acl':acl.public}],
'PATCH': [{'acl':acl.public}], 'PATCH': [{'acl':acl.public}],
'PUT': [{'acl':acl.public}] 'PUT': [{'acl':acl.public}],
'DELETE': [{'acl':acl.public}]
} }
def get(test): def get(test):
@ -17,3 +18,6 @@ def patch(test):
def put(test): def put(test):
return str(test) return str(test)
def delete(test):
return str(test)

View File

@ -39,3 +39,12 @@ def test_get_route(dummy_project, application_domain, routers):
if not path: if not path:
raise Exception('No route generated') raise Exception('No route generated')
def test_delete_route(dummy_project, application_domain, routers):
c = TestClient(application_domain)
from uuid import uuid4
arg = str(uuid4())
r = c.delete(f'/dummy_domain/abc/alphabet/{arg}')
assert r.status_code == 200
assert r.json() == arg