2 Commits
Author SHA1 Message Date
Brian Bjarke Jensen 19a211121c formatting fixes
Build and Push Docker Image / build-and-push (pull_request) Successful in 58s
Python Code Quality / python-code-quality (pull_request) Successful in 10s
Python Test / python-test (pull_request) Successful in 17s
2025-11-07 23:56:38 +01:00
Brian Bjarke Jensen ef1c7f83b6 added admin credential env vars for testing 2025-11-07 23:56:15 +01:00
4 changed files with 18 additions and 18 deletions
@@ -50,9 +50,7 @@ def _ensure_admin_user() -> None:
db = SessionLocal()
try:
# Check if admin user exists
admin_user = db.query(User).filter(
User.username == admin_username
).first()
admin_user = db.query(User).filter(User.username == admin_username).first()
hashed_pw = hash_password(admin_password)
@@ -42,7 +42,7 @@ class InMemoryTokenRepository(TokenRepositoryInterface):
def cleanup_expired(self) -> None:
"""Remove expired tokens."""
now = datetime.utcnow()
now = datetime.now(UTC)
expired_tokens = [
token for token, (_, expiry) in self._tokens.items() if now > expiry
]
+2 -6
View File
@@ -80,15 +80,11 @@ def login(
# Check if user exists in database
user = user_repo.get_by_username(credentials.username)
if not user:
raise HTTPException(
status_code=401, detail="Invalid username or password"
)
raise HTTPException(status_code=401, detail="Invalid username or password")
# Verify password using bcrypt
if not verify_password(credentials.password, user["hashed_password"]):
raise HTTPException(
status_code=401, detail="Invalid username or password"
)
raise HTTPException(status_code=401, detail="Invalid username or password")
# Generate a secure random token
access_token = secrets.token_urlsafe(32)
+6
View File
@@ -12,3 +12,9 @@ def pytest_configure(config: pytest.Config) -> None:
tmpdir = tempfile.mkdtemp(prefix="baby_monitor_test_")
os.environ["DATA_DIR"] = tmpdir
os.environ["ENVIRONMENT"] = "development"
# Set admin credentials for tests
if "ADMIN_USERNAME" not in os.environ:
os.environ["ADMIN_USERNAME"] = "admin"
if "ADMIN_PASSWORD" not in os.environ:
os.environ["ADMIN_PASSWORD"] = "password"