File tree 2 files changed +10
-1
lines changed
2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ def _decode_jwt_from_headers():
188
188
if header_type :
189
189
field_values = split (r',\s*' , auth_header )
190
190
jwt_header = [s for s in field_values if s .split ()[0 ] == header_type ]
191
- if len (jwt_header ) < 1 :
191
+ if len (jwt_header ) < 1 or len ( jwt_header [ 0 ]. split ()) != 2 :
192
192
msg = "Bad {} header. Expected value '{} <JWT>'" .format (
193
193
header_name ,
194
194
header_type
Original file line number Diff line number Diff line change @@ -151,6 +151,15 @@ def custom_response(err_str):
151
151
assert response .get_json () == {'foo' : "bar" }
152
152
153
153
154
+ def test_header_without_jwt (app ):
155
+ jwtM = get_jwt_manager (app )
156
+ test_client = app .test_client ()
157
+
158
+ access_headers = {'Authorization' : 'Bearer ' }
159
+ response = test_client .get ('/protected' , headers = access_headers )
160
+ assert response .status_code == 422
161
+ assert response .get_json () == {'msg' : "Bad Authorization header. Expected value 'Bearer <JWT>'" }
162
+
154
163
def test_custom_error_msg_key (app ):
155
164
app .config ['JWT_ERROR_MESSAGE_KEY' ] = 'message'
156
165
response = app .test_client ().get ('/protected' , headers = None )
You can’t perform that action at this time.
0 commit comments