mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-10-29 00:18:08 +08:00
chore: lint
This commit is contained in:
committed by
François Voron
parent
3d33e3da8a
commit
8404f24b62
@ -27,4 +27,3 @@ class ErrorCode(str, Enum):
|
|||||||
UPDATE_USER_INVALID_PASSWORD = "UPDATE_USER_INVALID_PASSWORD"
|
UPDATE_USER_INVALID_PASSWORD = "UPDATE_USER_INVALID_PASSWORD"
|
||||||
ACCESS_TOKEN_ALREADY_EXPIRED = "ACCESS_TOKEN_ALREADY_EXPIRED"
|
ACCESS_TOKEN_ALREADY_EXPIRED = "ACCESS_TOKEN_ALREADY_EXPIRED"
|
||||||
ACCESS_TOKEN_DECODE_ERROR = "ACCESS_TOKEN_DECODE_ERROR"
|
ACCESS_TOKEN_DECODE_ERROR = "ACCESS_TOKEN_DECODE_ERROR"
|
||||||
|
|
||||||
|
|||||||
@ -92,11 +92,15 @@ def get_oauth_router(
|
|||||||
},
|
},
|
||||||
ErrorCode.ACCESS_TOKEN_DECODE_ERROR: {
|
ErrorCode.ACCESS_TOKEN_DECODE_ERROR: {
|
||||||
"summary": "Access token is error.",
|
"summary": "Access token is error.",
|
||||||
"value": {"detail": ErrorCode.ACCESS_TOKEN_DECODE_ERROR},
|
"value": {
|
||||||
|
"detail": ErrorCode.ACCESS_TOKEN_DECODE_ERROR
|
||||||
|
},
|
||||||
},
|
},
|
||||||
ErrorCode.ACCESS_TOKEN_ALREADY_EXPIRED: {
|
ErrorCode.ACCESS_TOKEN_ALREADY_EXPIRED: {
|
||||||
"summary": "Access token is already expired.",
|
"summary": "Access token is already expired.",
|
||||||
"value": {"detail": ErrorCode.ACCESS_TOKEN_ALREADY_EXPIRED},
|
"value": {
|
||||||
|
"detail": ErrorCode.ACCESS_TOKEN_ALREADY_EXPIRED
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -239,11 +243,15 @@ def get_oauth_associate_router(
|
|||||||
},
|
},
|
||||||
ErrorCode.ACCESS_TOKEN_DECODE_ERROR: {
|
ErrorCode.ACCESS_TOKEN_DECODE_ERROR: {
|
||||||
"summary": "Access token is error.",
|
"summary": "Access token is error.",
|
||||||
"value": {"detail": ErrorCode.ACCESS_TOKEN_DECODE_ERROR},
|
"value": {
|
||||||
|
"detail": ErrorCode.ACCESS_TOKEN_DECODE_ERROR
|
||||||
|
},
|
||||||
},
|
},
|
||||||
ErrorCode.ACCESS_TOKEN_ALREADY_EXPIRED: {
|
ErrorCode.ACCESS_TOKEN_ALREADY_EXPIRED: {
|
||||||
"summary": "Access token is already expired.",
|
"summary": "Access token is already expired.",
|
||||||
"value": {"detail": ErrorCode.ACCESS_TOKEN_ALREADY_EXPIRED},
|
"value": {
|
||||||
|
"detail": ErrorCode.ACCESS_TOKEN_ALREADY_EXPIRED
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -309,7 +309,6 @@ class TestCallback:
|
|||||||
json = response.json()
|
json = response.json()
|
||||||
assert json["detail"] == ErrorCode.OAUTH_NOT_AVAILABLE_EMAIL
|
assert json["detail"] == ErrorCode.OAUTH_NOT_AVAILABLE_EMAIL
|
||||||
|
|
||||||
|
|
||||||
async def test_callback_token_expired(
|
async def test_callback_token_expired(
|
||||||
self,
|
self,
|
||||||
async_method_mocker: AsyncMethodMocker,
|
async_method_mocker: AsyncMethodMocker,
|
||||||
@ -361,6 +360,7 @@ class TestCallback:
|
|||||||
assert response.status_code == status.HTTP_400_BAD_REQUEST
|
assert response.status_code == status.HTTP_400_BAD_REQUEST
|
||||||
assert user_manager_oauth.on_after_login.called is False
|
assert user_manager_oauth.on_after_login.called is False
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.router
|
@pytest.mark.router
|
||||||
@pytest.mark.oauth
|
@pytest.mark.oauth
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@ -602,7 +602,7 @@ class TestAssociateCallback:
|
|||||||
assert response.status_code == status.HTTP_400_BAD_REQUEST
|
assert response.status_code == status.HTTP_400_BAD_REQUEST
|
||||||
json = response.json()
|
json = response.json()
|
||||||
assert json["detail"] == ErrorCode.OAUTH_NOT_AVAILABLE_EMAIL
|
assert json["detail"] == ErrorCode.OAUTH_NOT_AVAILABLE_EMAIL
|
||||||
|
|
||||||
async def test_callback_token_expired(
|
async def test_callback_token_expired(
|
||||||
self,
|
self,
|
||||||
async_method_mocker: AsyncMethodMocker,
|
async_method_mocker: AsyncMethodMocker,
|
||||||
@ -612,10 +612,10 @@ class TestAssociateCallback:
|
|||||||
user_manager_oauth: UserManagerMock,
|
user_manager_oauth: UserManagerMock,
|
||||||
access_token: str,
|
access_token: str,
|
||||||
):
|
):
|
||||||
state_jwt = generate_state_token({"sub": str(user_oauth.id)}, "SECRET", lifetime_seconds=-1)
|
state_jwt = generate_state_token(
|
||||||
async_method_mocker(
|
{"sub": str(user_oauth.id)}, "SECRET", lifetime_seconds=-1
|
||||||
oauth_client, "get_access_token", return_value=access_token
|
|
||||||
)
|
)
|
||||||
|
async_method_mocker(oauth_client, "get_access_token", return_value=access_token)
|
||||||
async_method_mocker(
|
async_method_mocker(
|
||||||
oauth_client, "get_id_email", return_value=("user_oauth1", user_oauth.email)
|
oauth_client, "get_id_email", return_value=("user_oauth1", user_oauth.email)
|
||||||
)
|
)
|
||||||
@ -643,9 +643,7 @@ class TestAssociateCallback:
|
|||||||
access_token: str,
|
access_token: str,
|
||||||
):
|
):
|
||||||
state_jwt = generate_state_token({"sub": str(user_oauth.id)}, "RANDOM")
|
state_jwt = generate_state_token({"sub": str(user_oauth.id)}, "RANDOM")
|
||||||
async_method_mocker(
|
async_method_mocker(oauth_client, "get_access_token", return_value=access_token)
|
||||||
oauth_client, "get_access_token", return_value=access_token
|
|
||||||
)
|
|
||||||
async_method_mocker(
|
async_method_mocker(
|
||||||
oauth_client, "get_id_email", return_value=("user_oauth1", user_oauth.email)
|
oauth_client, "get_id_email", return_value=("user_oauth1", user_oauth.email)
|
||||||
)
|
)
|
||||||
@ -663,6 +661,7 @@ class TestAssociateCallback:
|
|||||||
|
|
||||||
assert response.status_code == status.HTTP_400_BAD_REQUEST
|
assert response.status_code == status.HTTP_400_BAD_REQUEST
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.oauth
|
@pytest.mark.oauth
|
||||||
@pytest.mark.router
|
@pytest.mark.router
|
||||||
|
|||||||
Reference in New Issue
Block a user