@@ -377,12 +377,12 @@ async def test_exchange_id_jag_for_access_token_success(sample_id_jag: str, mock
377377
378378 # Parse the request body
379379 import urllib .parse
380+
380381 body_params = urllib .parse .parse_qs (request .content .decode ())
381382 assert body_params ["grant_type" ][0 ] == "urn:ietf:params:oauth:grant-type:jwt-bearer"
382383 assert body_params ["assertion" ][0 ] == sample_id_jag
383384
384385
385-
386386@pytest .mark .anyio
387387async def test_exchange_id_jag_for_access_token_no_metadata (sample_id_jag : str , mock_token_storage : Any ):
388388 """Test JWT bearer grant fails without OAuth metadata."""
@@ -464,6 +464,7 @@ async def test_perform_authorization_full_flow(mock_token_storage: Any, sample_i
464464
465465 # Verify the request contains JWT bearer grant
466466 import urllib .parse
467+
467468 body_params = urllib .parse .parse_qs (request .content .decode ())
468469 assert body_params ["grant_type" ][0 ] == "urn:ietf:params:oauth:grant-type:jwt-bearer"
469470 assert body_params ["assertion" ][0 ] == sample_id_jag
@@ -514,6 +515,7 @@ async def test_perform_authorization_with_valid_tokens(mock_token_storage: Any,
514515
515516 # Verify it uses the cached ID-JAG
516517 import urllib .parse
518+
517519 body_params = urllib .parse .parse_qs (request .content .decode ())
518520 assert body_params ["assertion" ][0 ] == sample_id_jag
519521
@@ -786,14 +788,14 @@ async def test_exchange_id_jag_with_client_authentication(sample_id_jag: str, mo
786788
787789 # Verify client credentials were included in request body
788790 import urllib .parse
791+
789792 body_params = urllib .parse .parse_qs (request .content .decode ())
790793 assert body_params ["client_id" ][0 ] == "test-client-id"
791794 # With client_secret_basic (default), credentials should be in Authorization header
792795 assert "Authorization" in request .headers
793796 assert request .headers ["Authorization" ].startswith ("Basic " )
794797
795798
796-
797799@pytest .mark .anyio
798800async def test_exchange_id_jag_with_client_id_only (sample_id_jag : str , mock_token_storage : Any ):
799801 """Test JWT bearer grant request building with client_id but no client_secret."""
@@ -837,15 +839,14 @@ async def test_exchange_id_jag_with_client_id_only(sample_id_jag: str, mock_toke
837839
838840 # Verify client_id was included but NOT client_secret
839841 import urllib .parse
842+
840843 body_params = urllib .parse .parse_qs (request .content .decode ())
841844 assert body_params ["client_id" ][0 ] == "test-client-id"
842845 assert "client_secret" not in body_params
843846 # With no client_secret, there should be no Authorization header either
844847 assert "Authorization" not in request .headers or not request .headers ["Authorization" ].startswith ("Basic " )
845848
846849
847-
848-
849850@pytest .mark .anyio
850851async def test_exchange_token_with_client_info_but_no_client_id (
851852 sample_id_token : str , sample_id_jag : str , mock_token_storage : Any
@@ -950,11 +951,11 @@ async def test_exchange_id_jag_with_client_info_but_no_client_id(sample_id_jag:
950951
951952 # Verify client_id was not included (None), but client_secret should be handled
952953 import urllib .parse
954+
953955 body_params = urllib .parse .parse_qs (request .content .decode ())
954956 assert "client_id" not in body_params or body_params ["client_id" ][0 ] == ""
955957
956958
957-
958959def test_validate_token_exchange_params_missing_audience ():
959960 """Test validation fails for missing audience."""
960961 params = TokenExchangeParameters (
@@ -1025,6 +1026,7 @@ async def test_exchange_id_jag_with_existing_auth_method(sample_id_jag: str, moc
10251026
10261027 # Verify it used client_secret_post (in body, not header)
10271028 import urllib .parse
1029+
10281030 body_params = urllib .parse .parse_qs (request .content .decode ())
10291031 assert body_params ["client_id" ][0 ] == "test-client-id"
10301032 assert body_params ["client_secret" ][0 ] == "test-client-secret"
0 commit comments