Use shared SESSION_COOKIE_NAME in auth router tests

This commit is contained in:
2026-04-14 10:33:32 +02:00
parent 5e4d3fcf12
commit 0e5e08374f
2 changed files with 8 additions and 5 deletions

View File

@@ -8,6 +8,8 @@ from unittest.mock import patch
import pytest
from httpx import AsyncClient
from app.utils.constants import SESSION_COOKIE_NAME
# ---------------------------------------------------------------------------
# Helpers
# ---------------------------------------------------------------------------
@@ -64,8 +66,8 @@ class TestLogin:
"/api/auth/login", json={"password": "mysecretpass1"}
)
assert response.status_code == 200
assert "bangui_session" in response.cookies
assert "." in response.cookies["bangui_session"]
assert SESSION_COOKIE_NAME in response.cookies
assert "." in response.cookies[SESSION_COOKIE_NAME]
set_cookie = response.headers.get("set-cookie", "")
assert "HttpOnly" in set_cookie
assert "SameSite=lax" in set_cookie
@@ -124,7 +126,7 @@ class TestLogout:
assert response.status_code == 200
# Cookie should be set to empty / deleted in the Set-Cookie header.
set_cookie = response.headers.get("set-cookie", "")
assert "bangui_session" in set_cookie
assert SESSION_COOKIE_NAME in set_cookie
async def test_logout_is_idempotent(self, client: AsyncClient) -> None:
"""Logout succeeds even when called without a session token."""