mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
syncthing: Convert functional tests to non-BDD python format
Signed-off-by: James Valleroy <jvalleroy@mailbox.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
3bbbd0c812
commit
7ea6eeeac8
@ -1,59 +0,0 @@
|
|||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
||||||
|
|
||||||
@apps @syncthing @sso
|
|
||||||
Feature: Syncthing File Synchronization
|
|
||||||
Run Syncthing File Synchronization server.
|
|
||||||
|
|
||||||
Background:
|
|
||||||
Given I'm a logged in user
|
|
||||||
Given the syncthing application is installed
|
|
||||||
|
|
||||||
Scenario: Enable syncthing application
|
|
||||||
Given the syncthing application is disabled
|
|
||||||
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
|
|
||||||
When I add a folder /tmp as syncthing folder Test
|
|
||||||
Then syncthing folder Test should be present
|
|
||||||
|
|
||||||
Scenario: Remove a syncthing folder
|
|
||||||
Given the syncthing application is enabled
|
|
||||||
And folder /tmp is present as syncthing folder Test
|
|
||||||
When I remove syncthing folder Test
|
|
||||||
Then syncthing folder Test should not be present
|
|
||||||
|
|
||||||
@backups
|
|
||||||
Scenario: Backup and restore syncthing
|
|
||||||
Given the syncthing application is enabled
|
|
||||||
And syncthing folder Test is not present
|
|
||||||
When I add a folder /tmp as syncthing folder Test
|
|
||||||
And I create a backup of the syncthing app data with name test_syncthing
|
|
||||||
And I remove syncthing folder Test
|
|
||||||
And I restore the syncthing app data backup with name test_syncthing
|
|
||||||
Then syncthing folder Test should be present
|
|
||||||
|
|
||||||
Scenario: User of syncthing-access group can access syncthing site
|
|
||||||
Given the syncthing application is enabled
|
|
||||||
And the user syncthinguser in group syncthing-access exists
|
|
||||||
When I'm logged in as the user syncthinguser
|
|
||||||
Then the syncthing site should be available
|
|
||||||
|
|
||||||
Scenario: User not of syncthing-access group can't access syncthing site
|
|
||||||
Given the syncthing application is enabled
|
|
||||||
And the user nogroupuser exists
|
|
||||||
When I'm logged in as the user nogroupuser
|
|
||||||
Then the syncthing site should not be available
|
|
||||||
|
|
||||||
Scenario: Disable syncthing application
|
|
||||||
Given the syncthing application is enabled
|
|
||||||
When I disable the syncthing application
|
|
||||||
Then the syncthing service should not be running
|
|
||||||
@ -5,63 +5,102 @@ Functional, browser based tests for syncthing app.
|
|||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from pytest_bdd import given, parsers, scenarios, then, when
|
import pytest
|
||||||
|
|
||||||
from plinth.tests import functional
|
from plinth.tests import functional
|
||||||
|
|
||||||
scenarios('syncthing.feature')
|
pytestmark = [pytest.mark.apps, pytest.mark.syncthing]
|
||||||
|
|
||||||
|
|
||||||
@given(parsers.parse('syncthing folder {folder_name:w} is not present'))
|
@pytest.fixture(scope='module', autouse=True)
|
||||||
def syncthing_folder_not_present(session_browser, folder_name):
|
def fixture_background(session_browser):
|
||||||
if _folder_is_present(session_browser, folder_name):
|
"""Login and install the app."""
|
||||||
_remove_folder(session_browser, folder_name)
|
functional.login(session_browser)
|
||||||
|
functional.install(session_browser, 'syncthing')
|
||||||
|
yield
|
||||||
|
functional.app_disable(session_browser, 'syncthing')
|
||||||
|
|
||||||
|
|
||||||
@given(
|
def test_enable_disable(session_browser):
|
||||||
parsers.parse(
|
"""Test enabling the app."""
|
||||||
'folder {folder_path:S} is present as syncthing folder {folder_name:w}'
|
functional.app_disable(session_browser, 'syncthing')
|
||||||
))
|
|
||||||
def syncthing_folder_present(session_browser, folder_name, folder_path):
|
functional.app_enable(session_browser, 'syncthing')
|
||||||
if not _folder_is_present(session_browser, folder_name):
|
assert functional.service_is_running(session_browser, 'syncthing')
|
||||||
_add_folder(session_browser, folder_name, folder_path)
|
|
||||||
|
functional.app_disable(session_browser, 'syncthing')
|
||||||
|
assert functional.service_is_not_running(session_browser, 'syncthing')
|
||||||
|
|
||||||
|
|
||||||
@when(
|
def test_notifications(session_browser):
|
||||||
parsers.parse(
|
"""Test that authentication and usage reporting notifications are not
|
||||||
'I add a folder {folder_path:S} as syncthing folder {folder_name:w}'))
|
shown."""
|
||||||
def syncthing_add_folder(session_browser, folder_name, folder_path):
|
functional.app_enable(session_browser, 'syncthing')
|
||||||
_add_folder(session_browser, folder_name, folder_path)
|
functional.access_url(session_browser, 'syncthing')
|
||||||
|
_assert_usage_report_notification_not_shown(session_browser)
|
||||||
|
_assert_authentication_notification_not_shown(session_browser)
|
||||||
|
|
||||||
|
|
||||||
@when(parsers.parse('I remove syncthing folder {folder_name:w}'))
|
def test_add_remove_folder(session_browser):
|
||||||
def syncthing_remove_folder(session_browser, folder_name):
|
"""Test adding and removing a folder."""
|
||||||
_remove_folder(session_browser, folder_name)
|
functional.app_enable(session_browser, 'syncthing')
|
||||||
|
if _folder_is_present(session_browser, 'Test'):
|
||||||
|
_remove_folder(session_browser, 'Test')
|
||||||
|
|
||||||
|
_add_folder(session_browser, 'Test', '/tmp')
|
||||||
|
assert _folder_is_present(session_browser, 'Test')
|
||||||
|
|
||||||
|
_remove_folder(session_browser, 'Test')
|
||||||
|
assert not _folder_is_present(session_browser, 'Test')
|
||||||
|
|
||||||
|
|
||||||
@then('the usage reporting notification is not shown')
|
@pytest.mark.backups
|
||||||
def syncthing_assert_usage_report_notification_not_shown(session_browser):
|
def test_backup_restore(session_browser):
|
||||||
|
"""Test backup and restore of app data."""
|
||||||
|
functional.app_enable(session_browser, 'syncthing')
|
||||||
|
if _folder_is_present(session_browser, 'Test'):
|
||||||
|
_remove_folder(session_browser, 'Test')
|
||||||
|
|
||||||
|
_add_folder(session_browser, 'Test', '/tmp')
|
||||||
|
functional.backup_create(session_browser, 'syncthing', 'test_syncthing')
|
||||||
|
|
||||||
|
_remove_folder(session_browser, 'Test')
|
||||||
|
functional.backup_restore(session_browser, 'syncthing', 'test_syncthing')
|
||||||
|
|
||||||
|
assert _folder_is_present(session_browser, 'Test')
|
||||||
|
|
||||||
|
|
||||||
|
def test_user_group_access(session_browser):
|
||||||
|
"""Test that only users in syncthing-access group can access syncthing
|
||||||
|
site."""
|
||||||
|
functional.app_enable(session_browser, 'syncthing')
|
||||||
|
if not functional.user_exists(session_browser, 'syncthinguser'):
|
||||||
|
functional.create_user(session_browser, 'syncthinguser',
|
||||||
|
groups=['syncthing-access'])
|
||||||
|
if not functional.user_exists(session_browser, 'nogroupuser'):
|
||||||
|
functional.create_user(session_browser, 'nogroupuser')
|
||||||
|
|
||||||
|
functional.login_with_account(session_browser, functional.base_url,
|
||||||
|
'syncthinguser')
|
||||||
|
assert functional.is_available(session_browser, 'syncthing')
|
||||||
|
|
||||||
|
functional.login_with_account(session_browser, functional.base_url,
|
||||||
|
'nogroupuser')
|
||||||
|
assert not functional.is_available(session_browser, 'syncthing')
|
||||||
|
|
||||||
|
functional.login(session_browser)
|
||||||
|
|
||||||
|
|
||||||
|
def _assert_usage_report_notification_not_shown(session_browser):
|
||||||
_load_main_interface(session_browser)
|
_load_main_interface(session_browser)
|
||||||
assert session_browser.find_by_id('ur').visible is False
|
assert session_browser.find_by_id('ur').visible is False
|
||||||
|
|
||||||
|
|
||||||
@then('the authentication notification is not shown')
|
def _assert_authentication_notification_not_shown(session_browser):
|
||||||
def syncthing_assert_authentication_notification_not_shown(session_browser):
|
|
||||||
_load_main_interface(session_browser)
|
_load_main_interface(session_browser)
|
||||||
assert bool(session_browser.find_by_css(
|
assert bool(session_browser.find_by_css(
|
||||||
'#authenticationUserAndPassword *')) is False
|
'#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)
|
|
||||||
|
|
||||||
|
|
||||||
@then(parsers.parse('syncthing folder {folder_name:w} should not be present'))
|
|
||||||
def syncthing_assert_folder_not_present(session_browser, folder_name):
|
|
||||||
assert not _folder_is_present(session_browser, folder_name)
|
|
||||||
|
|
||||||
|
|
||||||
def _load_main_interface(browser):
|
def _load_main_interface(browser):
|
||||||
"""Close the dialog boxes that many popup after visiting the URL."""
|
"""Close the dialog boxes that many popup after visiting the URL."""
|
||||||
functional.access_url(browser, 'syncthing')
|
functional.access_url(browser, 'syncthing')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user