Skip to content

Commit

Permalink
maintenance update
Browse files Browse the repository at this point in the history
  • Loading branch information
thingsplode committed Mar 16, 2020
1 parent 073fad8 commit bc154c7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion appkernel/infrastructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, cfg_dir, config_file_name='cfg.yml', optional=False):
self.cfg = yaml.load(ymlfile)
self.initialised = True
except yaml.scanner.ScannerError as se:
raise AppInitialisationError('cannot read configuration file due to: {}'.format(config_file))
raise AppInitialisationError(f'cannot read config file {config_file} due to: {str(se)}')

def get(self, path_expression, default_value=None):
"""
Expand Down
4 changes: 2 additions & 2 deletions appkernel/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,14 +562,14 @@ def _autobox_parameters(provisioner_method, arguments):
arguments[arg_key] = result
else:
arguments[arg_key] = [result]
except ValueError as verr:
except ValueError:
# skip boxing
pass
elif issubclass(required_type, dict) and provided_type in [str, str, str]:
# if the required type is dict, but provided string
try:
arguments[arg_key] = json.loads(arg_value)
except ValueError as verr:
except ValueError:
# skip boxing
pass
else:
Expand Down
12 changes: 6 additions & 6 deletions tests/test_rbac.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,19 @@ def test_auth_basic_deny_without_token(client):
user = default_config()
headers = Headers()
headers.add('X-Tenant', 'rockee')
rsp = client.get('/users/{}'.format(user.id), headers=headers)
#print('\nResponse: {} -> {}'.format(rsp.status, rsp.data.decode()))
#assert rsp.status_code == 401, 'should be unauthorized'
#assert rsp.json.get('message') == 'The authorisation header is missing.'
rsp = client.get(f'/users/{user.id}', headers=headers)
print(f'\nResponse: {rsp.status} -> {rsp.data.decode()}')
# assert rsp.status_code == 401, 'should be unauthorized'
# assert rsp.json.get('message') == 'The authorisation header is missing.'


def test_auth_basic_garbage_token(client):
user = default_config()
headers = Headers()
user.update(roles=['user', 'admin'])
headers.add('Authorization', 'Bearer {}'.format('eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.'))
rsp = client.get('/users/{}'.format(user.id), headers=headers)
print('\nResponse: {} -> {}'.format(rsp.status, rsp.data.decode()))
rsp = client.get('/users/{user.id}', headers=headers)
print(f'\nResponse: {rsp.status} -> {rsp.data.decode()}')
assert rsp.status_code == 403, 'should be forbidden'
assert rsp.json.get('message') == 'Not enough segments'

Expand Down

0 comments on commit bc154c7

Please sign in to comment.