mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
openvpn: 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:
parent
f801e768f3
commit
8dea7d3c79
@ -1,43 +0,0 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
@apps @openvpn
|
||||
Feature: OpenVPN - Virtual Private Network
|
||||
Setup and configure OpenVPN
|
||||
|
||||
Background:
|
||||
Given I'm a logged in user
|
||||
Given the openvpn application is installed
|
||||
|
||||
Scenario: Enable openvpn application
|
||||
Given the openvpn application is disabled
|
||||
When I enable the openvpn application
|
||||
Then the openvpn service should be running
|
||||
|
||||
Scenario: Download openvpn profile
|
||||
Given the openvpn application is enabled
|
||||
Then the openvpn profile should be downloadable
|
||||
|
||||
Scenario: User of 'vpn' group
|
||||
Given the openvpn application is enabled
|
||||
And the user vpnuser in group vpn exists
|
||||
When I'm logged in as the user vpnuser
|
||||
Then the openvpn profile should be downloadable
|
||||
|
||||
Scenario: User not of 'vpn' group
|
||||
Given the openvpn application is enabled
|
||||
And the user nonvpnuser exists
|
||||
When I'm logged in as the user nonvpnuser
|
||||
Then openvpn app should not be visible on the front page
|
||||
|
||||
@backups
|
||||
Scenario: Backup and restore openvpn
|
||||
Given the openvpn application is enabled
|
||||
And I download openvpn profile
|
||||
When I create a backup of the openvpn app data with name test_openvpn
|
||||
And I restore the openvpn app data backup with name test_openvpn
|
||||
Then the openvpn profile downloaded should be same as before
|
||||
|
||||
Scenario: Disable openvpn application
|
||||
Given the openvpn application is enabled
|
||||
When I disable the openvpn application
|
||||
Then the openvpn service should not be running
|
||||
@ -3,35 +3,75 @@
|
||||
Functional, browser based tests for openvpn app.
|
||||
"""
|
||||
|
||||
from pytest_bdd import given, scenarios, then
|
||||
|
||||
import pytest
|
||||
from plinth.tests import functional
|
||||
|
||||
scenarios('openvpn.feature')
|
||||
pytestmark = [pytest.mark.apps, pytest.mark.openvpn]
|
||||
|
||||
base_url = functional.config['DEFAULT']['URL']
|
||||
shortcut_href = '?selected=shortcut-openvpn'
|
||||
|
||||
|
||||
@given('I download openvpn profile', target_fixture='openvpn_profile')
|
||||
def openvpn_download_profile(session_browser):
|
||||
return _download_profile(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, 'openvpn')
|
||||
yield
|
||||
functional.app_disable(session_browser, 'openvpn')
|
||||
|
||||
|
||||
@then('the openvpn profile should be downloadable')
|
||||
def openvpn_profile_downloadable(session_browser):
|
||||
def test_enable_disable(session_browser):
|
||||
"""Test enabling the app."""
|
||||
functional.app_disable(session_browser, 'openvpn')
|
||||
|
||||
functional.app_enable(session_browser, 'openvpn')
|
||||
assert functional.service_is_running(session_browser, 'openvpn')
|
||||
|
||||
functional.app_disable(session_browser, 'openvpn')
|
||||
assert functional.service_is_not_running(session_browser, 'openvpn')
|
||||
|
||||
|
||||
def test_download_profile(session_browser):
|
||||
"""Test that OpenVPN profile is downloadable."""
|
||||
functional.app_enable(session_browser, 'openvpn')
|
||||
_download_profile(session_browser)
|
||||
|
||||
|
||||
@then('openvpn app should not be visible on the front page')
|
||||
def openvpn_app_not_on_front_page(session_browser):
|
||||
def test_user_group(session_browser):
|
||||
"""Test that only users in vpn group have access."""
|
||||
functional.app_enable(session_browser, 'openvpn')
|
||||
if not functional.user_exists(session_browser, 'vpnuser'):
|
||||
functional.create_user(session_browser, 'vpnuser', groups=['vpn'])
|
||||
if not functional.user_exists(session_browser, 'nonvpnuser'):
|
||||
functional.create_user(session_browser, 'nonvpnuser', groups=[])
|
||||
|
||||
functional.login_with_account(session_browser, base_url, 'vpnuser')
|
||||
_download_profile(session_browser)
|
||||
|
||||
functional.login_with_account(session_browser, base_url, 'nonvpnuser')
|
||||
_not_on_front_page(session_browser)
|
||||
|
||||
functional.login(session_browser)
|
||||
|
||||
|
||||
def test_backup_restore(session_browser):
|
||||
"""Test backup and restore of app data."""
|
||||
functional.app_enable(session_browser, 'openvpn')
|
||||
profile = _download_profile(session_browser)
|
||||
functional.backup_create(session_browser, 'openvpn', 'test_openvpn')
|
||||
|
||||
functional.backup_restore(session_browser, 'openvpn', 'test_openvpn')
|
||||
_profile_download_compare(session_browser, profile)
|
||||
|
||||
|
||||
def _not_on_front_page(session_browser):
|
||||
session_browser.visit(base_url)
|
||||
links = session_browser.links.find_by_href(shortcut_href)
|
||||
assert len(links) == 0
|
||||
|
||||
|
||||
@then('the openvpn profile downloaded should be same as before')
|
||||
def openvpn_profile_download_compare(session_browser, openvpn_profile):
|
||||
def _profile_download_compare(session_browser, openvpn_profile):
|
||||
new_profile = _download_profile(session_browser)
|
||||
assert openvpn_profile == new_profile
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user