mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
- In pytest-bdd v4.0, given steps are no longer fixtures. Mark steps as fixtures when needed. - Remove 'test_' prefix from step function names, so that pytest doesn't run those twice. Test performed: - Run all tests, no more pytest-bdd v4.0 related failures - All the openvpn, snapshot and users module tests pass Signed-off-by: Veiko Aasa <veiko17@disroot.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""
|
|
Functional, browser based tests for openvpn app.
|
|
"""
|
|
|
|
from pytest_bdd import given, scenarios, then
|
|
|
|
from plinth.tests import functional
|
|
|
|
scenarios('openvpn.feature')
|
|
|
|
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)
|
|
|
|
|
|
@then('the openvpn profile should be downloadable')
|
|
def openvpn_profile_downloadable(session_browser):
|
|
_download_profile(session_browser)
|
|
|
|
|
|
@then('openvpn app should not be visible on the front page')
|
|
def openvpn_app_not_on_front_page(session_browser):
|
|
session_browser.visit(base_url)
|
|
links = session_browser.find_link_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):
|
|
new_profile = _download_profile(session_browser)
|
|
assert openvpn_profile == new_profile
|
|
|
|
|
|
def _download_profile(browser):
|
|
"""Return the content of the current user's OpenVPN profile."""
|
|
browser.visit(base_url)
|
|
browser.click_link_by_href(shortcut_href)
|
|
profile_url = f'{base_url}/plinth/apps/openvpn/profile/'
|
|
return functional.download_file(browser, profile_url)
|