Skip to content

Commit e657ac6

Browse files
Merge branch 'master' into add-health-check
2 parents 47a61af + d1df85e commit e657ac6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+6562
-6143
lines changed

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,17 @@ updates:
1414
interval: daily
1515
commit-message:
1616
prefix:
17+
# npm
18+
- package-ecosystem: npm
19+
directory: /
20+
schedule:
21+
interval: daily
22+
commit-message:
23+
prefix:
24+
# Docker
25+
- package-ecosystem: docker
26+
directory: /
27+
schedule:
28+
interval: weekly
29+
commit-message:
30+
prefix:

backend/app/api/routes/users.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ def delete_user_me(session: SessionDep, current_user: CurrentUser) -> Any:
134134
raise HTTPException(
135135
status_code=403, detail="Super users are not allowed to delete themselves"
136136
)
137-
statement = delete(Item).where(col(Item.owner_id) == current_user.id)
138-
session.exec(statement) # type: ignore
139137
session.delete(current_user)
140138
session.commit()
141139
return Message(message="User deleted successfully")

backend/app/core/config.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from pydantic import (
66
AnyUrl,
77
BeforeValidator,
8+
EmailStr,
89
HttpUrl,
910
PostgresDsn,
1011
computed_field,
@@ -74,9 +75,8 @@ def SQLALCHEMY_DATABASE_URI(self) -> PostgresDsn:
7475
SMTP_HOST: str | None = None
7576
SMTP_USER: str | None = None
7677
SMTP_PASSWORD: str | None = None
77-
# TODO: update type to EmailStr when sqlmodel supports it
78-
EMAILS_FROM_EMAIL: str | None = None
79-
EMAILS_FROM_NAME: str | None = None
78+
EMAILS_FROM_EMAIL: EmailStr | None = None
79+
EMAILS_FROM_NAME: EmailStr | None = None
8080

8181
@model_validator(mode="after")
8282
def _set_default_emails_from(self) -> Self:
@@ -91,10 +91,8 @@ def _set_default_emails_from(self) -> Self:
9191
def emails_enabled(self) -> bool:
9292
return bool(self.SMTP_HOST and self.EMAILS_FROM_EMAIL)
9393

94-
# TODO: update type to EmailStr when sqlmodel supports it
95-
EMAIL_TEST_USER: str = "[email protected]"
96-
# TODO: update type to EmailStr when sqlmodel supports it
97-
FIRST_SUPERUSER: str
94+
EMAIL_TEST_USER: EmailStr = "[email protected]"
95+
FIRST_SUPERUSER: EmailStr
9896
FIRST_SUPERUSER_PASSWORD: str
9997

10098
def _check_default_secret(self, var_name: str, value: str | None) -> None:

backend/app/models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ class ItemUpdate(ItemBase):
7575
# Database model, database table inferred from class name
7676
class Item(ItemBase, table=True):
7777
id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True)
78-
title: str = Field(max_length=255)
7978
owner_id: uuid.UUID = Field(
8079
foreign_key="user.id", nullable=False, ondelete="CASCADE"
8180
)

backend/app/tests/api/routes/test_login.py

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
from unittest.mock import patch
22

33
from fastapi.testclient import TestClient
4-
from sqlmodel import Session, select
4+
from sqlmodel import Session
55

66
from app.core.config import settings
77
from app.core.security import verify_password
8-
from app.models import User
8+
from app.crud import create_user
9+
from app.models import UserCreate
10+
from app.tests.utils.user import user_authentication_headers
11+
from app.tests.utils.utils import random_email, random_lower_string
912
from app.utils import generate_password_reset_token
1013

1114

@@ -69,23 +72,34 @@ def test_recovery_password_user_not_exits(
6972
assert r.status_code == 404
7073

7174

72-
def test_reset_password(
73-
client: TestClient, superuser_token_headers: dict[str, str], db: Session
74-
) -> None:
75-
token = generate_password_reset_token(email=settings.FIRST_SUPERUSER)
76-
data = {"new_password": "changethis", "token": token}
75+
def test_reset_password(client: TestClient, db: Session) -> None:
76+
email = random_email()
77+
password = random_lower_string()
78+
new_password = random_lower_string()
79+
80+
user_create = UserCreate(
81+
email=email,
82+
full_name="Test User",
83+
password=password,
84+
is_active=True,
85+
is_superuser=False,
86+
)
87+
user = create_user(session=db, user_create=user_create)
88+
token = generate_password_reset_token(email=email)
89+
headers = user_authentication_headers(client=client, email=email, password=password)
90+
data = {"new_password": new_password, "token": token}
91+
7792
r = client.post(
7893
f"{settings.API_V1_STR}/reset-password/",
79-
headers=superuser_token_headers,
94+
headers=headers,
8095
json=data,
8196
)
97+
8298
assert r.status_code == 200
8399
assert r.json() == {"message": "Password updated successfully"}
84100

85-
user_query = select(User).where(User.email == settings.FIRST_SUPERUSER)
86-
user = db.exec(user_query).first()
87-
assert user
88-
assert verify_password(data["new_password"], user.hashed_password)
101+
db.refresh(user)
102+
assert verify_password(new_password, user.hashed_password)
89103

90104

91105
def test_reset_password_invalid_token(

frontend/README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ But it would be only to clean them up, leaving them won't really have any effect
8080
* From the top level project directory, run the script:
8181

8282
```bash
83-
./scripts/generate-frontend-client.sh
83+
./scripts/generate-client.sh
8484
```
8585

8686
* Commit the changes.
@@ -91,12 +91,6 @@ But it would be only to clean them up, leaving them won't really have any effect
9191

9292
* Download the OpenAPI JSON file from `http://localhost/api/v1/openapi.json` and copy it to a new file `openapi.json` at the root of the `frontend` directory.
9393

94-
* To simplify the names in the generated frontend client code, modify the `openapi.json` file by running the following script:
95-
96-
```bash
97-
node modify-openapi-operationids.js
98-
```
99-
10094
* To generate the frontend client, run:
10195

10296
```bash

frontend/openapi-ts.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default defineConfig({
1515
// @ts-ignore
1616
let name: string = operation.name
1717
// @ts-ignore
18-
let service: string = operation.service
18+
const service: string = operation.service
1919

2020
if (service && name.toLowerCase().startsWith(service.toLowerCase())) {
2121
name = name.slice(service.length)

0 commit comments

Comments
 (0)