~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: correct SSRF test selectors, endpoints, and add real assertions (#2197)
LearningCircuit8bd7634f0353
diff --git a/tests/puppeteer/test_deep_functionality.js b/tests/puppeteer/test_deep_functionality.jsindex 593b7236c1..3f654f12e8 100644--- a/tests/puppeteer/test_deep_functionality.js+++ b/tests/puppeteer/test_deep_functionality.js@@ -656,6 +656,100 @@ describe('Deep Functionality Tests', function() {});});++ describe('Research API Workflow', () => {+ it('should start a research task and verify it in history', async () => {+ console.log('\n--- Test: Start research via API and verify in history ---');++ // Navigate to home page to have a valid page context+ await page.goto(`${BASE_URL}/`, { waitUntil: 'domcontentloaded' });++ // Start research via API (CSRF-exempt under /research/api/, session cookie auto-sent)+ const startResult = await page.evaluate(async (baseUrl) => {+ try {+ const res = await fetch(`${baseUrl}/research/api/start_research`, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify({+ query: 'What is 2+2?',+ mode: 'quick',+ model_provider: 'openrouter',+ model: 'google/gemini-2.0-flash-001',+ search_engine: 'serper'+ })+ });+ const text = await res.text();+ return { status: res.status, body: text.substring(0, 500) };+ } catch (e) {+ return { error: e.message };+ }+ }, BASE_URL);++ console.log('Start research result:', JSON.stringify(startResult, null, 2));+ expect(startResult.error).to.be.undefined;+ expect(startResult.status).to.equal(200);++ // Extract research ID+ const startData = JSON.parse(startResult.body);+ const researchId = startData.research_id;+ expect(researchId).to.be.a('string');+ console.log(` Research ID: ${researchId}`);++ // Verify it appears in history+ await delay(2000);+ const historyResult = await page.evaluate(async (baseUrl) => {+ try {+ const res = await fetch(`${baseUrl}/api/history`);+ return { status: res.status, body: await res.text() };+ } catch (e) {+ return { error: e.message };+ }+ }, BASE_URL);++ expect(historyResult.status).to.equal(200);+ const historyData = JSON.parse(historyResult.body);+ const found = historyData.items && historyData.items.some(item => item.id === researchId);+ console.log(` Research found in history: ${found}`);+ expect(found).to.be.true;++ // Brief check for status progression+ await delay(5000);+ const statusResult = await page.evaluate(async (baseUrl, id) => {+ try {+ const res = await fetch(`${baseUrl}/api/research/${id}/status`);+ const data = await res.json();+ return { status: res.status, research_status: data.status };+ } catch (e) {+ return { error: e.message };+ }+ }, BASE_URL, researchId);++ console.log(` Research status: ${statusResult.research_status}`);+ // Accept any valid status - research may still be running or may have errored+ const validStatuses = ['queued', 'in_progress', 'completed', 'error', 'pending', 'suspended'];+ expect(validStatuses).to.include(statusResult.research_status);++ // Terminate research to avoid side effects on subsequent tests+ // /api/terminate/{id} is NOT CSRF-exempt, so we need the CSRF token from meta tag+ const csrfForTerminate = await page.$eval('meta[name="csrf-token"]', el => el.content).catch(() => null);+ if (csrfForTerminate) {+ await page.evaluate(async (baseUrl, id, csrf) => {+ try {+ await fetch(`${baseUrl}/api/terminate/${id}`, {+ method: 'POST',+ headers: { 'X-CSRFToken': csrf }+ });+ } catch (e) {+ // Ignore cleanup errors+ }+ }, BASE_URL, researchId, csrfForTerminate);+ console.log(' Research terminated for cleanup');+ } else {+ console.log(' Could not get CSRF token for cleanup - research will be cleaned up on browser close');+ }+ });+ });+describe('News Subscription Creation', () => {it('should navigate to new subscription form', async () => {await page.goto(`${BASE_URL}/news/subscriptions/new`, { waitUntil: 'domcontentloaded' });diff --git a/tests/puppeteer/test_ssrf_protection.js b/tests/puppeteer/test_ssrf_protection.jsindex 97e0a62a2b..217971c8cb 100644--- a/tests/puppeteer/test_ssrf_protection.js+++ b/tests/puppeteer/test_ssrf_protection.js@@ -237,7 +237,7 @@ describe('SSRF Protection - Functionality Tests', function() {const endpoints = ['/api/settings',- '/api/research/history',+ '/api/history',];for (const endpoint of endpoints) {@@ -253,12 +253,12 @@ describe('SSRF Protection - Functionality Tests', function() {console.log(`API ${endpoint}:`, JSON.stringify(response, null, 2));- if (response.status) {- expect(response.status).to.not.equal(500,- `Endpoint ${endpoint} returned 500 error`);- }+ expect(response.error).to.be.undefined;+ expect(response.status).to.equal(200,+ `Endpoint ${endpoint} should return 200`);}});+});describe('News API Functionality', () => {@@ -286,7 +286,7 @@ describe('SSRF Protection - Functionality Tests', function() {const response = await page.evaluate(async (baseUrl) => {try {- const res = await fetch(`${baseUrl}/news/api/briefings`);+ const res = await fetch(`${baseUrl}/news/api/feed`);const text = await res.text();return { status: res.status, ok: res.ok, body: text.substring(0, 300) };} catch (e) {@@ -294,11 +294,11 @@ describe('SSRF Protection - Functionality Tests', function() {}}, BASE_URL);- console.log('News briefings API:', JSON.stringify(response, null, 2));+ console.log('News feed API:', JSON.stringify(response, null, 2));- if (response.status) {- expect(response.status).to.not.equal(500);- }+ expect(response.error).to.be.undefined;+ expect(response.status).to.equal(200,+ 'News feed endpoint should return 200');});});@@ -325,8 +325,8 @@ describe('SSRF Protection - Functionality Tests', function() {console.log('\n--- Test: Library API endpoints ---');const endpoints = [- '/library/api/resources',- '/library/api/sources',+ '/library/api/stats',+ '/library/api/documents',];for (const endpoint of endpoints) {@@ -342,24 +342,32 @@ describe('SSRF Protection - Functionality Tests', function() {console.log(`Library API ${endpoint}:`, JSON.stringify(response, null, 2));- if (response.status) {- expect(response.status).to.not.equal(500,- `Library endpoint ${endpoint} returned 500 error`);- }+ expect(response.error).to.be.undefined;+ expect(response.status).to.equal(200,+ `Library endpoint ${endpoint} should return 200`);}});it('should handle download-source endpoint gracefully', async () => {console.log('\n--- Test: Download source endpoint ---');- const response = await page.evaluate(async (baseUrl) => {+ // Navigate to /library to get a fresh CSRF token from the page+ await page.goto(`${BASE_URL}/library`, { waitUntil: 'domcontentloaded' });++ const csrfToken = await page.$eval('meta[name="csrf-token"]', el => el.content).catch(() => null);+ console.log(`CSRF token available: ${csrfToken !== null}`);++ const response = await page.evaluate(async (baseUrl, csrf) => {try {const res = await fetch(`${baseUrl}/library/api/download-source`, {method: 'POST',- headers: { 'Content-Type': 'application/json' },+ headers: {+ 'Content-Type': 'application/json',+ 'X-CSRFToken': csrf+ },body: JSON.stringify({url: 'https://example.com/test.pdf',- resource_id: 'test-123'+ research_id: 'test-123'})});const text = await res.text();@@ -367,14 +375,14 @@ describe('SSRF Protection - Functionality Tests', function() {} catch (e) {return { error: e.message };}- }, BASE_URL);+ }, BASE_URL, csrfToken);console.log('Download-source API:', JSON.stringify(response, null, 2));- if (response.status) {- expect(response.status).to.not.equal(500,- 'Download endpoint crashed with 500 error');- }+ expect(response.error).to.be.undefined;+ // With valid CSRF token, endpoint returns 404 "Resource not found" for fake research_id+ expect(response.status).to.equal(404,+ 'Download endpoint should return 404 for non-existent resource');});});@@ -387,10 +395,27 @@ describe('SSRF Protection - Functionality Tests', function() {const url = page.url();console.log(`Current URL: ${url}`);+ // Wait for settings to finish loading (spinner is in static HTML, removed after API fetch + render)+ await page.waitForFunction(+ () => !document.querySelector('.ldr-loading-spinner'),+ { timeout: 10000 }+ );+ console.log('Settings loaded (spinner gone)');+await screenshot(page, '07-search-settings');- const searchSection = await page.$('[data-section="search"], #search-settings, .search-engines');- console.log(`Found search settings section: ${searchSection !== null}`);+ // Click the Search Engines tab+ const searchTab = await page.$('[data-tab="search"]');+ expect(searchTab).to.not.be.null;+ await searchTab.click();++ // Wait for search-specific sections to render+ await page.waitForSelector('[id^="section-search-"]', { timeout: 5000 });+ const searchSections = await page.$$('[id^="section-search-"]');+ console.log(`Found search settings sections: ${searchSections.length}`);+ expect(searchSections.length).to.be.greaterThan(0);++ await screenshot(page, '07b-search-tab-active');const bodyText = await page.$eval('body', el => el.innerText);expect(bodyText.toLowerCase()).to.not.include('internal server error');