@@ -144,6 +144,17 @@ def test_decode_valid_with_audience(token_factory):
144144 assert payload ["metadata" ]["meta" ] == "data"
145145
146146
147+ def test_decode_valid_with_audience_list (token_factory ):
148+ payload = jwt .decode (
149+ token_factory (),
150+ certs = PUBLIC_CERT_BYTES ,
151+ audience = ["audience@example.com" , "another_audience@example.com" ],
152+ )
153+ assert payload ["aud" ] == "audience@example.com"
154+ assert payload ["user" ] == "billy bob"
155+ assert payload ["metadata" ]["meta" ] == "data"
156+
157+
147158def test_decode_valid_unverified (token_factory ):
148159 payload = jwt .decode (token_factory (), certs = OTHER_CERT_BYTES , verify = False )
149160 assert payload ["aud" ] == "audience@example.com"
@@ -211,6 +222,14 @@ def test_decode_bad_token_wrong_audience(token_factory):
211222 assert excinfo .match (r"Token has wrong audience" )
212223
213224
225+ def test_decode_bad_token_wrong_audience_list (token_factory ):
226+ token = token_factory ()
227+ audience = ["audience2@example.com" , "audience3@example.com" ]
228+ with pytest .raises (ValueError ) as excinfo :
229+ jwt .decode (token , PUBLIC_CERT_BYTES , audience = audience )
230+ assert excinfo .match (r"Token has wrong audience" )
231+
232+
214233def test_decode_wrong_cert (token_factory ):
215234 with pytest .raises (ValueError ) as excinfo :
216235 jwt .decode (token_factory (), OTHER_CERT_BYTES )
0 commit comments