Skip to content

Commit

Permalink
read JWT_AUTH_HEADER_PREFIX in all functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkukral committed Nov 9, 2017
1 parent 611cb9c commit 0ca4bdc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 9 additions & 1 deletion kqueen/blueprints/api/test_user.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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')
Expand Down
7 changes: 6 additions & 1 deletion kqueen/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
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
import uuid
import yaml

config_file = 'config/test.py'
config = current_config()
fake = Faker()


Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0ca4bdc

Please sign in to comment.