@@ -939,19 +939,35 @@ async def test_client_registration_default_scopes(
939939 assert registered_client .scope == "read write"
940940
941941 @pytest .mark .anyio
942- async def test_client_registration_invalid_grant_type (self , test_client : httpx .AsyncClient ):
942+ async def test_client_registration_with_authorization_code_only (self , test_client : httpx .AsyncClient ):
943+ """Test that registration succeeds with only authorization_code (refresh_token is optional per RFC 7591)."""
943944 client_metadata = {
944945 "redirect_uris" : ["https://client.example.com/callback" ],
945946 "client_name" : "Test Client" ,
946947 "grant_types" : ["authorization_code" ],
947948 }
948949
950+ response = await test_client .post ("/register" , json = client_metadata )
951+ assert response .status_code == 201
952+ client_info = response .json ()
953+ assert "client_id" in client_info
954+ assert client_info ["grant_types" ] == ["authorization_code" ]
955+
956+ @pytest .mark .anyio
957+ async def test_client_registration_missing_authorization_code (self , test_client : httpx .AsyncClient ):
958+ """Test that registration fails when authorization_code grant type is missing."""
959+ client_metadata = {
960+ "redirect_uris" : ["https://client.example.com/callback" ],
961+ "client_name" : "Test Client" ,
962+ "grant_types" : ["refresh_token" ],
963+ }
964+
949965 response = await test_client .post ("/register" , json = client_metadata )
950966 assert response .status_code == 400
951967 error_data = response .json ()
952968 assert "error" in error_data
953969 assert error_data ["error" ] == "invalid_client_metadata"
954- assert error_data ["error_description" ] == "grant_types must be authorization_code and refresh_token "
970+ assert error_data ["error_description" ] == "grant_types must include ' authorization_code' "
955971
956972 @pytest .mark .anyio
957973 async def test_client_registration_with_additional_grant_type (self , test_client : httpx .AsyncClient ):
0 commit comments