Skip to content

Commit

Permalink
Fix pep8 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Croug committed Sep 10, 2019
1 parent cb437ba commit 2fc098e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion flask_jwt_extended/view_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def _decode_jwt_from_headers():
# <HeaderName>: <field> <value>, <field> <value>, etc...
if header_type:
field_values = split(r',\s*', auth_header)
jwt_header = [s for s in field_values if s.split()[0]==header_type]
jwt_header = [s for s in field_values if s.split()[0] == header_type]
if len(jwt_header) < 1:
msg = "Bad {} header. Expected value '{} <JWT>'".format(
header_name,
Expand Down Expand Up @@ -310,3 +310,4 @@ def _decode_jwt_from_request(request_type):
verify_token_type(decoded_token, expected_type=request_type)
verify_token_not_blacklisted(decoded_token, request_type)
return decoded_token

14 changes: 7 additions & 7 deletions tests/test_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_default_headers(app):

with app.test_request_context():
access_token = create_access_token('username')

# Ensure other authorization types don't work
access_headers = {'Authorization': 'Basic basiccreds'}
response = test_client.get('/protected', headers=access_headers)
Expand All @@ -40,13 +40,13 @@ def test_default_headers(app):
assert response.get_json() == {'foo': 'bar'}

# Ensure default headers work with multiple field values
access_headers = {'Authorization': 'Bearer {}, Basic randomcredshere'.format(access_token)}
access_headers = {'Authorization': 'Bearer {}, Basic creds'.format(access_token)}
response = test_client.get('/protected', headers=access_headers)
assert response.status_code == 200
assert response.get_json() == {'foo': 'bar'}

# Ensure default headers work with multiple field values in any position
access_headers = {'Authorization': 'Basic randomcredshere, Bearer {}'.format(access_token)}
access_headers = {'Authorization': 'Basic creds, Bearer {}'.format(access_token)}
response = test_client.get('/protected', headers=access_headers)
assert response.status_code == 200
assert response.get_json() == {'foo': 'bar'}
Expand All @@ -58,7 +58,7 @@ def test_custom_header_name(app):

with app.test_request_context():
access_token = create_access_token('username')

# Insure 'default' headers no longer work
access_headers = {'Authorization': 'Bearer {}'.format(access_token)}
response = test_client.get('/protected', headers=access_headers)
Expand Down Expand Up @@ -103,15 +103,15 @@ def test_custom_header_type(app):
response = test_client.get('/protected', headers=access_headers)
assert response.status_code == 200
assert response.get_json() == {'foo': 'bar'}

# Ensure new headers work with multiple field values
access_headers = {'Authorization': 'JWT {}, Basic randomcredshere'.format(access_token)}
access_headers = {'Authorization': 'JWT {}, Basic creds'.format(access_token)}
response = test_client.get('/protected', headers=access_headers)
assert response.status_code == 200
assert response.get_json() == {'foo': 'bar'}

# Ensure new headers work with multiple field values in any position
access_headers = {'Authorization': 'Basic randomcredshere, JWT {}'.format(access_token)}
access_headers = {'Authorization': 'Basic creds, JWT {}'.format(access_token)}
response = test_client.get('/protected', headers=access_headers)
assert response.status_code == 200
assert response.get_json() == {'foo': 'bar'}
Expand Down

0 comments on commit 2fc098e

Please sign in to comment.