@@ -107,7 +107,7 @@ async def test_register_enabled_unauthenticated_allows_public_clients(
107107
108108
109109@pytest .mark .asyncio
110- async def test_register_enabled_unauthenticated_rejects_confidential_clients (
110+ async def test_register_enabled_unauthenticated_allows_omitted_auth_method (
111111 belgie_instance ,
112112 oauth_settings : OAuthServer ,
113113) -> None :
@@ -127,6 +127,34 @@ async def test_register_enabled_unauthenticated_rejects_confidential_clients(
127127 },
128128 )
129129
130+ assert response .status_code == 200
131+ payload = response .json ()
132+ assert payload ["client_secret" ] is not None
133+ assert payload ["token_endpoint_auth_method" ] == "client_secret_post" # noqa: S105
134+
135+
136+ @pytest .mark .asyncio
137+ async def test_register_enabled_unauthenticated_rejects_explicit_confidential_clients (
138+ belgie_instance ,
139+ oauth_settings : OAuthServer ,
140+ ) -> None :
141+ settings_payload = oauth_settings .model_dump (mode = "python" )
142+ settings_payload ["allow_dynamic_client_registration" ] = True
143+ settings_payload ["allow_unauthenticated_client_registration" ] = True
144+ settings = OAuthServer (** settings_payload )
145+ belgie_instance .add_plugin (settings )
146+ app = FastAPI ()
147+ app .include_router (belgie_instance .router )
148+ transport = httpx .ASGITransport (app = app )
149+ async with httpx .AsyncClient (transport = transport , base_url = "http://testserver" ) as client :
150+ response = await client .post (
151+ "/auth/oauth/register" ,
152+ json = {
153+ "redirect_uris" : ["http://testserver/callback" ],
154+ "token_endpoint_auth_method" : "client_secret_post" ,
155+ },
156+ )
157+
130158 assert response .status_code == 401
131159 payload = response .json ()
132160 assert payload ["error" ] == "invalid_request"
0 commit comments