@@ -2005,6 +2005,8 @@ class TestWWWAuthenticate:
20052005 ),
20062006 # Multiple parameters with unquoted value
20072007 ('Bearer realm="api", scope=basic' , "scope" , "basic" ),
2008+ ("Bearer scope= read" , "scope" , "read" ),
2009+ ('Bearer =bad, scope="read"' , "scope" , "read" ),
20082010 # Decoy parameter name before the real field
20092011 ('Bearer error_scope="decoy", scope="read write"' , "scope" , "read write" ),
20102012 ('Bearer error_description="missing scope=wrong", scope="read write"' , "scope" , "read write" ),
@@ -2026,6 +2028,7 @@ class TestWWWAuthenticate:
20262028 "scope" ,
20272029 "resource:read resource:write user_profile" ,
20282030 ),
2031+ ('Bearer scope="say \\ "hi\\ ""' , "scope" , 'say "hi"' ),
20292032 (
20302033 'Bearer resource_metadata="https://api.example.com/auth/metadata?version=1"' ,
20312034 "resource_metadata" ,
@@ -2076,6 +2079,9 @@ def test_extract_field_from_www_auth_valid_cases(
20762079 ),
20772080 # Malformed field (empty value)
20782081 ("Bearer scope=" , "scope" , "malformed scope parameter" ),
2082+ ("Bearer scope= " , "scope" , "malformed scope parameter with only whitespace" ),
2083+ ("Bearer scope=," , "scope" , "malformed scope parameter with delimiter" ),
2084+ ('Bearer scope="unterminated' , "scope" , "unterminated quoted scope parameter" ),
20792085 ("Bearer resource_metadata=" , "resource_metadata" , "malformed resource_metadata parameter" ),
20802086 ],
20812087 )
0 commit comments