syncthing: Hide unnecessary security warning

- Hide the warning 'The Syncthing admin interface is configured to allow
remote access without a password. ... '. This warning is unnecessary because
we are using authentication through Apache.

- Hide the usage reporting notification by declining reporting, if the user
has not made a choice yet.

- Call add_user_to_share_group() in setup() before starting syncthing to
avoid another syncthing daemon restart.

- Add a functional test for hidden notification messages.

- Functional tests: Improve the method to check if the javascript
loading process is complete.

Closes #1581

Tests performed:
- The syncthing app is installed successfully on Debian testing
- All syncthing tests pass on Debian stable and testing

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Veiko Aasa authored and Sunil Mohan Adapa committed 2021-01-21 16:34:51 -08:00
1 parent f892843ba5
commit 77face68b0
4 files changed
+86 -31

No files matched your search

+5 -3
View File
@@ -18,7 +18,7 @@ from plinth.utils import format_lazy
from . import manifest
version = 4
version = 5
managed_services = ['syncthing@syncthing']
@@ -108,9 +108,13 @@ def setup(helper, old_version=None):
"""Install and configure the module."""
helper.install(managed_packages)
helper.call('post', actions.superuser_run, 'syncthing', ['setup'])
add_user_to_share_group(SYSTEM_USER, managed_services[0])
if not old_version:
helper.call('post', app.enable)
helper.call('post', actions.superuser_run, 'syncthing', ['setup-config'])
if old_version == 1 and app.is_enabled():
app.get_component('firewall-syncthing-ports').enable()
@@ -138,5 +142,3 @@ def setup(helper, old_version=None):
sharing.remove_share(name)
sharing.add_share(name, share['path'], new_groups,
share['is_public'])
add_user_to_share_group(SYSTEM_USER, managed_services[0])
@@ -13,6 +13,12 @@ Scenario: Enable syncthing application
When I enable the syncthing application
Then the syncthing service should be running
Scenario: Authentication and usage reporting notifications not shown
Given the syncthing application is enabled
When I access syncthing application
Then the usage reporting notification is not shown
And the authentication notification is not shown
Scenario: Add a syncthing folder
Given the syncthing application is enabled
And syncthing folder Test is not present
@@ -3,6 +3,8 @@
Functional, browser based tests for syncthing app.
"""
import time
from pytest_bdd import given, parsers, scenarios, then, when
from plinth.tests import functional
@@ -37,6 +39,19 @@ def syncthing_remove_folder(session_browser, folder_name):
_remove_folder(session_browser, folder_name)
@then('the usage reporting notification is not shown')
def syncthing_assert_usage_report_notification_not_shown(session_browser):
_load_main_interface(session_browser)
assert session_browser.find_by_id('ur').visible is False
@then('the authentication notification is not shown')
def syncthing_assert_authentication_notification_not_shown(session_browser):
_load_main_interface(session_browser)
assert bool(session_browser.find_by_css(
'#authenticationUserAndPassword *')) is False
@then(parsers.parse('syncthing folder {folder_name:w} should be present'))
def syncthing_assert_folder_present(session_browser, folder_name):
assert _folder_is_present(session_browser, folder_name)
@@ -63,28 +78,12 @@ def _load_main_interface(browser):
functional.eventually(service_is_available)
# Wait for javascript loading process to complete
browser.execute_script('''
document.is_ui_online = false;
var old_console_log = console.log;
console.log = function(message) {
old_console_log.apply(null, arguments);
if (message == 'UIOnline') {
document.is_ui_online = true;
console.log = old_console_log;
}
};
''')
functional.eventually(
lambda: browser.evaluate_script('document.is_ui_online'), timeout=5)
functional.eventually(lambda: browser.evaluate_script(
'angular.element("[ng-controller=SyncthingController]").scope()'
'.thisDevice().name'))
# Dismiss the Usage Reporting consent dialog
functional.eventually(browser.find_by_id, ['ur'])
usage_reporting = browser.find_by_id('ur').first
functional.eventually(lambda: usage_reporting.visible, timeout=2)
if usage_reporting.visible:
yes_xpath = './/button[contains(@ng-click, "declineUR")]'
usage_reporting.find_by_xpath(yes_xpath).first.click()
functional.eventually(lambda: not usage_reporting.visible)
# Give browser additional time to setup site
time.sleep(1)
def _folder_is_present(browser, folder_name):