~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
test(ui): honor guarded engine URLs (#7265)
LearningCircuitbebe8bff7870
diff --git a/tests/ui_tests/test_news_subscription_engine_dropdown_ci.js b/tests/ui_tests/test_news_subscription_engine_dropdown_ci.jsindex 29f8da8b5b..5cb293b44e 100644--- a/tests/ui_tests/test_news_subscription_engine_dropdown_ci.js+++ b/tests/ui_tests/test_news_subscription_engine_dropdown_ci.js@@ -73,6 +73,7 @@ async function readDropdownItems(page) {return items.map((el) => ({value: el.getAttribute('data-value'),disabled: el.classList.contains('ldr-custom-dropdown-item--disabled'),+ ariaDisabled: el.getAttribute('aria-disabled'),reason: el.querySelector('.ldr-dropdown-item-disabled-reason')?.textContent || null,}));}, SEARCH_ENGINE_LIST);@@ -102,8 +103,21 @@ async function setSavedEgressScope(page, baseUrl, value) {async function loadSubscriptionForm(page, url) {const respP = page.waitForResponse(enginesResponseMatcher(), { timeout: 20000 });await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 30000 });- await respP;+ const response = await respP;await page.waitForSelector(SEARCH_ENGINE_INPUT, { timeout: 15000 });+ const payload = await response.json();+ if (!response.ok() || !Array.isArray(payload.engine_options)) {+ throw new Error(`Search-engine API failed while loading ${url}: HTTP ${response.status()}`);+ }+ return new Set(payload.engine_options.filter((o) => o.egress?.allowed === false).map((o) => o.value));+}++function matchesDisabledPolicy(items, policyDenied) {+ const disabled = items.filter((i) => i.disabled);+ const values = new Set(disabled.map((i) => i.value));+ return items.length > 5 && values.size === policyDenied.size &&+ [...values].every((value) => policyDenied.has(value)) &&+ disabled.every((i) => !!i.reason && i.ariaDisabled === 'true');}async function main() {@@ -138,18 +152,19 @@ async function main() {restoreScopeTo = await page.$eval('#policy_egress_scope', (el) => el.value);// ===============================================================- // 1. New-subscription form: default (adaptive) scope -> unfiltered+ // 1. New-subscription form: adaptive scope still guards private URLs// ===============================================================- await run('New form', 'Default/adaptive saved scope: every option enabled (zero impact)', async () => {+ let adaptiveDeniedValues = null;+ await run('New form', 'Default/adaptive saved scope matches guarded URL decisions', async () => {await setSavedEgressScope(page, baseUrl, 'adaptive');- await loadSubscriptionForm(page, `${baseUrl}/news/subscriptions/new`);+ adaptiveDeniedValues = await loadSubscriptionForm(page, `${baseUrl}/news/subscriptions/new`);await openSearchEngineDropdown(page);const items = await readDropdownItems(page);await closeOpenDropdown(page);const disabled = items.filter((i) => i.disabled);return {- passed: items.length > 5 && disabled.length === 0,- message: `${items.length} items rendered, ${disabled.length} disabled (want 0)`,+ passed: matchesDisabledPolicy(items, adaptiveDeniedValues),+ message: `${items.length} items rendered, ${disabled.length} disabled (API guarded=${adaptiveDeniedValues.size})`,};});@@ -159,7 +174,7 @@ async function main() {let privateOnlyDisabledValues = null;await run('New form', 'Saved private_only scope disables non-local engines with a reason', async () => {await setSavedEgressScope(page, baseUrl, 'private_only');- await loadSubscriptionForm(page, `${baseUrl}/news/subscriptions/new`);+ const policyDenied = await loadSubscriptionForm(page, `${baseUrl}/news/subscriptions/new`);await openSearchEngineDropdown(page);const items = await readDropdownItems(page);await closeOpenDropdown(page);@@ -169,7 +184,8 @@ async function main() {const reasonsLookRight = disabled.every((i) => /blocked/i.test(i.reason || ''));privateOnlyDisabledValues = new Set(disabled.map((i) => i.value));- const passed = items.length > 5 && disabled.length > 0 && disabledWithoutReason.length === 0 && reasonsLookRight;+ const passed = matchesDisabledPolicy(items, policyDenied) && disabled.length > 0 &&+ disabledWithoutReason.length === 0 && reasonsLookRight;return {passed,message: passed@@ -213,26 +229,29 @@ async function main() {});// ===============================================================- // 4. Edit-subscription form: default scope -> unfiltered (zero impact)+ // 4. Edit-subscription form: adaptive scope preserves the URL guard// ===============================================================- await run('Edit form', 'Default/adaptive saved scope: edit form shows every option enabled too', async () => {+ await run('Edit form', 'Default/adaptive saved scope retains the new form guarded set', async () => {if (!seededSub) {return { passed: null, skipped: true, message: 'No seeded subscription available' };}await setSavedEgressScope(page, baseUrl, 'adaptive');- await loadSubscriptionForm(page, `${baseUrl}/news/subscriptions/${seededSub.id}/edit`);+ const editPolicyDenied = await loadSubscriptionForm(page, `${baseUrl}/news/subscriptions/${seededSub.id}/edit`);await openSearchEngineDropdown(page);const items = await readDropdownItems(page);await closeOpenDropdown(page);const disabled = items.filter((i) => i.disabled);+ const sameAsNew = adaptiveDeniedValues && editPolicyDenied.size === adaptiveDeniedValues.size &&+ [...editPolicyDenied].every((value) => adaptiveDeniedValues.has(value));return {- passed: items.length > 5 && disabled.length === 0,- message: `${items.length} items rendered, ${disabled.length} disabled (want 0)`,+ passed: !!sameAsNew && matchesDisabledPolicy(items, editPolicyDenied),+ message: `${items.length} items rendered, ${disabled.length} disabled (API guarded=${editPolicyDenied.size}, matches new=${!!sameAsNew})`,};});} catch (error) {log.error(`Fatal error: ${error.message}`);console.error(error.stack);+ results.add('Suite', 'Unexpected Suite Error', false, error.message);} finally {try {if (seededSub) await deleteSubscription(page, seededSub.id);diff --git a/tests/ui_tests/test_search_engine_dropdown_scope_ci.js b/tests/ui_tests/test_search_engine_dropdown_scope_ci.jsindex bc8255c7a0..100533e426 100644--- a/tests/ui_tests/test_search_engine_dropdown_scope_ci.js+++ b/tests/ui_tests/test_search_engine_dropdown_scope_ci.js@@ -12,13 +12,13 @@* together in a browser before this suite.** What this proves, end to end (server response -> DOM):- * 1. GET /settings/api/available-search-engines?egress_scope=&primary=+ * 1. GET /settings/api/available-search-engines?egress_scope=private_only&primary=searxng* stamps every option with egress:{allowed,reason}, and the rendered* dropdown disables exactly the denied ones (aria-disabled + a* visible reason), never more, never fewer.* 2. The same endpoint WITHOUT those query params (or with them blank)- * returns the historical, unfiltered shape — zero behavior impact on- * existing callers — and the dropdown shows every option enabled.+ * skips scope classification but still marks unapproved private+ * instance URLs, and the adaptive dropdown disables exactly those.* 3. An engine option carrying agent_enabled:false (collections only)* is disabled precisely when the LangGraph Agent strategy is* selected, and re-enabled the instant a different strategy is@@ -46,6 +46,11 @@ const ENGINES_PATH_SUFFIX = '/settings/api/available-search-engines';// contract test above exercises directly.const FILTERED_SCOPES = new Set(['private_only', 'public_only']);+function sameValueSet(left, right) {+ return !!left && !!right && left.size === right.size &&+ [...left].every((value) => right.has(value));+}+/*** Puppeteer response predicate for GET .../available-search-engines.* - scope undefined: matches any request to the endpoint.@@ -251,7 +256,9 @@ async function main() {// Cross-test state shared by the DOM-classification test and the// live-reconciliation test that depends on its findings.let deniedUnderPrivateOnly = null; // { value, reason }+ let deniedValuesUnderPrivateOnly = null; // Set<string>let allowedUnderPrivateOnly = null; // Set<string>+ let deniedUnderAdaptive = null; // Set<string> blocked by the guarded URL overlaylet seededCollection = null;let restoreScopeTo = 'adaptive';let restoreStrategyTo = null;@@ -290,29 +297,30 @@ async function main() {// ===============================================================// 1. API contract// ===============================================================- await run('API contract', 'No query params returns the historical, unfiltered shape', async () => {+ await run('API contract', 'No query params only marks unapproved private instance URLs', async () => {const r = await fetchEngineOptions(page, '');if (!r.ok || !Array.isArray(r.data.engine_options) || r.data.engine_options.length === 0) {return { passed: false, message: `Bad/empty response: ${JSON.stringify(r).slice(0, 200)}` };}- const anyEgress = r.data.engine_options.some((o) => 'egress' in o);+ const marked = r.data.engine_options.filter((o) => 'egress' in o);+ deniedUnderAdaptive = new Set(marked.map((o) => o.value));+ const unexpected = marked.filter((o) => o.egress?.allowed !== false || o.egress?.reason !== 'private_url_unapproved');return {- passed: !anyEgress,- message: anyEgress- ? 'Unfiltered response unexpectedly carries an egress field on at least one option'- : `${r.data.engine_options.length} options returned, none carry an egress field`,+ passed: unexpected.length === 0,+ message: `${r.data.engine_options.length} options, ${marked.length} guarded URLs, ${unexpected.length} unexpected egress decisions`,};});- await run('API contract', 'Blank egress_scope/primary also falls back to unfiltered shape', async () => {+ await run('API contract', 'Blank egress_scope/primary preserves the guarded URL overlay', async () => {const r = await fetchEngineOptions(page, '?egress_scope=&primary=');if (!r.ok) return { passed: false, message: `HTTP ${r.status}` };- const anyEgress = r.data.engine_options.some((o) => 'egress' in o);+ const marked = r.data.engine_options.filter((o) => 'egress' in o);+ const markedValues = new Set(marked.map((o) => o.value));+ const unexpected = marked.filter((o) => o.egress?.allowed !== false || o.egress?.reason !== 'private_url_unapproved');+ const sameSet = sameValueSet(markedValues, deniedUnderAdaptive);return {- passed: !anyEgress,- message: anyEgress- ? 'Blank egress_scope param unexpectedly triggered filtering'- : 'Blank query params behave identically to absent params',+ passed: !!sameSet && unexpected.length === 0,+ message: `blank params: ${marked.length} guarded URLs, same as absent=${!!sameSet}, unexpected=${unexpected.length}`,};});@@ -325,9 +333,13 @@ async function main() {const allowed = opts.filter((o) => o.egress && o.egress.allowed === true);const deniedWithoutReason = denied.filter((o) => !o.egress.reason);- if (denied.length > 0) {- deniedUnderPrivateOnly = { value: denied[0].value, reason: denied[0].egress.reason };+ // A guarded private URL is denied even in adaptive scope. Choose+ // an option that is selectable before switching scopes below.+ const reconcilable = denied.find((o) => !deniedUnderAdaptive?.has(o.value));+ if (reconcilable) {+ deniedUnderPrivateOnly = { value: reconcilable.value, reason: reconcilable.egress.reason };}+ deniedValuesUnderPrivateOnly = new Set(denied.map((o) => o.value));allowedUnderPrivateOnly = new Set(allowed.map((o) => o.value));const passed = missing.length === 0 && denied.length > 0 && allowed.length > 0 && deniedWithoutReason.length === 0;@@ -344,7 +356,7 @@ async function main() {// ===============================================================// 2. DOM: dropdown rendering matches the API classification// ===============================================================- await run('Dropdown DOM', 'Adaptive scope: every dropdown item is enabled (zero impact)', async () => {+ await run('Dropdown DOM', 'Adaptive scope disables exactly the guarded private URLs', async () => {// Same registry-snapshot race as setNonLangGraphBaselineAndVerify: a// still-in-flight refresh from setup can occasionally paint one more// stale frame after this test's own read. Re-verify via a forced@@ -355,21 +367,24 @@ async function main() {await openSearchEngineDropdown(page);items = await readDropdownItems(page);await closeOpenDropdown(page);- if (!items.some((i) => i.disabled)) break;+ const disabledNow = new Set(items.filter((i) => i.disabled).map((i) => i.value));+ if (sameValueSet(disabledNow, deniedUnderAdaptive)) break;await forceRefreshEngineList(page);}const disabled = items.filter((i) => i.disabled);+ const disabledValues = new Set(disabled.map((i) => i.value));+ const sameSet = sameValueSet(disabledValues, deniedUnderAdaptive);return {- passed: items.length > 5 && disabled.length === 0,+ passed: items.length > 5 && !!sameSet && disabled.every((i) => i.reason && i.ariaDisabled === 'true'),message:- `${items.length} items rendered, ${disabled.length} disabled (want 0)` ++ `${items.length} items rendered, ${disabled.length} disabled (API guarded=${deniedUnderAdaptive?.size ?? 'unknown'})` +(disabled.length > 0 ? ` [${disabled.map((i) => `${i.value}: ${i.reason}`).join('; ')}]` : ''),};});await run('Dropdown DOM', 'Private-only scope disables exactly the API-denied engines, with a reason', async () => {- if (!allowedUnderPrivateOnly || !deniedUnderPrivateOnly) {- return { passed: null, skipped: true, message: 'API classification test did not produce a denied/allowed set' };+ if (!deniedValuesUnderPrivateOnly || !allowedUnderPrivateOnly) {+ return { passed: false, message: 'API classification test did not produce a denied/allowed set' };}await selectScopeAndWait(page, 'private_only');await openSearchEngineDropdown(page);@@ -377,8 +392,8 @@ async function main() {await closeOpenDropdown(page);const domDisabledValues = new Set(items.filter((i) => i.disabled).map((i) => i.value));- const wronglyEnabled = items.filter((i) => !domDisabledValues.has(i.value) && i.value === deniedUnderPrivateOnly.value);- const wronglyDisabled = items.filter((i) => domDisabledValues.has(i.value) && allowedUnderPrivateOnly.has(i.value));+ const wronglyEnabled = [...deniedValuesUnderPrivateOnly].filter((value) => !domDisabledValues.has(value));+ const wronglyDisabled = [...domDisabledValues].filter((value) => !deniedValuesUnderPrivateOnly.has(value));const disabledWithoutReasonText = items.filter((i) => i.disabled && !i.reason);const disabledWithoutAria = items.filter((i) => i.disabled && i.ariaDisabled !== 'true');@@ -393,8 +408,8 @@ async function main() {passed,message: passed? `${domDisabledValues.size} items disabled in the DOM, all matching the API's denied set ` +- `(e.g. "${deniedUnderPrivateOnly.value}": "${deniedUnderPrivateOnly.reason}")`- : `wronglyEnabled=${wronglyEnabled.map((i) => i.value)} wronglyDisabled=${wronglyDisabled.map((i) => i.value)} ` ++ `(e.g. "${deniedUnderPrivateOnly?.value}": "${deniedUnderPrivateOnly?.reason}")`+ : `wronglyEnabled=${wronglyEnabled} wronglyDisabled=${wronglyDisabled} ` +`missingReasonText=${disabledWithoutReasonText.length} missingAria=${disabledWithoutAria.length}`,};});@@ -404,9 +419,9 @@ async function main() {// ===============================================================await run('Live reconciliation', 'Selecting a to-be-denied primary then switching scope reconciles the selection', async () => {if (!deniedUnderPrivateOnly) {- return { passed: null, skipped: true, message: 'No denied-under-private_only candidate discovered earlier' };+ return { passed: false, message: 'No selectable adaptive engine that becomes denied under private_only was discovered' };}- // Back to adaptive (unfiltered) so the denied-under-private_only engine is selectable.+ // Back to adaptive so this scope-specific denied engine is selectable.await selectScopeAndWait(page, 'adaptive');await openSearchEngineDropdown(page);const itemHandle = await page.$(`#search-engine-dropdown-list [data-value="${deniedUnderPrivateOnly.value}"]`);@@ -542,6 +557,7 @@ async function main() {} catch (error) {log.error(`Fatal error: ${error.message}`);console.error(error.stack);+ results.add('Suite', 'Unexpected Suite Error', false, error.message);} finally {// Best-effort cleanup — never let a cleanup failure mask the test results above.try {