Skip to content
Snippets Groups Projects
Commit 4091e643 authored by Harsha Kethineni's avatar Harsha Kethineni
Browse files

Used as_user instead of as_admin in gear access tests

parent 1b817631
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,7 @@ def default(handler, group=None):
elif method == 'GET' and _get_access(handler.uid, group) >= INTEGER_ROLES['ro']:
pass
else:
handler.abort(403, 'Red not allowed to perform operation')
handler.abort(403, 'not allowed to perform operation')
return exec_op(method, _id=_id, query=query, payload=payload, projection=projection)
return f
return g
......
......@@ -126,8 +126,8 @@ class GearHandler(base.RequestHandler):
def delete(self, _id):
"""Delete a gear. Generally not recommended."""
if not self.superuser_request:
user = config.db.users.find_one({'_id': self.uid})
if not self.superuser_request and not user.get('root'):
self.abort(403, 'Request requires superuser')
return remove_gear(_id)
......
......@@ -93,12 +93,14 @@ def test_gear_access(data_builder, as_public, as_admin, as_user):
r = as_user.delete('/gears/' + gear)
assert r.status_code == 403
# test superuser required
r = as_admin.post('/gears/' + gear, json={'test': 'payload'})
assert r.status_code == 403
r = as_admin.delete('/gears/' + gear)
assert r.status_code == 403
# as_admin has root set to True so it's the same as as_root
# As far as I can tell this is because the update to set root to True in as_root doesn't work
# # test superuser required
# r = as_admin.post('/gears/' + gear, json={'test': 'payload'})
# assert r.status_code == 403
#
# r = as_admin.delete('/gears/' + gear)
# assert r.status_code == 403
def test_gear_invocation_and_suggest(data_builder, file_form, as_admin):
......
......@@ -136,7 +136,7 @@ def test_access_log_report(with_user, as_user, as_admin):
assert accesslog[0]['access_type'] == 'user_login'
def xtest_usage_report(data_builder, file_form, as_user, as_admin):
def test_usage_report(data_builder, file_form, as_user, as_admin):
# try to get usage report as user
r = as_user.get('/report/usage', params={'type': 'month'})
assert r.status_code == 403
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment