Remnawave_python-sdk/tests/test_auth.py
Artem 950a7ffab3
Add Pydantic models for nodes usage history, subscriptions, and user management
- Implemented models for nodes usage history including NodeInfoDto, GetUserAccessibleNodesResponse, and usage statistics.
- Created subscription-related models such as UserSubscription, SubscriptionInfoData, and various response DTOs for subscription information.
- Developed models for subscription settings, templates, and system statistics, enhancing the API's capability to manage and retrieve subscription configurations.
- Introduced user management models including CreateUserRequestDto, UpdateUserRequestDto, and various response DTOs for user actions.
- Added bulk actions for user updates and statistics tracking, improving the efficiency of user management operations.
- Established a base controller for handling API requests and responses, along with decorators for HTTP methods to streamline API interactions.
- Included utility functions for serialization using orjson for better performance with Pydantic models.
2025-07-03 12:22:16 +02:00

35 lines
No EOL
1.2 KiB
Python

import pytest
from remnawave.models import LoginRequestDto, LoginResponseDto, LoginTelegramRequestDto
from remnawave.exceptions import ForbiddenError, ApiError
from tests.conftest import REMNAWAVE_ADMIN_PASSWORD, REMNAWAVE_ADMIN_USERNAME
@pytest.mark.asyncio
async def test_auth(remnawave):
login = await remnawave.auth.login(
LoginRequestDto(
username=REMNAWAVE_ADMIN_USERNAME,
password=REMNAWAVE_ADMIN_PASSWORD,
)
)
assert isinstance(login, LoginResponseDto)
try:
telegram_login = await remnawave.auth.oauth2_tg_callback(
LoginTelegramRequestDto(
id=123456789,
first_name="Test",
last_name="User",
username="testuser",
photo_url="https://example.com/photo.jpg",
auth_date=1234567890,
hash="examplehash",
)
)
pytest.fail("Expected 403 error, but got successful response")
except ForbiddenError as e:
assert e.status_code == 403, f"Expected 403, got {e.status_code}"
print(f"Получено ожидаемое исключение: {e}")
except ApiError as e:
pytest.fail(f"Неожиданное исключение: {e}")