fixed scope test attr error for older_requirements.txt test

This commit is contained in:
IvanaH8
2020-12-09 14:50:50 +01:00
parent f9a3eec147
commit 9de9070641
2 changed files with 8 additions and 2 deletions

View File

@@ -217,7 +217,7 @@ def switch_default_role(db, obj, kind, admin):
def update_roles(db, obj, kind, roles=None): def update_roles(db, obj, kind, roles=None):
"""Updates object's roles if specified, """Updates object's roles if specified,
assigns default if no roles specified""" assigns default if no roles specified"""
Class = get_orm_class(kind) Class = get_orm_class(kind)
user_role = orm.Role.find(db, 'user') user_role = orm.Role.find(db, 'user')

View File

@@ -406,9 +406,15 @@ def needs_scope(scope):
if check_scope(self, scope, parsed_scopes, **s_kwargs): if check_scope(self, scope, parsed_scopes, **s_kwargs):
return func(self, *args, **kwargs) return func(self, *args, **kwargs)
else: else:
# catching attr error occurring for older_requirements test
# could be done more ellegantly?
try:
request_path = self.request.path
except AttributeError:
request_path = 'the requested API'
app_log.warning( app_log.warning(
"Not authorizing access to {}. Requires scope {}, not derived from scopes {}".format( "Not authorizing access to {}. Requires scope {}, not derived from scopes {}".format(
self.request.path, scope, ", ".join(self.scopes) request_path, scope, ", ".join(self.scopes)
) )
) )
raise web.HTTPError( raise web.HTTPError(