88
99from jwt import (
1010 ExpiredSignatureError , InvalidSignatureError , InvalidAudienceError ,
11- ImmatureSignatureError
11+ ImmatureSignatureError , InvalidIssuerError
1212)
1313
1414from flask_jwt_extended import (
@@ -246,9 +246,9 @@ def test_valid_aud(app, default_access_token, token_aud):
246246 app .config ['JWT_DECODE_AUDIENCE' ] = ['foo' , 'bar' ]
247247
248248 default_access_token ['aud' ] = token_aud
249- invalid_token = encode_token (app , default_access_token )
249+ valid_token = encode_token (app , default_access_token )
250250 with app .test_request_context ():
251- decoded = decode_token (invalid_token )
251+ decoded = decode_token (valid_token )
252252 assert decoded ['aud' ] == token_aud
253253
254254
@@ -261,3 +261,21 @@ def test_invalid_aud(app, default_access_token, token_aud):
261261 with pytest .raises (InvalidAudienceError ):
262262 with app .test_request_context ():
263263 decode_token (invalid_token )
264+
265+ def test_valid_iss (app , default_access_token ):
266+ app .config ['JWT_DECODE_ISSUER' ] = 'foobar'
267+
268+ default_access_token ['iss' ] = 'foobar'
269+ valid_token = encode_token (app , default_access_token )
270+ with app .test_request_context ():
271+ decoded = decode_token (valid_token )
272+ assert decoded ['iss' ] == 'foobar'
273+
274+ def test_invalid_iss (app , default_access_token ):
275+ app .config ['JWT_DECODE_ISSUER' ] = 'baz'
276+
277+ default_access_token ['iss' ] = 'foobar'
278+ invalid_token = encode_token (app , default_access_token )
279+ with pytest .raises (InvalidIssuerError ):
280+ with app .test_request_context ():
281+ decode_token (invalid_token )
0 commit comments