mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-11-30 07:34:10 -05:00
fix: unclosed sessions (#1734)
* resolve session leak * cleanup session management functions
This commit is contained in:
@@ -3,7 +3,7 @@ import json
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from mealie.db.db_setup import create_session
|
||||
from mealie.db.db_setup import session_context
|
||||
from mealie.services.user_services.password_reset_service import PasswordResetService
|
||||
from tests.utils.factories import random_string
|
||||
from tests.utils.fixture_schemas import TestUser
|
||||
@@ -31,10 +31,10 @@ def test_password_reset(api_client: TestClient, unique_user: TestUser, casing: s
|
||||
cased_email += l.lower()
|
||||
cased_email
|
||||
|
||||
session = create_session()
|
||||
service = PasswordResetService(session)
|
||||
token = service.generate_reset_token(cased_email)
|
||||
assert token is not None
|
||||
with session_context() as session:
|
||||
service = PasswordResetService(session)
|
||||
token = service.generate_reset_token(cased_email)
|
||||
assert token is not None
|
||||
|
||||
new_password = random_string(15)
|
||||
|
||||
@@ -59,8 +59,6 @@ def test_password_reset(api_client: TestClient, unique_user: TestUser, casing: s
|
||||
response = api_client.get(Routes.self, headers={"Authorization": f"Bearer {new_token}"})
|
||||
assert response.status_code == 200
|
||||
|
||||
session.close()
|
||||
|
||||
# Test successful password reset
|
||||
response = api_client.post(Routes.base, json=payload)
|
||||
assert response.status_code == 400
|
||||
|
||||
Reference in New Issue
Block a user