@@ -1122,6 +1122,46 @@ async def test_verify_uses_private_key_jwt_assertion(self, mocker):
11221122 assert claims ["iss" ] == CLIENT_ID
11231123 assert claims ["sub" ] == CLIENT_ID
11241124
1125+ @pytest .mark .asyncio
1126+ async def test_start_uses_client_secret_when_configured (self ):
1127+ client = _make_client ()
1128+ http = _mock_http (client , 200 , {})
1129+
1130+ await client .passwordless .start (
1131+ StartPasswordlessEmailOptions (email = "user@example.com" , send = "code" )
1132+ )
1133+
1134+ body = http .post .call_args .kwargs ["json" ]
1135+ assert body ["client_secret" ] == CLIENT_SECRET
1136+ assert "client_assertion" not in body
1137+
1138+ @pytest .mark .asyncio
1139+ async def test_verify_uses_client_secret_when_configured (self , mocker ):
1140+ client = _make_client ()
1141+ claims_from_id_token = {"iss" : ISSUER , "sub" : "auth0|1" , "sid" : "SID-123" , "iat" : 1_000 }
1142+ mocker .patch .object (client , "_get_oidc_metadata_cached" , return_value = METADATA )
1143+ mocker .patch .object (
1144+ client ,
1145+ "_get_jwks_cached" ,
1146+ return_value = {"keys" : [{"kty" : "RSA" , "kid" : "k1" }]},
1147+ )
1148+ mocker .patch .object (client , "_verify_and_decode_jwt" , return_value = claims_from_id_token )
1149+ http = _mock_http (
1150+ client ,
1151+ 200 ,
1152+ {"access_token" : "at" , "id_token" : "idt" , "expires_in" : 3600 , "scope" : "openid" },
1153+ )
1154+
1155+ await client .passwordless .verify (
1156+ VerifyPasswordlessOtpOptions (
1157+ connection = "email" , email = "user@example.com" , verification_code = "123456"
1158+ )
1159+ )
1160+
1161+ data = http .post .call_args .kwargs ["data" ]
1162+ assert data ["client_secret" ] == CLIENT_SECRET
1163+ assert "client_assertion" not in data
1164+
11251165 @pytest .mark .asyncio
11261166 async def test_start_no_client_auth_configured_raises_configuration_error (self ):
11271167 client = _make_client (client_secret = None )
@@ -1130,3 +1170,15 @@ async def test_start_no_client_auth_configured_raises_configuration_error(self):
11301170 await client .passwordless .start (
11311171 StartPasswordlessEmailOptions (email = "user@example.com" , send = "code" )
11321172 )
1173+
1174+ @pytest .mark .asyncio
1175+ async def test_verify_no_client_auth_configured_raises_configuration_error (self , mocker ):
1176+ client = _make_client (client_secret = None )
1177+ mocker .patch .object (client , "_get_oidc_metadata_cached" , return_value = METADATA )
1178+
1179+ with pytest .raises (ConfigurationError ):
1180+ await client .passwordless .verify (
1181+ VerifyPasswordlessOtpOptions (
1182+ connection = "email" , email = "user@example.com" , verification_code = "123456"
1183+ )
1184+ )
0 commit comments