mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-06-17 11:10:23 +00:00
shadowsocks: Convert functional tests to non-BDD python format
Signed-off-by: James Valleroy <jvalleroy@mailbox.org> [sunil: Properly changes the values before restoring from backup] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
9ec995a741
commit
d3c7383cb6
@ -1,30 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
@apps @shadowsocks
|
||||
Feature: Shadowsocks Socks5 Proxy
|
||||
Run the Shadowsocks Socks5 proxy client.
|
||||
|
||||
Background:
|
||||
Given I'm a logged in user
|
||||
Given the shadowsocks application is installed
|
||||
Given the shadowsocks application is configured
|
||||
|
||||
Scenario: Enable shadowsocks application
|
||||
Given the shadowsocks application is disabled
|
||||
When I enable the shadowsocks application
|
||||
Then the shadowsocks service should be running
|
||||
|
||||
@backups
|
||||
Scenario: Backup and restore shadowsocks
|
||||
Given the shadowsocks application is enabled
|
||||
When I configure shadowsocks with server example.com and password beforebackup123
|
||||
And I create a backup of the shadowsocks app data with name test_shadowsocks
|
||||
And I configure shadowsocks with server example.org and password afterbackup123
|
||||
And I restore the shadowsocks app data backup with name test_shadowsocks
|
||||
Then the shadowsocks service should be running
|
||||
And shadowsocks should be configured with server example.com and password beforebackup123
|
||||
|
||||
Scenario: Disable shadowsocks application
|
||||
Given the shadowsocks application is enabled
|
||||
When I disable the shadowsocks application
|
||||
Then the shadowsocks service should not be running
|
||||
@ -3,30 +3,49 @@
|
||||
Functional, browser based tests for shadowsocks app.
|
||||
"""
|
||||
|
||||
from pytest_bdd import given, parsers, scenarios, then, when
|
||||
import pytest
|
||||
|
||||
from plinth.tests import functional
|
||||
|
||||
scenarios('shadowsocks.feature')
|
||||
pytestmark = [pytest.mark.apps, pytest.mark.shadowsocks]
|
||||
|
||||
|
||||
@given('the shadowsocks application is configured')
|
||||
def configure_shadowsocks(session_browser):
|
||||
@pytest.fixture(scope='module', autouse=True)
|
||||
def fixture_background(session_browser):
|
||||
"""Login and install the app."""
|
||||
functional.login(session_browser)
|
||||
functional.install(session_browser, 'shadowsocks')
|
||||
_configure(session_browser, 'example.com', 'fakepassword')
|
||||
yield
|
||||
functional.app_disable(session_browser, 'shadowsocks')
|
||||
|
||||
|
||||
@when(
|
||||
parsers.parse('I configure shadowsocks with server {server:S} and '
|
||||
'password {password:w}'))
|
||||
def configure_shadowsocks_with_details(session_browser, server, password):
|
||||
_configure(session_browser, server, password)
|
||||
def test_enable_disable(session_browser):
|
||||
"""Test enabling the app."""
|
||||
functional.app_disable(session_browser, 'shadowsocks')
|
||||
|
||||
functional.app_enable(session_browser, 'shadowsocks')
|
||||
assert functional.service_is_running(session_browser, 'shadowsocks')
|
||||
|
||||
functional.app_disable(session_browser, 'shadowsocks')
|
||||
assert functional.service_is_not_running(session_browser, 'shadowsocks')
|
||||
|
||||
|
||||
@then(
|
||||
parsers.parse('shadowsocks should be configured with server {server:S} '
|
||||
'and password {password:w}'))
|
||||
def assert_shadowsocks_configuration(session_browser, server, password):
|
||||
assert (server, password) == _get_configuration(session_browser)
|
||||
@pytest.mark.backups
|
||||
def test_backup_restore(session_browser):
|
||||
"""Test backup and restore of configuration."""
|
||||
functional.app_enable(session_browser, 'shadowsocks')
|
||||
_configure(session_browser, 'example.com', 'beforebackup123')
|
||||
functional.backup_create(session_browser, 'shadowsocks',
|
||||
'test_shadowsocks')
|
||||
|
||||
_configure(session_browser, 'example.org', 'afterbackup123')
|
||||
functional.backup_restore(session_browser, 'shadowsocks',
|
||||
'test_shadowsocks')
|
||||
|
||||
assert functional.service_is_running(session_browser, 'shadowsocks')
|
||||
assert _get_configuration(session_browser) == ('example.com',
|
||||
'beforebackup123')
|
||||
|
||||
|
||||
def _configure(browser, server, password):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user