@@ -177,22 +177,27 @@ async def test_token_exchange_request_jwt(self, rfc7523_oauth_provider: RFC7523O
177177class TestClientCredentialsOAuthProvider :
178178 """Test ClientCredentialsOAuthProvider."""
179179
180- def test_init_sets_client_info (self , mock_storage : MockTokenStorage ):
181- """Test that constructor sets client_info directly."""
180+ @pytest .mark .anyio
181+ async def test_init_sets_client_info (self , mock_storage : MockTokenStorage ):
182+ """Test that _initialize sets client_info."""
182183 provider = ClientCredentialsOAuthProvider (
183184 server_url = "https://api.example.com" ,
184185 storage = mock_storage ,
185186 client_id = "test-client-id" ,
186187 client_secret = "test-client-secret" ,
187188 )
188189
190+ # client_info is set during _initialize
191+ await provider ._initialize ()
192+
189193 assert provider .context .client_info is not None
190194 assert provider .context .client_info .client_id == "test-client-id"
191195 assert provider .context .client_info .client_secret == "test-client-secret"
192196 assert provider .context .client_info .grant_types == ["client_credentials" ]
193197 assert provider .context .client_info .token_endpoint_auth_method == "client_secret_basic"
194198
195- def test_init_with_scopes (self , mock_storage : MockTokenStorage ):
199+ @pytest .mark .anyio
200+ async def test_init_with_scopes (self , mock_storage : MockTokenStorage ):
196201 """Test that constructor accepts scopes."""
197202 provider = ClientCredentialsOAuthProvider (
198203 server_url = "https://api.example.com" ,
@@ -202,9 +207,11 @@ def test_init_with_scopes(self, mock_storage: MockTokenStorage):
202207 scopes = "read write" ,
203208 )
204209
210+ await provider ._initialize ()
205211 assert provider .context .client_info .scope == "read write"
206212
207- def test_init_with_client_secret_post (self , mock_storage : MockTokenStorage ):
213+ @pytest .mark .anyio
214+ async def test_init_with_client_secret_post (self , mock_storage : MockTokenStorage ):
208215 """Test that constructor accepts client_secret_post auth method."""
209216 provider = ClientCredentialsOAuthProvider (
210217 server_url = "https://api.example.com" ,
@@ -214,6 +221,7 @@ def test_init_with_client_secret_post(self, mock_storage: MockTokenStorage):
214221 token_endpoint_auth_method = "client_secret_post" ,
215222 )
216223
224+ await provider ._initialize ()
217225 assert provider .context .client_info .token_endpoint_auth_method == "client_secret_post"
218226
219227 @pytest .mark .anyio
@@ -270,8 +278,9 @@ async def test_exchange_token_without_scopes(self, mock_storage: MockTokenStorag
270278class TestPrivateKeyJWTOAuthProvider :
271279 """Test PrivateKeyJWTOAuthProvider."""
272280
273- def test_init_sets_client_info (self , mock_storage : MockTokenStorage ):
274- """Test that constructor sets client_info directly."""
281+ @pytest .mark .anyio
282+ async def test_init_sets_client_info (self , mock_storage : MockTokenStorage ):
283+ """Test that _initialize sets client_info."""
275284
276285 async def mock_assertion_provider (audience : str ) -> str :
277286 return "mock-jwt"
@@ -283,6 +292,9 @@ async def mock_assertion_provider(audience: str) -> str:
283292 assertion_provider = mock_assertion_provider ,
284293 )
285294
295+ # client_info is set during _initialize
296+ await provider ._initialize ()
297+
286298 assert provider .context .client_info is not None
287299 assert provider .context .client_info .client_id == "test-client-id"
288300 assert provider .context .client_info .grant_types == ["client_credentials" ]
0 commit comments