DRY-up creating auth headers for requests

The rest of the tests need to construct the header directly so they
can pass custom tokens. But for the three tests that actually make
a request to prove the auth functions work as wrappers, we can use
the same factory functions we use everywhere else in the tests.
This commit is contained in:
Ben Thorner
2021-08-04 15:24:49 +01:00
parent 0312e2a528
commit 09e3ba6836
2 changed files with 17 additions and 15 deletions

View File

@@ -32,6 +32,10 @@ def create_service_authorization_header(service_id, key_type=KEY_TYPE_NORMAL):
def create_admin_authorization_header():
client_id = current_app.config['ADMIN_CLIENT_ID']
return create_internal_authorization_header(client_id)
def create_internal_authorization_header(client_id):
secret = current_app.config['INTERNAL_CLIENT_API_KEYS'][client_id][0]
token = create_jwt_token(secret=secret, client_id=client_id)
return 'Authorization', 'Bearer {}'.format(token)