Backend (FastAPI + Python 3.12): - Multi-tenant auth with JWT: login, register, refresh, Meta OAuth - Business & BusinessConfig management - WhatsApp webhook with HMAC signature verification - Bot engine powered by Claude AI - Calendar availability with Redis caching - Reservations CRUD with status management - Dashboard analytics (stats, agenda, peak hours) - Billing & plan management - Admin panel with platform-wide stats - Async bcrypt via asyncio.to_thread - IntegrityError handling for concurrent registration race conditions Frontend (React 18 + Vite + Tailwind CSS): - Multi-step guided registration form with helper text on every field - Login page with show/hide password toggle - Protected routes with AuthContext - Dashboard with stats cards, bar chart, and daily agenda - Reservations list with search, filters, and inline status actions - Calendar with weekly view, slot availability, and date blocking - Config page: business info, schedules, bot personality - Billing page with plan comparison and usage bar Design system: - Bricolage Grotesque + DM Sans typography - Emerald primary palette with semantic color tokens - scale(0.97) button press feedback, ease-out animations - Skeleton loaders, stagger animations, prefers-reduced-motion support - Accessible: aria-labels, visible focus rings, 4.5:1 contrast Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
43 lines
1003 B
Python
43 lines
1003 B
Python
import pytest
|
|
from jose import JWTError
|
|
|
|
from app.core.security import (
|
|
create_access_token,
|
|
decode_token,
|
|
hash_password,
|
|
verify_password,
|
|
)
|
|
|
|
|
|
def test_hash_and_verify_password():
|
|
plain = "supersecret123"
|
|
hashed = hash_password(plain)
|
|
assert hashed != plain
|
|
assert verify_password(plain, hashed)
|
|
|
|
|
|
def test_wrong_password_fails():
|
|
hashed = hash_password("correct")
|
|
assert not verify_password("wrong", hashed)
|
|
|
|
|
|
def test_create_and_decode_token():
|
|
data = {"sub": "42", "business_id": 7}
|
|
token = create_access_token(data)
|
|
payload = decode_token(token)
|
|
assert payload["sub"] == "42"
|
|
assert payload["business_id"] == 7
|
|
|
|
|
|
def test_tampered_token_raises():
|
|
token = create_access_token({"sub": "1"})
|
|
tampered = token[:-5] + "XXXXX"
|
|
with pytest.raises(JWTError):
|
|
decode_token(tampered)
|
|
|
|
|
|
def test_token_contains_expiry():
|
|
token = create_access_token({"sub": "1"})
|
|
payload = decode_token(token)
|
|
assert "exp" in payload
|