~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix: Fix CSRF token and logs API handling in api_tests_with_login
LearningCircuitee6ce8473285
diff --git a/tests/api_tests_with_login/auth_helper.js b/tests/api_tests_with_login/auth_helper.jsindex 2b05ad20ab..8fa9ae2e1a 100644--- a/tests/api_tests_with_login/auth_helper.js+++ b/tests/api_tests_with_login/auth_helper.js@@ -101,6 +101,15 @@ async function authenticate(baseUrl, username, password, cookieFile) {console.log('Login completed');}+ // After login/registration, navigate to home page to ensure we have CSRF token+ const currentUrl = page.url();+ if (!currentUrl.includes('/auth/')) {+ console.log('Already on app page, good for CSRF token');+ } else {+ console.log('Navigating to home page to get CSRF token...');+ await page.goto(baseUrl, { waitUntil: 'networkidle0', timeout: 30000 });+ }+// Get cookiesconst cookies = await page.cookies();console.log(`Got ${cookies.length} cookies`);@@ -109,38 +118,42 @@ async function authenticate(baseUrl, username, password, cookieFile) {const cookieNames = cookies.map(c => c.name);console.log('Cookie names:', cookieNames.join(', '));- // Try to get CSRF token from page meta tag if not in cookies+ // Try to get CSRF token - Flask-WTF doesn't use cookies for CSRF, it uses session+ // We need to get it from the pagelet csrfToken = null;- for (const cookie of cookies) {- if (cookie.name === 'csrf_token') {- csrfToken = cookie.value;- break;- }- }- if (!csrfToken) {- console.log('CSRF token not found in cookies, checking page meta tag...');- try {+ console.log('Getting CSRF token from page meta tag...');+ try {+ csrfToken = await page.evaluate(() => {+ const metaTag = document.querySelector('meta[name="csrf-token"]');+ return metaTag ? metaTag.getAttribute('content') : null;+ });++ if (!csrfToken) {+ // Try to find it in a formcsrfToken = await page.evaluate(() => {- const metaTag = document.querySelector('meta[name="csrf-token"]');- return metaTag ? metaTag.getAttribute('content') : null;+ const csrfInput = document.querySelector('input[name="csrf_token"]');+ return csrfInput ? csrfInput.value : null;});- if (csrfToken) {- console.log('Found CSRF token in meta tag');- // Add it as a cookie for compatibility- cookies.push({- name: 'csrf_token',- value: csrfToken,- domain: new URL(baseUrl).hostname,- path: '/',- httpOnly: false,- secure: false,- sameSite: 'Lax'- });- }- } catch (e) {- console.log('Could not get CSRF token from page:', e.message);}++ if (csrfToken) {+ console.log('Found CSRF token:', csrfToken.substring(0, 10) + '...');+ // Add it as a cookie for compatibility with the test framework+ cookies.push({+ name: 'csrf_token',+ value: csrfToken,+ domain: new URL(baseUrl).hostname,+ path: '/',+ httpOnly: false,+ secure: false,+ sameSite: 'Lax'+ });+ } else {+ console.log('WARNING: Could not find CSRF token on page');+ }+ } catch (e) {+ console.log('Error getting CSRF token from page:', e.message);}// Save to filediff --git a/tests/api_tests_with_login/test_research_api_pytest.py b/tests/api_tests_with_login/test_research_api_pytest.pyindex f4aa8f7a1d..b142b72fab 100644--- a/tests/api_tests_with_login/test_research_api_pytest.py+++ b/tests/api_tests_with_login/test_research_api_pytest.py@@ -146,7 +146,11 @@ class TestResearchAPI:)if logs_response.status_code == 200:logs_data = logs_response.json()- logs = logs_data.get("logs", [])+ # Handle both list and dict responses+ if isinstance(logs_data, list):+ logs = logs_data+ else:+ logs = logs_data.get("logs", [])# Check if model appears in logsmodel_found = False