[lib.acl] fixes #20
This commit is contained in:
parent
0c3aeb532f
commit
bb50fae186
|
@ -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 ''
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue