From f8258fcef49c23203b80c1398a655d7e1f2afadc Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Sun, 3 Oct 2021 11:29:26 -0400 Subject: [PATCH] ssh: Convert functional tests to non-BDD python format Signed-off-by: James Valleroy [sunil: Ensure app is enabled after tests] Signed-off-by: Sunil Mohan Adapa Reviewed-by: Sunil Mohan Adapa --- plinth/modules/ssh/tests/ssh.feature | 28 ---------------- plinth/modules/ssh/tests/test_functional.py | 37 +++++++++++++++++++-- 2 files changed, 35 insertions(+), 30 deletions(-) delete mode 100644 plinth/modules/ssh/tests/ssh.feature diff --git a/plinth/modules/ssh/tests/ssh.feature b/plinth/modules/ssh/tests/ssh.feature deleted file mode 100644 index 251125044..000000000 --- a/plinth/modules/ssh/tests/ssh.feature +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: AGPL-3.0-or-later - -@apps @ssh -Feature: Secure Shell Server - Run secure shell server. - -Background: - Given I'm a logged in user - Given the ssh application is installed - -Scenario: Enable ssh application - Given the ssh application is disabled - When I enable the ssh application - Then the ssh service should be running - -Scenario: Disable ssh application - Given the ssh application is enabled - When I disable the ssh application - Then the ssh service should not be running - -# TODO: Improve this to actually check that earlier ssh certificate has been -# restored. -@backups -Scenario: Backup and restore ssh - Given the ssh application is enabled - When I create a backup of the ssh app data with name test_ssh - And I restore the ssh app data backup with name test_ssh - Then the ssh service should be running diff --git a/plinth/modules/ssh/tests/test_functional.py b/plinth/modules/ssh/tests/test_functional.py index 6b239f3ea..550769e1c 100644 --- a/plinth/modules/ssh/tests/test_functional.py +++ b/plinth/modules/ssh/tests/test_functional.py @@ -3,6 +3,39 @@ Functional, browser based tests for ssh app. """ -from pytest_bdd import scenarios +import pytest -scenarios('ssh.feature') +from plinth.tests import functional + +pytestmark = [pytest.mark.system, pytest.mark.ssh] + + +@pytest.fixture(scope='module', autouse=True) +def fixture_background(session_browser): + """Login and install the app.""" + functional.login(session_browser) + functional.install(session_browser, 'ssh') + yield + functional.app_enable(session_browser, 'ssh') + + +def test_enable_disable(session_browser): + """Test enabling the app.""" + functional.app_disable(session_browser, 'ssh') + + functional.app_enable(session_browser, 'ssh') + assert functional.service_is_running(session_browser, 'ssh') + + functional.app_disable(session_browser, 'ssh') + assert functional.service_is_not_running(session_browser, 'ssh') + + +# TODO: Improve this to actually check that earlier ssh certificate has been +# restored. +@pytest.mark.backups +def test_backup_restore(session_browser): + """Test backup and restore.""" + functional.app_enable(session_browser, 'ssh') + functional.backup_create(session_browser, 'ssh', 'test_ssh') + functional.backup_restore(session_browser, 'ssh', 'test_ssh') + assert functional.service_is_running(session_browser, 'ssh')