@@ -229,17 +229,23 @@ def get_decode_key_1(claims, headers):
229229 decode_token (token )
230230
231231
232- def test_valid_aud (app , default_access_token ):
232+ @pytest .mark .parametrize ("token_aud" , ['foo' , ['bar' ], ['foo' , 'bar' , 'baz' ]])
233+ def test_valid_aud (app , default_access_token , token_aud ):
234+ app .config ['JWT_DECODE_AUDIENCE' ] = ['foo' , 'bar' ]
235+
236+ default_access_token ['aud' ] = token_aud
237+ invalid_token = encode_token (app , default_access_token )
238+ with app .test_request_context ():
239+ decoded = decode_token (invalid_token )
240+ assert decoded ['aud' ] == token_aud
241+
242+
243+ @pytest .mark .parametrize ("token_aud" , ['bar' , ['bar' ], ['bar' , 'baz' ]])
244+ def test_invalid_aud (app , default_access_token , token_aud ):
233245 app .config ['JWT_DECODE_AUDIENCE' ] = 'foo'
234246
235- default_access_token ['aud' ] = 'bar'
247+ default_access_token ['aud' ] = token_aud
236248 invalid_token = encode_token (app , default_access_token )
237249 with pytest .raises (InvalidAudienceError ):
238250 with app .test_request_context ():
239251 decode_token (invalid_token )
240-
241- default_access_token ['aud' ] = 'foo'
242- valid_token = encode_token (app , default_access_token )
243- with app .test_request_context ():
244- decoded = decode_token (valid_token )
245- assert decoded ['aud' ] == 'foo'
0 commit comments