mirror of
https://github.com/remnawave/python-sdk.git
synced 2026-05-13 12:16:42 +00:00
- Restructured HWID tests into classes for better organization and clarity. - Enhanced subscription tests to cover additional scenarios and improved assertions. - Introduced new tests for system statistics and monitoring. - Implemented CRUD operations for user management with comprehensive test coverage. - Added new controllers and models for handling subscription request history. - Created tests for subscription request history, including pagination and statistics. - Improved error handling in tests to skip when exceptions occur.
43 lines
No EOL
1.8 KiB
Python
43 lines
No EOL
1.8 KiB
Python
import pytest
|
||
|
||
from remnawave.models import (
|
||
LoginRequestDto,
|
||
LoginResponseDto,
|
||
LoginTelegramRequestDto,
|
||
TelegramCallbackRequestDto,
|
||
)
|
||
from remnawave.exceptions import ForbiddenError, ApiError
|
||
from tests.conftest import REMNAWAVE_ADMIN_PASSWORD, REMNAWAVE_ADMIN_USERNAME
|
||
|
||
|
||
class TestAuthentication:
|
||
"""Тесты для проверки функциональности аутентификации"""
|
||
|
||
@pytest.mark.asyncio
|
||
async def test_login_with_credentials(self, remnawave):
|
||
"""Тест базовой аутентификации по имени пользователя и паролю"""
|
||
login = await remnawave.auth.login(
|
||
LoginRequestDto(
|
||
username=REMNAWAVE_ADMIN_USERNAME,
|
||
password=REMNAWAVE_ADMIN_PASSWORD,
|
||
)
|
||
)
|
||
assert isinstance(login, LoginResponseDto)
|
||
assert login.access_token is not None
|
||
# Проверяем наличие токена, но не обращаемся к полю user,
|
||
# так как в текущей версии API это поле не возвращается
|
||
assert login.access_token.startswith("eyJ") # JWT token всегда начинается с eyJ
|
||
|
||
@pytest.mark.asyncio
|
||
async def test_login_with_invalid_credentials(self, remnawave):
|
||
"""Тест аутентификации с неверными учетными данными"""
|
||
try:
|
||
await remnawave.auth.login(
|
||
LoginRequestDto(
|
||
username="invalid_username",
|
||
password="invalid_password",
|
||
)
|
||
)
|
||
pytest.fail("Expected authentication error for invalid credentials")
|
||
except ApiError as e:
|
||
assert e.status_code in [401, 403], f"Expected 401 or 403, got {e.status_code}" |