Skip to content

Commit 6dc142a

Browse files
committed
Linting fix for imports
1 parent e91b27e commit 6dc142a

2 files changed

Lines changed: 11 additions & 29 deletions

File tree

src/auth0_server_python/tests/test_my_account_client.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import base64
2+
import json
13
from unittest.mock import ANY, AsyncMock, MagicMock
24

35
import httpx
@@ -1369,9 +1371,6 @@ def test_dpop_auth_flow_retries_with_nonce_on_401():
13691371
DPoPAuth.auth_flow() must retry with DPoP-Nonce when server responds 401
13701372
+ DPoP-Nonce header (RFC 9449 §8.2). Tested by driving the generator directly.
13711373
"""
1372-
import base64
1373-
import json as _json
1374-
13751374
dpop_key = jwk_module.JWK.generate(kty="EC", crv="P-256")
13761375
auth = DPoPAuth(token="test_access_token", key=dpop_key)
13771376

@@ -1387,7 +1386,7 @@ def test_dpop_auth_flow_retries_with_nonce_on_401():
13871386
proof1 = first_request.headers["DPoP"]
13881387
payload1_b64 = proof1.split(".")[1]
13891388
padding = 4 - len(payload1_b64) % 4
1390-
payload1 = _json.loads(base64.urlsafe_b64decode(payload1_b64 + "=" * padding))
1389+
payload1 = json.loads(base64.urlsafe_b64decode(payload1_b64 + "=" * padding))
13911390
assert "nonce" not in payload1
13921391

13931392
# Simulate 401 + DPoP-Nonce response
@@ -1408,7 +1407,7 @@ def test_dpop_auth_flow_retries_with_nonce_on_401():
14081407
proof2 = second_request.headers["DPoP"]
14091408
payload2_b64 = proof2.split(".")[1]
14101409
padding = 4 - len(payload2_b64) % 4
1411-
payload2 = _json.loads(base64.urlsafe_b64decode(payload2_b64 + "=" * padding))
1410+
payload2 = json.loads(base64.urlsafe_b64decode(payload2_b64 + "=" * padding))
14121411
assert payload2["nonce"] == "server-nonce-abc"
14131412

14141413

src/auth0_server_python/tests/test_server_client.py

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626
LoginWithCustomTokenExchangeOptions,
2727
LogoutOptions,
2828
MfaRequirements,
29+
PasskeyAuthResponse,
30+
PasskeyLoginChallengeResponse,
31+
PasskeyLoginResult,
32+
PasskeySignupChallengeResponse,
33+
PasskeyTokenResponse,
34+
PasskeyUserProfile,
2935
StartInteractiveLoginOptions,
3036
StateData,
3137
TransactionData,
@@ -47,6 +53,7 @@
4753
MissingRequiredArgumentError,
4854
MissingTransactionError,
4955
OrganizationTokenValidationError,
56+
PasskeyError,
5057
PollingApiError,
5158
StartLinkUserError,
5259
)
@@ -5269,7 +5276,6 @@ async def _fake_fetch(self, domain):
52695276

52705277

52715278
def _make_passkey_authn_response():
5272-
from auth0_server_python.auth_types import PasskeyAuthResponse
52735279
return PasskeyAuthResponse(
52745280
id="cred_abc123",
52755281
raw_id="Y3JlZF9hYmMxMjM",
@@ -5286,7 +5292,6 @@ def _make_passkey_authn_response():
52865292

52875293
@pytest.mark.asyncio
52885294
async def test_passkey_signup_challenge_success(mocker):
5289-
from auth0_server_python.auth_types import PasskeySignupChallengeResponse, PasskeyUserProfile
52905295
client = ServerClient(
52915296
domain="auth0.local",
52925297
client_id="test_client_id",
@@ -5327,7 +5332,6 @@ async def test_passkey_signup_challenge_success(mocker):
53275332

53285333
@pytest.mark.asyncio
53295334
async def test_passkey_signup_challenge_user_profile_fields(mocker):
5330-
from auth0_server_python.auth_types import PasskeyUserProfile
53315335
client = ServerClient(
53325336
domain="auth0.local",
53335337
client_id="test_client_id",
@@ -5426,8 +5430,6 @@ async def test_passkey_signup_challenge_user_metadata_root_level(mocker):
54265430

54275431
@pytest.mark.asyncio
54285432
async def test_passkey_signup_challenge_api_error(mocker):
5429-
from auth0_server_python.auth_types import PasskeyUserProfile
5430-
from auth0_server_python.error import PasskeyError
54315433
client = ServerClient(
54325434
domain="auth0.local",
54335435
client_id="test_client_id",
@@ -5454,7 +5456,6 @@ async def test_passkey_signup_challenge_api_error(mocker):
54545456

54555457
@pytest.mark.asyncio
54565458
async def test_passkey_signup_challenge_non_json_error(mocker):
5457-
from auth0_server_python.error import PasskeyError
54585459
client = ServerClient(
54595460
domain="auth0.local",
54605461
client_id="test_client_id",
@@ -5476,7 +5477,6 @@ async def test_passkey_signup_challenge_non_json_error(mocker):
54765477

54775478
@pytest.mark.asyncio
54785479
async def test_passkey_signup_challenge_network_error(mocker):
5479-
from auth0_server_python.error import PasskeyError
54805480
client = ServerClient(
54815481
domain="auth0.local",
54825482
client_id="test_client_id",
@@ -5495,7 +5495,6 @@ async def test_passkey_signup_challenge_network_error(mocker):
54955495

54965496
@pytest.mark.asyncio
54975497
async def test_passkey_login_challenge_success(mocker):
5498-
from auth0_server_python.auth_types import PasskeyLoginChallengeResponse
54995498
client = ServerClient(
55005499
domain="auth0.local",
55015500
client_id="test_client_id",
@@ -5581,7 +5580,6 @@ async def test_passkey_login_challenge_with_username(mocker):
55815580

55825581
@pytest.mark.asyncio
55835582
async def test_passkey_login_challenge_api_error(mocker):
5584-
from auth0_server_python.error import PasskeyError
55855583
client = ServerClient(
55865584
domain="auth0.local",
55875585
client_id="test_client_id",
@@ -5605,7 +5603,6 @@ async def test_passkey_login_challenge_api_error(mocker):
56055603

56065604
@pytest.mark.asyncio
56075605
async def test_passkey_login_challenge_network_error(mocker):
5608-
from auth0_server_python.error import PasskeyError
56095606
client = ServerClient(
56105607
domain="auth0.local",
56115608
client_id="test_client_id",
@@ -5623,7 +5620,6 @@ async def test_passkey_login_challenge_network_error(mocker):
56235620

56245621
@pytest.mark.asyncio
56255622
async def test_signin_with_passkey_success(mocker):
5626-
from auth0_server_python.auth_types import PasskeyLoginResult
56275623
state_store = AsyncMock()
56285624
client = ServerClient(
56295625
domain="auth0.local",
@@ -5754,7 +5750,6 @@ async def test_signin_with_passkey_missing_authn_response():
57545750

57555751
@pytest.mark.asyncio
57565752
async def test_signin_with_passkey_api_error(mocker):
5757-
from auth0_server_python.error import PasskeyError
57585753
client = ServerClient(
57595754
domain="auth0.local",
57605755
client_id="test_client_id",
@@ -5787,7 +5782,6 @@ async def test_signin_with_passkey_api_error(mocker):
57875782

57885783
@pytest.mark.asyncio
57895784
async def test_signin_with_passkey_missing_token_endpoint(mocker):
5790-
from auth0_server_python.error import PasskeyError
57915785
client = ServerClient(
57925786
domain="auth0.local",
57935787
client_id="test_client_id",
@@ -5808,7 +5802,6 @@ async def test_signin_with_passkey_missing_token_endpoint(mocker):
58085802

58095803
@pytest.mark.asyncio
58105804
async def test_signin_with_passkey_network_error(mocker):
5811-
from auth0_server_python.error import PasskeyError
58125805
client = ServerClient(
58135806
domain="auth0.local",
58145807
client_id="test_client_id",
@@ -5857,7 +5850,6 @@ async def test_signin_with_passkey_no_client_secret(mocker):
58575850
mock_response.json = MagicMock(return_value=_PASSKEY_TOKEN_RESPONSE)
58585851
mock_post.return_value = mock_response
58595852

5860-
from auth0_server_python.auth_types import PasskeyAuthResponse
58615853
authn_resp = PasskeyAuthResponse(
58625854
id="cred",
58635855
raw_id="cmF3",
@@ -5873,23 +5865,20 @@ async def test_signin_with_passkey_no_client_secret(mocker):
58735865

58745866

58755867
def test_passkey_signup_challenge_repr_redacts_auth_session():
5876-
from auth0_server_python.auth_types import PasskeySignupChallengeResponse
58775868
resp = PasskeySignupChallengeResponse.model_validate(_PASSKEY_SIGNUP_CHALLENGE_RESPONSE)
58785869
repr_str = repr(resp)
58795870
assert "session_abc123" not in repr_str
58805871
assert "[REDACTED]" in repr_str
58815872

58825873

58835874
def test_passkey_login_challenge_repr_redacts_auth_session():
5884-
from auth0_server_python.auth_types import PasskeyLoginChallengeResponse
58855875
resp = PasskeyLoginChallengeResponse.model_validate(_PASSKEY_LOGIN_CHALLENGE_RESPONSE)
58865876
repr_str = repr(resp)
58875877
assert "session_login_xyz" not in repr_str
58885878
assert "[REDACTED]" in repr_str
58895879

58905880

58915881
def test_passkey_token_response_repr_redacts_tokens():
5892-
from auth0_server_python.auth_types import PasskeyTokenResponse
58935882
resp = PasskeyTokenResponse(
58945883
access_token="secret_at_value",
58955884
token_type="Bearer",
@@ -6129,7 +6118,6 @@ async def test_signin_with_passkey_dpop_nonce_retry_on_401(mocker):
61296118
@pytest.mark.asyncio
61306119
async def test_signin_with_passkey_dpop_rejects_bearer_downgrade(mocker):
61316120
"""Server returning token_type=Bearer when DPoP was requested must raise PasskeyError."""
6132-
from auth0_server_python.error import PasskeyError
61336121

61346122
client = ServerClient(
61356123
domain="auth0.local",
@@ -6231,7 +6219,6 @@ async def test_signin_with_passkey_without_dpop_no_dpop_header(mocker):
62316219
@pytest.mark.asyncio
62326220
async def test_signin_with_passkey_creates_session_in_state_store(mocker):
62336221
"""signin_with_passkey must persist a session — consistent with complete_interactive_login."""
6234-
from auth0_server_python.auth_types import PasskeyLoginResult
62356222
state_store = AsyncMock()
62366223
client = ServerClient(
62376224
domain="auth0.local",
@@ -6286,7 +6273,6 @@ async def test_signin_with_passkey_creates_session_in_state_store(mocker):
62866273
@pytest.mark.asyncio
62876274
async def test_signin_with_passkey_session_without_id_token(mocker):
62886275
"""When no id_token is returned, session is still created with user=None."""
6289-
from auth0_server_python.auth_types import PasskeyLoginResult
62906276
state_store = AsyncMock()
62916277
client = ServerClient(
62926278
domain="auth0.local",
@@ -6325,7 +6311,6 @@ async def test_signin_with_passkey_session_without_id_token(mocker):
63256311
@pytest.mark.asyncio
63266312
async def test_signin_with_passkey_mfa_required_raises_mfa_required_error(mocker):
63276313
"""Server returns 403 mfa_required — SDK raises MfaRequiredError with encrypted token."""
6328-
from auth0_server_python.error import MfaRequiredError
63296314
client = ServerClient(
63306315
domain="auth0.local",
63316316
client_id="test_client_id",
@@ -6361,7 +6346,6 @@ async def test_signin_with_passkey_mfa_required_raises_mfa_required_error(mocker
63616346
@pytest.mark.asyncio
63626347
async def test_signin_with_passkey_mfa_required_with_requirements(mocker):
63636348
"""mfa_required response including mfa_requirements is propagated correctly."""
6364-
from auth0_server_python.error import MfaRequiredError
63656349
client = ServerClient(
63666350
domain="auth0.local",
63676351
client_id="test_client_id",
@@ -6398,7 +6382,6 @@ async def test_signin_with_passkey_mfa_required_with_requirements(mocker):
63986382
@pytest.mark.asyncio
63996383
async def test_signin_with_passkey_mfa_required_without_mfa_token_falls_through(mocker):
64006384
"""mfa_required response missing mfa_token raises PasskeyError (server misconfiguration)."""
6401-
from auth0_server_python.error import PasskeyError
64026385
client = ServerClient(
64036386
domain="auth0.local",
64046387
client_id="test_client_id",

0 commit comments

Comments
 (0)