File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -73,8 +73,8 @@ def _coerce_redirect_uris_to_any_url(cls, v: object) -> object:
7373 # Pydantic v2 keeps AnyUrl subclasses such as AnyHttpUrl as-is, while
7474 # AnyUrl equality is type-strict. Store the declared base type so later
7575 # redirect_uri membership checks compare URLs, not URL wrapper classes.
76- if isinstance (v , list | tuple ):
77- items = cast ("list[object] | tuple[object, ...]" , v )
76+ if isinstance (v , list | tuple | set | frozenset ):
77+ items = cast ("list[object] | tuple[object, ...] | set[object] | frozenset[object] " , v )
7878 return [str (item ) if isinstance (item , AnyUrl ) else item for item in items ]
7979 return v
8080
Original file line number Diff line number Diff line change 11"""Tests for OAuth 2.0 shared code."""
22
3+ from typing import Any
4+
35import pytest
46from pydantic import AnyHttpUrl , AnyUrl , ValidationError
57
@@ -130,10 +132,19 @@ def test_information_full_inherits_coercion():
130132 assert info .jwks_uri is None
131133
132134
133- def test_redirect_uris_normalize_any_url_subtypes ():
135+ @pytest .mark .parametrize (
136+ "redirect_uris" ,
137+ [
138+ [AnyHttpUrl ("https://example.com/callback" )],
139+ (AnyHttpUrl ("https://example.com/callback" ),),
140+ {AnyHttpUrl ("https://example.com/callback" )},
141+ frozenset ({AnyHttpUrl ("https://example.com/callback" )}),
142+ ],
143+ )
144+ def test_redirect_uris_normalize_any_url_subtypes (redirect_uris : Any ):
134145 info = OAuthClientInformationFull (
135146 client_id = "abc123" ,
136- redirect_uris = [ AnyHttpUrl ( "https://example.com/callback" )] ,
147+ redirect_uris = redirect_uris ,
137148 )
138149
139150 assert info .validate_redirect_uri (AnyUrl ("https://example.com/callback" )) == AnyUrl ("https://example.com/callback" )
You can’t perform that action at this time.
0 commit comments