🛡️ Warracker is an open source, self-hostable warranty tracker to monitor expirations, store receipts, files. You own the data, your rules!
Tests: read the signing key and DB credentials from the environment (CI fix)
Omega (QA)9af2dcae399f
diff --git a/tests/test_a_first_user_race.py b/tests/test_a_first_user_race.pyindex c4bb4bf..6e79ef4 100644--- a/tests/test_a_first_user_race.py+++ b/tests/test_a_first_user_race.py@@ -16,6 +16,7 @@ creates, leaving the table empty for the tests that follow. If thetable is not empty (someone runs this file after other tests), itskips."""+import osimport threadingimport uuidfrom pathlib import Path@@ -24,12 +25,16 @@ import psycopg2import pytestfrom backend.auth_utils import FIRST_USER_LOCK_KEY, acquire_first_user_lock+from conftest import _connectdef test_first_user_lock_blocks_concurrent_acquire(db_connection):"""The advisory lock serializes: a second transaction cannot takeit while the first holds it, and can once the first commits."""- conn_b = psycopg2.connect(db_connection.dsn)+ # Build the second connection from the environment like the+ # fixture does: db_connection.dsn carries no password, which works+ # on the trust-auth local socket but fails password auth in CI.+ conn_b = _connect(os.environ["DB_NAME"])try:with db_connection.cursor() as cur_a:acquire_first_user_lock(cur_a)diff --git a/tests/test_token_revocation.py b/tests/test_token_revocation.pyindex feac3b5..187cf75 100644--- a/tests/test_token_revocation.py+++ b/tests/test_token_revocation.py@@ -6,6 +6,7 @@ password change, and password reset all delete session rows, so acaptured token stops working after each. Tokens minted before jtiexisted carry no jti and are grandfathered until their 24h expiry."""+import osimport uuidfrom datetime import datetime, timedelta, UTC@@ -13,7 +14,11 @@ import jwtfrom backend.auth_routes import _hash_reset_token-SECRET_KEY = "warracker-test-secret-key-0123456789"+# The app signs with the SECRET_KEY from the environment (conftest sets+# the local default; CI sets its own), so forged tokens must use the+# same value or signature verification fails before the jti logic runs.+SECRET_KEY = os.environ.get(+ "SECRET_KEY", "warracker-test-secret-key-0123456789")def _user_id_from_token(token):