Files
CMT/backend/tests/core/test_auth.py
T
linmihigo c086f64363 feat: implement complete CMT backend with API endpoints and test suite
- Add 7 core API endpoints: users, transactions, partners, products, inventory, payments, credit
- Implement role-based authentication (admin/write/read-only access)
- Add comprehensive database models with proper relationships
- Include full test coverage for all endpoints and business logic
- Set up Alembic migrations and Docker configuration
- Configure FastAPI app with CORS and database integration
2025-09-14 21:04:07 +02:00

23 lines
699 B
Python

import pytest
from app.core.auth import get_password_hash, verify_password, create_access_token
from app.schemas.base import UserRole
def test_password_hashing():
"""Test password hashing and verification."""
password = "testpassword123"
hashed = get_password_hash(password)
assert hashed != password
assert verify_password(password, hashed) is True
assert verify_password("wrongpassword", hashed) is False
def test_create_access_token():
"""Test JWT token creation."""
data = {"sub": "testuser", "user_id": 1, "role": UserRole.ADMIN}
token = create_access_token(data, expires_delta=None)
assert isinstance(token, str)
assert len(token) > 0