ssh: Convert functional tests to non-BDD python format

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
[sunil: Ensure app is enabled after tests]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
James Valleroy 2021-10-03 11:29:26 -04:00 committed by Sunil Mohan Adapa
parent b9f561a43f
commit f8258fcef4
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 35 additions and 30 deletions

View File

@ -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

View File

@ -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')