Skip to content

Commit c052cfd

Browse files
committed
docs: add TODOs
1 parent 946974a commit c052cfd

5 files changed

Lines changed: 16 additions & 4 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ Alembic for migrations, and SQLite for fast unit tests.
1616
│ ├── db/
1717
│ │ └── session.py
1818
│ └── modules/
19-
│ └── orders/
19+
│ ├── orders/
20+
│ │ ├── models.py
21+
│ │ ├── schemas.py
22+
│ │ ├── repository.py
23+
│ │ ├── service.py
24+
│ │ └── routes.py
25+
│ └── users/
2026
│ ├── models.py
2127
│ ├── schemas.py
2228
│ ├── repository.py

app/modules/orders/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
router = APIRouter()
88

9+
# TODO: Require user authentication when calling these paths
910

1011
@router.post("/", response_model=schemas.OrderRead)
1112
def create_order(payload: schemas.OrderCreate, db: Session = Depends(get_db)):

app/modules/users/repository.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66

77
def create_user(db: Session, username: str, password: str):
8+
# TODO: Add password strength check, should be long (20+ chars) OR complex (with uppercase, lowercase, numbers and symbols)
9+
810
# Hash the password with bcrypt
911
# bcrypt has a 72-byte limit, so we'll hash long passwords with SHA-256 first
1012
if len(password) > 72:
@@ -37,4 +39,4 @@ def verify_password(plain_password: str, hashed_password: str) -> bool:
3739
plain_password = hashlib.sha256(plain_password.encode()).hexdigest()
3840

3941
# Verify password
40-
return bcrypt.checkpw(plain_password.encode('utf-8'), hashed_password.encode('utf-8'))
42+
return bcrypt.checkpw(plain_password.encode('utf-8'), hashed_password.encode('utf-8'))

app/modules/users/service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from . import repository, schemas
33
from fastapi import HTTPException, status
44

5+
# TODO: Evaluate if the logic to check for user existance should actually be here
56

67
def create_user(db: Session, username: str, password: str):
78
# Check if user already exists
@@ -28,4 +29,4 @@ def authenticate_user(db: Session, username: str, password: str):
2829
headers={"WWW-Authenticate": "Bearer"},
2930
)
3031

31-
return user
32+
return user

tests/unit/test_users.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from app.modules.users.repository import create_user, get_user_by_username, verify_password
44
from app.modules.users.service import authenticate_user
55

6+
# TODO: Create test to check if long passwords with 50 chars works just fine
67

78
def test_create_user(db: Session):
89
# Test creating a new user
@@ -11,6 +12,7 @@ def test_create_user(db: Session):
1112
assert user.username == "testuser"
1213
assert user.id is not None
1314

15+
# TODO: Move hashing verification into its own test
1416
# Test that password was hashed
1517
assert user.hashed_password != "password123"
1618

@@ -59,4 +61,4 @@ def test_authenticate_user_success(db: Session):
5961
def test_authenticate_user_failure(db: Session):
6062
# Try to authenticate with wrong password - should fail
6163
with pytest.raises(Exception): # Will be HTTPException in service layer
62-
authenticate_user(db, "nonexistent", "wrongpassword")
64+
authenticate_user(db, "nonexistent", "wrongpassword")

0 commit comments

Comments
 (0)