f0af44d840
- Update agent router/service/repository with new endpoints - Update auth routes with phone-based authentication - Update users service with new phone lookup - Update schedule_items with new schemas - Update message schemas with visibility support - Update settings with new automation scheduler config - Update CLI with new commands - Update tests to match new API contracts
54 lines
1.3 KiB
Python
54 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
import pytest
|
|
from pydantic import ValidationError
|
|
|
|
from v1.auth.schemas import (
|
|
AuthUser,
|
|
OtpSendRequest,
|
|
PhoneSessionCreateRequest,
|
|
SessionDeleteRequest,
|
|
SessionRefreshRequest,
|
|
SessionResponse,
|
|
)
|
|
|
|
|
|
def test_send_otp_requires_valid_phone() -> None:
|
|
with pytest.raises(ValidationError):
|
|
OtpSendRequest(phone="13812345678")
|
|
|
|
|
|
def test_send_otp_accepts_e164_phone() -> None:
|
|
request = OtpSendRequest(phone="+14155552671")
|
|
|
|
assert request.phone == "+14155552671"
|
|
|
|
|
|
def test_phone_session_requires_six_digit_token() -> None:
|
|
with pytest.raises(ValidationError):
|
|
PhoneSessionCreateRequest(phone="+8613812345678", token="abc123")
|
|
|
|
|
|
def test_refresh_requires_token() -> None:
|
|
with pytest.raises(ValidationError):
|
|
SessionRefreshRequest(refresh_token="")
|
|
|
|
|
|
def test_logout_requires_token() -> None:
|
|
with pytest.raises(ValidationError):
|
|
SessionDeleteRequest(refresh_token="")
|
|
|
|
|
|
def test_session_response_maps_user() -> None:
|
|
user = AuthUser(id="user-1", phone="+14155552671")
|
|
response = SessionResponse(
|
|
access_token="access",
|
|
refresh_token="refresh",
|
|
expires_in=3600,
|
|
token_type="bearer",
|
|
user=user,
|
|
)
|
|
|
|
assert response.user.id == "user-1"
|
|
assert response.user.phone == "+14155552671"
|