This commit is contained in:
@@ -25,6 +25,7 @@ async def test_ensure_user_has_reader_role(db_session):
|
||||
|
||||
# Создаем тестового пользователя без роли reader
|
||||
test_author = Author(
|
||||
name="Test Reader User", # 🔍 Добавляем обязательное поле name
|
||||
email="test_reader_role@example.com",
|
||||
slug="test_reader_role",
|
||||
password="test_password"
|
||||
|
||||
@@ -231,7 +231,8 @@ with (
|
||||
body_content = response.body
|
||||
if isinstance(body_content, memoryview):
|
||||
body_content = bytes(body_content)
|
||||
assert "Invalid or expired OAuth state" in body_content.decode()
|
||||
response_data = body_content.decode()
|
||||
assert "oauth_state_expired" in response_data # 🔍 Проверяем новый формат ошибки
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_oauth_callback_missing_state(mock_request):
|
||||
|
||||
@@ -97,7 +97,7 @@ class TestOAuthFunctional:
|
||||
body = response.body
|
||||
if isinstance(body, memoryview):
|
||||
body = bytes(body)
|
||||
assert b"Invalid or expired OAuth state" in body
|
||||
assert b"oauth_state_expired" in body # 🔍 Проверяем новый формат ошибки
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_oauth_callback_success_session_free(self):
|
||||
@@ -163,8 +163,11 @@ class TestOAuthFunctional:
|
||||
assert isinstance(response, RedirectResponse)
|
||||
assert response.status_code == 307
|
||||
|
||||
# Проверяем URL редиректа
|
||||
assert response.headers["location"] == "https://localhost:3000"
|
||||
# Проверяем URL редиректа (теперь с параметрами)
|
||||
redirect_url = response.headers["location"]
|
||||
assert redirect_url.startswith("https://localhost:3000")
|
||||
assert "access_token=" in redirect_url # 🔍 Проверяем наличие токена
|
||||
assert "state=valid_state" in redirect_url # 🔍 Проверяем state
|
||||
|
||||
# Проверяем что токен получен без использования request.session
|
||||
mock_client.fetch_access_token.assert_called_once_with(
|
||||
|
||||
Reference in New Issue
Block a user