c086f64363
- 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
23 lines
699 B
Python
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
|