@@ -144,6 +144,15 @@ 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 (), certs = PUBLIC_CERT_BYTES , audience = ["audience@example.com" , "another_audience@example.com" ]
150+ )
151+ assert payload ["aud" ] == "audience@example.com"
152+ assert payload ["user" ] == "billy bob"
153+ assert payload ["metadata" ]["meta" ] == "data"
154+
155+
147156def test_decode_valid_unverified (token_factory ):
148157 payload = jwt .decode (token_factory (), certs = OTHER_CERT_BYTES , verify = False )
149158 assert payload ["aud" ] == "audience@example.com"
@@ -211,6 +220,14 @@ def test_decode_bad_token_wrong_audience(token_factory):
211220 assert excinfo .match (r"Token has wrong audience" )
212221
213222
223+ def test_decode_bad_token_wrong_audience_list (token_factory ):
224+ token = token_factory ()
225+ audience = ["audience2@example.com" , "audience3@example.com" ]
226+ with pytest .raises (ValueError ) as excinfo :
227+ jwt .decode (token , PUBLIC_CERT_BYTES , audience = audience )
228+ assert excinfo .match (r"Token has wrong audience" )
229+
230+
214231def test_decode_wrong_cert (token_factory ):
215232 with pytest .raises (ValueError ) as excinfo :
216233 jwt .decode (token_factory (), OTHER_CERT_BYTES )
0 commit comments