diff --git a/plinth/modules/pagekite/tests/pagekite.feature b/plinth/modules/pagekite/tests/pagekite.feature deleted file mode 100644 index 8e4848725..000000000 --- a/plinth/modules/pagekite/tests/pagekite.feature +++ /dev/null @@ -1,44 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later - -# TODO Scenario: Enable standard services -# TODO Scenario: Disable standard services -# TODO Scenario: Add custom service -# TODO Scenario: Delete custom service - -@apps @pagekite -Feature: Pagekite Public Visibility - Configure Pagekite public visitbility server. - -Background: - Given I'm a logged in user - Given the pagekite application is installed - -Scenario: Enable pagekite application - Given the pagekite application is disabled - When I enable the pagekite application - Then the pagekite service should be running - -Scenario: Configure pagekite application - Given the pagekite application is enabled - When I configure pagekite with host pagekite.example.com, port 8080, kite name mykite.example.com and kite secret mysecret - Then pagekite should be configured with host pagekite.example.com, port 8080, kite name mykite.example.com and kite secret mysecret - -Scenario: Capitalized kite name - Given the pagekite application is enabled - When I configure pagekite with host pagekite.example.com, port 8080, kite name Mykite.example.com and kite secret mysecret - Then pagekite should be configured with host pagekite.example.com, port 8080, kite name mykite.example.com and kite secret mysecret - -@backups -Scenario: Backup and restore pagekite - Given the pagekite application is enabled - When I configure pagekite with host beforebackup.example.com, port 8081, kite name beforebackup.example.com and kite secret beforebackupsecret - And I create a backup of the pagekite app data with name test_pagekite - And I configure pagekite with host afterbackup.example.com, port 8082, kite name afterbackup.example.com and kite secret afterbackupsecret - And I restore the pagekite app data backup with name test_pagekite - Then the pagekite service should be running - And pagekite should be configured with host beforebackup.example.com, port 8081, kite name beforebackup.example.com and kite secret beforebackupsecret - -Scenario: Disable pagekite application - Given the pagekite application is enabled - When I disable the pagekite application - Then the pagekite service should not be running diff --git a/plinth/modules/pagekite/tests/test_functional.py b/plinth/modules/pagekite/tests/test_functional.py index d18168619..3ea48b5ee 100644 --- a/plinth/modules/pagekite/tests/test_functional.py +++ b/plinth/modules/pagekite/tests/test_functional.py @@ -3,28 +3,66 @@ Functional, browser based tests for pagekite app. """ -from pytest_bdd import parsers, scenarios, then, when - +import pytest from plinth.tests import functional -scenarios('pagekite.feature') +pytestmark = [pytest.mark.system, pytest.mark.pagekite] + +# TODO Scenario: Enable standard services +# TODO Scenario: Disable standard services +# TODO Scenario: Add custom service +# TODO Scenario: Delete custom service -@when( - parsers.parse('I configure pagekite with host {host:S}, port {port:d}, ' - 'kite name {kite_name:S} and kite secret {kite_secret:w}')) -def pagekite_configure(session_browser, host, port, kite_name, kite_secret): - _configure(session_browser, host, port, kite_name, kite_secret) +@pytest.fixture(scope='module', autouse=True) +def fixture_background(session_browser): + """Login and install the app.""" + functional.login(session_browser) + functional.install(session_browser, 'pagekite') + yield + functional.app_disable(session_browser, 'pagekite') -@then( - parsers.parse( - 'pagekite should be configured with host {host:S}, port {port:d}, ' - 'kite name {kite_name:S} and kite secret {kite_secret:w}')) -def pagekite_assert_configured(session_browser, host, port, kite_name, - kite_secret): - assert (host, port, kite_name, - kite_secret) == _get_configuration(session_browser) +def test_enable_disable(session_browser): + """Test enabling the app.""" + functional.app_disable(session_browser, 'pagekite') + + functional.app_enable(session_browser, 'pagekite') + assert functional.service_is_running(session_browser, 'pagekite') + + functional.app_disable(session_browser, 'pagekite') + assert functional.service_is_not_running(session_browser, 'pagekite') + + +def test_configure(session_browser): + """Test pagekite configuration.""" + functional.app_enable(session_browser, 'pagekite') + _configure(session_browser, 'pagekite.example.com', 8080, + 'mykite.example.com', 'mysecret') + assert ('pagekite.example.com', 8080, 'mykite.example.com', + 'mysecret') == _get_configuration(session_browser) + + # Capitalized kite name should become lower case. + _configure(session_browser, 'pagekite.example.com', 8080, + 'Mykite.example.com', 'mysecret') + assert ('pagekite.example.com', 8080, 'mykite.example.com', + 'mysecret') == _get_configuration(session_browser) + + +def test_backup_restore(session_browser): + """Test backup and restore of configuration.""" + functional.app_enable(session_browser, 'pagekite') + _configure(session_browser, 'beforebackup.example.com', 8081, + 'beforebackup.example.com', 'beforebackupsecret') + functional.backup_create(session_browser, 'pagekite', 'test_pagekite') + + _configure(session_browser, 'afterbackup.example.com', 8082, + 'afterbackup.example.com', 'afterbackupsecret') + functional.backup_restore(session_browser, 'pagekite', 'test_pagekite') + + assert functional.service_is_running(session_browser, 'pagekite') + assert ('beforebackup.example.com', 8081, 'beforebackup.example.com', + 'beforebackupsecret') == _get_configuration(session_browser) def _configure(browser, host, port, kite_name, kite_secret):