Fix empty string handling for test password env var

This commit is contained in:
Mondo Diaz
2026-01-27 19:30:08 +00:00
parent 4fc8ca66e7
commit 15954b58f7

View File

@@ -68,12 +68,13 @@ def get_admin_password() -> str:
Returns the password from ORCHARD_TEST_PASSWORD environment variable,
or 'changeme123' as the default for local development.
"""
return os.environ.get("ORCHARD_TEST_PASSWORD", "changeme123")
# Use 'or' to handle empty string (when CI variable is undefined)
return os.environ.get("ORCHARD_TEST_PASSWORD") or "changeme123"
def get_admin_username() -> str:
"""Get the admin username for test authentication."""
return os.environ.get("ORCHARD_TEST_USERNAME", "admin")
return os.environ.get("ORCHARD_TEST_USERNAME") or "admin"
# Re-export factory functions for backward compatibility
@@ -248,9 +249,9 @@ def integration_client():
import httpx
# Connect to the running orchard-server container or deployed environment
base_url = os.environ.get("ORCHARD_TEST_URL", "http://localhost:8080")
username = os.environ.get("ORCHARD_TEST_USERNAME", "admin")
password = os.environ.get("ORCHARD_TEST_PASSWORD", "changeme123")
base_url = os.environ.get("ORCHARD_TEST_URL") or "http://localhost:8080"
username = get_admin_username()
password = get_admin_password()
with httpx.Client(base_url=base_url, timeout=30.0) as client:
# Login as admin to enable write operations