From 0ca4bdc049a695eea3bb6f6f08c1c33567da823a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Kukr=C3=A1l?= Date: Thu, 9 Nov 2017 14:38:17 +0100 Subject: [PATCH] read JWT_AUTH_HEADER_PREFIX in all functions --- kqueen/blueprints/api/test_user.py | 10 +++++++++- kqueen/conftest.py | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/kqueen/blueprints/api/test_user.py b/kqueen/blueprints/api/test_user.py index 6c8442d0..39aa36bd 100644 --- a/kqueen/blueprints/api/test_user.py +++ b/kqueen/blueprints/api/test_user.py @@ -1,9 +1,12 @@ from .test_crud import BaseTestCRUD from flask import url_for from kqueen.conftest import user +from kqueen.config import current_config import json +config = current_config() + class TestUserCRUD(BaseTestCRUD): def get_object(self): @@ -37,7 +40,12 @@ def get_auth_headers(self): data=json.dumps(data), content_type='application/json') - return {'Authorization': 'JWT {}'.format(response.json['access_token'])} + print(config) + + return {'Authorization': '{header_prefix} {token}'.format( + header_prefix=config.get('JWT_AUTH_HEADER_PREFIX'), + token=response.json['access_token'], + )} def test_whoami(self): url = url_for('api.user_whoami') diff --git a/kqueen/conftest.py b/kqueen/conftest.py index a108cf96..d38bc025 100644 --- a/kqueen/conftest.py +++ b/kqueen/conftest.py @@ -5,6 +5,7 @@ from kqueen.models import Provisioner from kqueen.models import User from kqueen.server import create_app +from kqueen.config import current_config import json import pytest @@ -12,6 +13,7 @@ import yaml config_file = 'config/test.py' +config = current_config() fake = Faker() @@ -78,7 +80,10 @@ def auth_header(client): data=json.dumps(data), content_type='application/json') - return {'Authorization': 'Bearer {}'.format(response.json['access_token'])} + return {'Authorization': '{token_prefix} {token}'.format( + token_prefix=config.get('JWT_AUTH_HEADER_PREFIX'), + token=response.json['access_token'], + )} @pytest.fixture