Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

refactor(ci): use auth_helper.js for CI user registration

LearningCircuit3054ccb42dcd
diff --git a/.github/workflows/mobile-ui-tests.yml b/.github/workflows/mobile-ui-tests.yml
index 1a96c53905..7129965fc1 100644
--- a/.github/workflows/mobile-ui-tests.yml
+++ b/.github/workflows/mobile-ui-tests.yml
@@ -103,7 +103,8 @@ jobs:
fi
- name: Register CI test user
- run: ./scripts/ci/register_test_user.sh http://127.0.0.1:5000
+ working-directory: tests/ui_tests
+ run: node ../../scripts/ci/register_test_user.js http://127.0.0.1:5000
- name: Run Mobile Navigation Tests
working-directory: tests/ui_tests
diff --git a/.github/workflows/responsive-ui-tests-enhanced.yml b/.github/workflows/responsive-ui-tests-enhanced.yml
index e6fdc50bea..b1be20e277 100644
--- a/.github/workflows/responsive-ui-tests-enhanced.yml
+++ b/.github/workflows/responsive-ui-tests-enhanced.yml
@@ -142,7 +142,8 @@ jobs:
done
- name: Register CI test user
- run: ./scripts/ci/register_test_user.sh http://127.0.0.1:5000
+ working-directory: tests/ui_tests
+ run: node ../../scripts/ci/register_test_user.js http://127.0.0.1:5000
- name: Run responsive UI tests - ${{ matrix.viewport }}
id: run-tests
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index b70ed3396d..10de6b59af 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -354,7 +354,14 @@ jobs:
fi
- name: Register CI test user
- run: ./scripts/ci/register_test_user.sh http://localhost:5000
+ run: |
+ docker run --rm \
+ -v "$PWD":/app \
+ -e CI=true \
+ --network host \
+ -w /app/tests/ui_tests \
+ ldr-test \
+ node /app/scripts/ci/register_test_user.js http://localhost:5000
- name: Run UI tests
run: |
diff --git a/.github/workflows/ui-tests.yml b/.github/workflows/ui-tests.yml
index 9157720884..2c5c935862 100644
--- a/.github/workflows/ui-tests.yml
+++ b/.github/workflows/ui-tests.yml
@@ -125,7 +125,8 @@ jobs:
fi
- name: Register CI test user
- run: ./scripts/ci/register_test_user.sh http://localhost:5000
+ working-directory: tests/ui_tests
+ run: node ../../scripts/ci/register_test_user.js http://localhost:5000
- name: Run UI tests
run: |
diff --git a/scripts/ci/register_test_user.js b/scripts/ci/register_test_user.js
new file mode 100644
index 0000000000..8eb9cb7cfb
--- /dev/null
+++ b/scripts/ci/register_test_user.js
@@ -0,0 +1,70 @@
+#!/usr/bin/env node
+/**
+ * Register CI test user via the real registration flow
+ *
+ * This script uses the same auth_helper.js that tests use,
+ * ensuring we test the actual registration flow.
+ *
+ * Usage: node scripts/ci/register_test_user.js [base_url]
+ */
+
+const puppeteer = require('puppeteer');
+const path = require('path');
+
+// Import auth helper from ui_tests
+const AuthHelper = require(path.join(__dirname, '../../tests/ui_tests/auth_helper.js'));
+const { CI_TEST_USER } = AuthHelper;
+
+const BASE_URL = process.argv[2] || process.env.TEST_BASE_URL || 'http://127.0.0.1:5000';
+
+async function main() {
+ console.log(`Registering CI test user (${CI_TEST_USER.username}) at ${BASE_URL}...`);
+
+ let browser;
+ try {
+ browser = await puppeteer.launch({
+ headless: 'new',
+ args: [
+ '--no-sandbox',
+ '--disable-setuid-sandbox',
+ '--disable-dev-shm-usage',
+ '--disable-gpu'
+ ]
+ });
+
+ const page = await browser.newPage();
+ const auth = new AuthHelper(page, BASE_URL);
+
+ // Try to register the CI test user
+ try {
+ await auth.register(CI_TEST_USER.username, CI_TEST_USER.password);
+ console.log('Registration successful');
+ } catch (regError) {
+ // User might already exist, try to login to verify
+ console.log(`Registration returned: ${regError.message}`);
+ console.log('Attempting login to verify user exists...');
+
+ try {
+ await auth.login(CI_TEST_USER.username, CI_TEST_USER.password);
+ console.log('Login successful - user already exists');
+ } catch (loginError) {
+ console.log(`Login also failed: ${loginError.message}`);
+ console.log('Warning: Could not register or login CI test user');
+ console.log('Tests will fall back to creating their own users');
+ }
+ }
+
+ console.log('CI test user setup complete');
+
+ } catch (error) {
+ console.error('Error during CI test user setup:', error.message);
+ // Don't fail the workflow - tests have their own fallback
+ console.log('Tests will fall back to creating their own users');
+ } finally {
+ if (browser) {
+ await browser.close();
+ }
+ }
+}
+
+main().catch(console.error);
diff --git a/scripts/ci/register_test_user.sh b/scripts/ci/register_test_user.sh
deleted file mode 100755
index dbf77c2d1e..0000000000
--- a/scripts/ci/register_test_user.sh
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/bin/bash
-# Register CI test user via the real registration endpoint
-#
-# This script registers the shared test_admin user for CI tests.
-# It uses the actual /auth/register endpoint to test the real registration flow.
-#
-# Usage: ./scripts/ci/register_test_user.sh [base_url]
-# base_url: Server URL (default: http://localhost:5000)
-#
-# Environment:
-# CI_TEST_USERNAME: Username to register (default: test_admin)
-# CI_TEST_PASSWORD: Password to use (default: testpass123) # pragma: allowlist secret
-
-set -e
-
-BASE_URL="${1:-http://localhost:5000}"
-USERNAME="${CI_TEST_USERNAME:-test_admin}"
-PASSWORD="${CI_TEST_PASSWORD:-testpass123}" # pragma: allowlist secret
-
-echo "Registering CI test user ($USERNAME) at $BASE_URL..."
-
-# Get CSRF token from registration page
-CSRF_TOKEN=$(curl -s "$BASE_URL/auth/register" -c cookies.txt | grep -oP 'name="csrf_token" value="\K[^"]+' || echo "")
-
-if [ -n "$CSRF_TOKEN" ]; then
- REGISTER_RESPONSE=$(curl -s -w "%{http_code}" -X POST "$BASE_URL/auth/register" \
- -H "Content-Type: application/x-www-form-urlencoded" \
- -b cookies.txt -c cookies.txt \
- -d "csrf_token=$CSRF_TOKEN&username=$USERNAME&password=$PASSWORD&confirm_password=$PASSWORD&acknowledge=true" \
- -o /dev/null)
-else
- REGISTER_RESPONSE=$(curl -s -w "%{http_code}" -X POST "$BASE_URL/auth/register" \
- -H "Content-Type: application/x-www-form-urlencoded" \
- -c cookies.txt \
- -d "username=$USERNAME&password=$PASSWORD&confirm_password=$PASSWORD&acknowledge=true" \
- -o /dev/null)
-fi
-
-echo "Registration response code: $REGISTER_RESPONSE"
-
-# 302 = redirect (success), 200 = might have error message, 400 = user exists (ok)
-if [ "$REGISTER_RESPONSE" = "302" ] || [ "$REGISTER_RESPONSE" = "200" ] || [ "$REGISTER_RESPONSE" = "400" ]; then
- echo "Registration completed (user may already exist, which is fine)"
-else
- echo "Warning: Unexpected registration response: $REGISTER_RESPONSE"
-fi
-
-# Verify login works
-echo "Verifying login for $USERNAME..."
-LOGIN_CSRF=$(curl -s "$BASE_URL/auth/login" -c cookies.txt | grep -oP 'name="csrf_token" value="\K[^"]+' || echo "")
-
-if [ -n "$LOGIN_CSRF" ]; then
- LOGIN_RESPONSE=$(curl -s -w "%{http_code}" -X POST "$BASE_URL/auth/login" \
- -H "Content-Type: application/x-www-form-urlencoded" \
- -b cookies.txt -c cookies.txt \
- -d "csrf_token=$LOGIN_CSRF&username=$USERNAME&password=$PASSWORD" \
- -o /dev/null)
-else
- LOGIN_RESPONSE=$(curl -s -w "%{http_code}" -X POST "$BASE_URL/auth/login" \
- -H "Content-Type: application/x-www-form-urlencoded" \
- -c cookies.txt \
- -d "username=$USERNAME&password=$PASSWORD" \
- -o /dev/null)
-fi
-
-echo "Login response code: $LOGIN_RESPONSE"
-
-if [ "$LOGIN_RESPONSE" = "302" ]; then
- echo "CI test user login verified successfully"
-else
- echo "Warning: Login returned $LOGIN_RESPONSE (may still work via UI)"
-fi
-
-rm -f cookies.txt
-echo "CI test user ready"