FreedomBox/plinth/modules/security/tests/test_functional.py
Sunil Mohan Adapa 29bf55dedb
security: Use AppView for app page
Tests:

- Enable/disable button is not shown.

- Diagnostics are shown and work.

- Initial status of the configuration is show properly.

- Enabling/disabling configuration options reflects correct status.

- Status of frequent features updates shows properly.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-08-29 08:29:09 -04:00

55 lines
1.7 KiB
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Functional, browser based tests for security app.
"""
import pytest
from plinth.tests import functional
pytestmark = [pytest.mark.system, pytest.mark.essential, pytest.mark.security]
@pytest.fixture(scope='module', autouse=True)
def fixture_background(session_browser):
"""Login."""
functional.login(session_browser)
def test_restricted_console_logins(session_browser):
"""Test enabling and disabling restricted console logins."""
_enable_restricted_logins(session_browser, False)
assert not _get_restricted_logins(session_browser)
_enable_restricted_logins(session_browser, True)
assert _get_restricted_logins(session_browser)
@pytest.mark.backups
def test_backup_restore(session_browser):
"""Test backup and restore of configuration."""
_enable_restricted_logins(session_browser, True)
functional.backup_create(session_browser, 'security', 'test_security')
_enable_restricted_logins(session_browser, False)
functional.backup_restore(session_browser, 'security', 'test_security')
assert _get_restricted_logins(session_browser)
def _enable_restricted_logins(browser, should_enable):
"""Enable/disable restricted logins in security module."""
functional.nav_to_module(browser, 'security')
if should_enable:
browser.check('security-restricted_access')
else:
browser.uncheck('security-restricted_access')
functional.submit(browser, form_class='form-configuration')
def _get_restricted_logins(browser):
"""Return whether restricted console logins is enabled."""
functional.nav_to_module(browser, 'security')
return browser.find_by_name('security-restricted_access').first.checked