-
Notifications
You must be signed in to change notification settings - Fork 5
fix: Add WebSocket health check and E2E test authentication #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
743dc3e
7fec1b8
0a461b0
6b370bf
13ea406
a488d6c
6e97c22
efd4acd
3cf6b5a
64a85db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,7 +87,7 @@ export default defineConfig({ | |
| // Backend FastAPI server | ||
| { | ||
| command: `cd ../.. && DATABASE_PATH=${TEST_DB_PATH} uv run uvicorn codeframe.ui.server:app --port 8080`, | ||
| url: 'http://localhost:8080/health', | ||
| url: 'http://localhost:8080/ws/health', | ||
| reuseExistingServer: !process.env.CI, | ||
| timeout: 120000, | ||
| }, | ||
|
Comment on lines
88
to
93
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: find . -name "server.py" -type f | head -20Repository: frankbria/codeframe Length of output: 87 🏁 Script executed: fd -t f "server\.(py|ts)" --max-results 20Repository: frankbria/codeframe Length of output: 114 🏁 Script executed: wc -l codeframe/ui/server.pyRepository: frankbria/codeframe Length of output: 89 🏁 Script executed: cat -n codeframe/ui/server.pyRepository: frankbria/codeframe Length of output: 14286 🏁 Script executed: fd -t f "websocket" codeframe/ui/routers/Repository: frankbria/codeframe Length of output: 96 🏁 Script executed: cat -n codeframe/ui/routers/websocket.pyRepository: frankbria/codeframe Length of output: 13164 🏁 Script executed: grep -n "get_db_websocket" codeframe/ui/dependencies.pyRepository: frankbria/codeframe Length of output: 253 🏁 Script executed: cat codeframe/ui/dependencies.pyRepository: frankbria/codeframe Length of output: 1873 Revert to Switching to Either: restore the 🤖 Prompt for AI Agents |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,56 @@ def seed_test_data(db_path: str, project_id: int): | |
| now = datetime(2025, 1, 15, 10, 0, 0) | ||
| now_ts = now.isoformat() | ||
|
|
||
| # ======================================== | ||
| # 0. Seed Test User (for authentication) | ||
| # ======================================== | ||
| # ⚠️ SECURITY WARNING: Test credentials only | ||
| # This seeding creates a test user with a KNOWN password and session token. | ||
| # NEVER use these credentials in production environments! | ||
| # - Test password: 'testpassword123' (bcrypt hashed) | ||
| # - Test session token: hardcoded, predictable value | ||
| # - Only safe for local E2E testing where AUTH_REQUIRED=false | ||
| print("👤 Seeding test user...") | ||
| # Hash: bcrypt hash of 'testpassword123' | ||
| # Generated with: python -c "import bcrypt; print(bcrypt.hashpw(b'testpassword123', bcrypt.gensalt()).decode())" | ||
| test_user_password_hash = "$2b$12$LQv3c1yqBWVHxkd0LHAkCOYz6TtxMQJqhN8/LewY5GyYb9K0rJ5n6" | ||
|
|
||
| cursor.execute( | ||
| """ | ||
| INSERT OR REPLACE INTO users (id, email, password_hash, name, created_at, updated_at) | ||
| VALUES (?, ?, ?, ?, ?, ?) | ||
| """, | ||
| ( | ||
| 1, | ||
| "test@example.com", | ||
| test_user_password_hash, | ||
| "E2E Test User", | ||
| now_ts, | ||
| now_ts, | ||
| ), | ||
| ) | ||
|
|
||
| # Create a session for the test user (expires in 7 days) | ||
| session_token = "test-session-token-12345678901234567890" | ||
| expires_at = (now + timedelta(days=7)).isoformat() | ||
|
|
||
| cursor.execute( | ||
| """ | ||
| INSERT OR REPLACE INTO sessions (token, user_id, expires_at, created_at) | ||
| VALUES (?, ?, ?, ?) | ||
| """, | ||
| (session_token, 1, expires_at, now_ts), | ||
| ) | ||
|
Comment on lines
+76
to
+86
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Session expiry is calculated from a fixed past date, causing immediate expiration. The session 🔎 Proposed fix: Use actual current time for session expiry # Create a session for the test user (expires in 7 days)
session_token = "test-session-token-12345678901234567890"
- expires_at = (now + timedelta(days=7)).isoformat()
+ # Use actual current time for session expiry to ensure token is valid
+ expires_at = (datetime.now() + timedelta(days=7)).isoformat()🤖 Prompt for AI Agents |
||
|
|
||
| print("✅ Seeded test user (email: test@example.com)") | ||
| print(f" Session token: {session_token[:20]}...") | ||
|
|
||
| # Export session token for tests to use via output file | ||
| # Write to a file that global-setup.ts can read | ||
| token_file = os.path.join(os.path.dirname(db_path), "test-session-token.txt") | ||
| with open(token_file, "w") as f: | ||
| f.write(session_token) | ||
|
|
||
| # ======================================== | ||
| # 1. Seed Agents (5) | ||
| # ======================================== | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add security warning comments for test credentials.
According to the PR objectives, "security-warning comments for test credentials" was a recommended change from review feedback. However, the hardcoded test credentials (lines 146-147, 151-152) lack any security warnings.
Additionally, logging the plaintext password (line 147) is not ideal even for test credentials, as these logs may be captured in CI/CD systems.
🔎 Recommended security improvements
console.log('✅ Test user session loaded'); + // ⚠️ SECURITY WARNING: These are test-only credentials. + // NEVER use these credentials in production or commit real credentials to the repository. console.log(` Email: test@example.com`); - console.log(` Password: testpassword123`); + console.log(` Password: [test password - see source]`); console.log(` Session token: ${sessionToken.substring(0, 20)}...`); // Store credentials for tests to use + // ⚠️ SECURITY WARNING: Test credentials only. Do not use in production. process.env.E2E_TEST_USER_EMAIL = 'test@example.com'; process.env.E2E_TEST_USER_PASSWORD = 'testpassword123'; process.env.E2E_TEST_SESSION_TOKEN = sessionToken;📝 Committable suggestion
🤖 Prompt for AI Agents