searx: Add option to allow public access to the application

[jvalleroy] Resolved merge conflict to use shortcut component.

Fixes #1590

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati authored and James Valleroy committed 2019-06-09 10:37:16 -04:00
1 parent 6a9133c305
commit 2d85b61199
10 files changed
+138 -22

No files matched your search

+15
View File
@@ -38,3 +38,18 @@ Scenario: Disable searx application
Given the searx application is enabled
When I disable the searx application
Then the searx site should not be available
Scenario: Enable public access
Given the searx application is enabled
And I enable public access in searx
And I'm a logged out user
Then searx app should be visible on the front page
And the searx site should be available
Scenario: Disable public access
Given the searx application is enabled
And I disable public access in searx
And I'm a logged out user
Then searx app should not be visible on the front page
And the searx site should not be available
@@ -423,3 +423,26 @@ def openvpn_profile_downloadable(browser):
def openvpn_profile_download_compare(browser, openvpn_download_profile):
new_profile = application.openvpn_download_profile(browser)
assert openvpn_download_profile == new_profile
@given('I enable public access in searx')
def searx_enable_public_access(browser):
application.searx_enable_public_access(browser)
@given('I disable public access in searx')
def searx_disable_public_access(browser):
application.searx_disable_public_access(browser)
@then(parsers.parse('{app_name:w} app should be visible on the front page'))
def app_visible_on_front_page(browser, app_name):
shortcuts = application.find_on_front_page(browser, app_name)
assert len(shortcuts) == 1
@then(
parsers.parse('{app_name:w} app should not be visible on the front page'))
def app_visible_on_front_page(browser, app_name):
shortcuts = application.find_on_front_page(browser, app_name)
assert len(shortcuts) == 0
+20
View File
@@ -469,3 +469,23 @@ def openvpn_download_profile(browser):
interface.nav_to_module(browser, 'openvpn')
url = browser.find_by_css('.form-profile')['action']
return _download_file(browser, url)
def searx_enable_public_access(browser):
"""Enable Public Access in SearX"""
interface.nav_to_module(browser, 'searx')
browser.find_by_id('id_public_access').check()
interface.submit(browser, form_class='form-configuration')
def searx_disable_public_access(browser):
"""Enable Public Access in SearX"""
interface.nav_to_module(browser, 'searx')
browser.find_by_id('id_public_access').uncheck()
interface.submit(browser, form_class='form-configuration')
def find_on_front_page(browser, app_name):
browser.visit(default_url)
shortcuts = browser.find_link_by_href(f'/{app_name}/')
return shortcuts
+6 -3
View File
@@ -21,7 +21,6 @@ import pathlib
import time
import requests
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
@@ -45,10 +44,14 @@ def get_site_url(site_name):
def is_available(browser, site_name):
browser.visit(config['DEFAULT']['url'] + get_site_url(site_name))
url_to_visit = config['DEFAULT']['url'] + get_site_url(site_name)
browser.visit(url_to_visit)
time.sleep(3)
browser.reload()
return '404' not in browser.title
not_404 = '404' not in browser.title
# A trailing slash might be appended by Apache redirect rules
no_redirect = url_to_visit.strip('/') == browser.url.strip('/')
return not_404 and no_redirect
def access_url(browser, site_name):