bind: 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:
James Valleroy 2021-09-20 19:34:02 -04:00 committed by Sunil Mohan Adapa
parent 0213fe370b
commit cb430b4b4b
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 53 additions and 63 deletions

View File

@ -1,49 +0,0 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
@apps @bind
Feature: Bind Domain Name Server
Configure the Bind Domain Name Server.
Background:
Given I'm a logged in user
Given the bind application is installed
Scenario: Enable bind application
Given the bind application is disabled
When I enable the bind application
Then the bind service should be running
Scenario: Set bind forwarders
Given the bind application is enabled
And bind forwarders are set to 1.1.1.1
When I set bind forwarders to 1.1.1.1 1.0.0.1
Then bind forwarders should be 1.1.1.1 1.0.0.1
Scenario: Enable bind DNSSEC
Given the bind application is enabled
And bind DNSSEC is disabled
When I enable bind DNSSEC
Then bind DNSSEC should be enabled
Scenario: Disable bind DNSSEC
Given the bind application is enabled
And bind DNSSEC is disabled
When I disable bind DNSSEC
Then bind DNSSEC should be disabled
@backups
Scenario: Backup and restore bind
Given the bind application is enabled
When I set bind forwarders to 1.1.1.1
And I disable bind DNSSEC
And I create a backup of the bind app data with name test_bind
And I set bind forwarders to 1.0.0.1
And I enable bind DNSSEC
And I restore the bind app data backup with name test_bind
Then bind forwarders should be 1.1.1.1
And bind DNSSEC should be disabled
Scenario: Disable bind application
Given the bind application is enabled
When I disable the bind application
Then the bind service should not be running

View File

@ -3,28 +3,67 @@
Functional, browser based tests for bind app. Functional, browser based tests for bind app.
""" """
from pytest_bdd import given, parsers, scenarios, then, when import pytest
from plinth.tests import functional from plinth.tests import functional
scenarios('bind.feature') pytestmark = [pytest.mark.system, pytest.mark.bind]
@given(parsers.parse('bind DNSSEC is {enable:w}')) @pytest.fixture(scope='module', autouse=True)
def bind_given_enable_dnssec(session_browser, enable): def fixture_background(session_browser):
should_enable = (enable == 'enabled') """Login and install the app."""
_enable_dnssec(session_browser, should_enable) functional.login(session_browser)
functional.install(session_browser, 'bind')
yield
functional.app_disable(session_browser, 'bind')
@when(parsers.parse('I {enable:w} bind DNSSEC')) def test_enable_disable(session_browser):
def bind_enable_dnssec(session_browser, enable): """Test enabling the app."""
should_enable = (enable == 'enable') functional.app_disable(session_browser, 'bind')
_enable_dnssec(session_browser, should_enable)
functional.app_enable(session_browser, 'bind')
assert functional.service_is_running(session_browser, 'bind')
functional.app_disable(session_browser, 'bind')
assert functional.service_is_not_running(session_browser, 'bind')
@then(parsers.parse('bind DNSSEC should be {enabled:w}')) def test_set_forwarders(session_browser):
def bind_assert_dnssec(session_browser, enabled): """Test setting forwarders."""
assert _get_dnssec(session_browser) == (enabled == 'enabled') functional.app_enable(session_browser, 'bind')
functional.set_forwarders(session_browser, '1.1.1.1')
functional.set_forwarders(session_browser, '1.1.1.1 1.0.0.1')
assert functional.get_forwarders(session_browser) == '1.1.1.1 1.0.0.1'
def test_enable_disable_dnssec(session_browser):
"""Test enabling/disabling DNSSEC."""
functional.app_enable(session_browser, 'bind')
_enable_dnssec(session_browser, False)
_enable_dnssec(session_browser, True)
assert _get_dnssec(session_browser)
_enable_dnssec(session_browser, False)
assert not _get_dnssec(session_browser)
@pytest.mark.backups
def test_backup(session_browser):
"""Test backup and restore."""
functional.app_enable(session_browser, 'bind')
functional.set_forwarders(session_browser, '1.1.1.1')
_enable_dnssec(session_browser, False)
functional.backup_create(session_browser, 'bind', 'test_bind')
functional.set_forwarders(session_browser, '1.0.0.1')
_enable_dnssec(session_browser, True)
functional.backup_restore(session_browser, 'bind', 'test_bind')
assert functional.get_forwarders(session_browser) == '1.1.1.1'
assert not _get_dnssec(session_browser)
def _enable_dnssec(browser, enable): def _enable_dnssec(browser, enable):