mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-13 10:30:16 +00:00
tests: Ensure that privileged daemon is not used during tests
- Fallback to sudo based privileged implementation. Privileged daemon tests are still to be implemented. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
This commit is contained in:
parent
213d0330fd
commit
a70611a2e9
@ -6,6 +6,7 @@ pytest configuration for all tests.
|
|||||||
import importlib
|
import importlib
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@ -109,6 +110,17 @@ def fixture_needs_sudo():
|
|||||||
pytest.skip('Needs sudo command installed.')
|
pytest.skip('Needs sudo command installed.')
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(name='no_privileged_server', scope='module')
|
||||||
|
def fixture_no_privileged__server():
|
||||||
|
"""Don't setup for and run privileged methods on server.
|
||||||
|
|
||||||
|
Tests on using privileged daemon are not yet implemented.
|
||||||
|
"""
|
||||||
|
with patch('plinth.actions._run_privileged_method_on_server') as mock:
|
||||||
|
mock.side_effect = NotImplementedError
|
||||||
|
yield
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def splinter_selenium_implicit_wait():
|
def splinter_selenium_implicit_wait():
|
||||||
"""Disable implicit waiting."""
|
"""Disable implicit waiting."""
|
||||||
|
|||||||
@ -15,7 +15,8 @@ from plinth.modules.backups import privileged
|
|||||||
from plinth.modules.backups.repository import BorgRepository, SshBorgRepository
|
from plinth.modules.backups.repository import BorgRepository, SshBorgRepository
|
||||||
from plinth.tests import config as test_config
|
from plinth.tests import config as test_config
|
||||||
|
|
||||||
pytestmark = pytest.mark.usefixtures('needs_root', 'needs_borg', 'load_cfg')
|
pytestmark = pytest.mark.usefixtures('needs_root', 'needs_borg', 'load_cfg',
|
||||||
|
'no_privileged_server')
|
||||||
|
|
||||||
# try to access a non-existing url and a URL that exists but does not
|
# try to access a non-existing url and a URL that exists but does not
|
||||||
# grant access
|
# grant access
|
||||||
|
|||||||
@ -20,6 +20,8 @@ from plinth.actions import privileged, secret_str
|
|||||||
|
|
||||||
actions_name = 'actions'
|
actions_name = 'actions'
|
||||||
|
|
||||||
|
pytestmark = pytest.mark.usefixtures('no_privileged_server')
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(name='popen')
|
@pytest.fixture(name='popen')
|
||||||
def fixture_popen():
|
def fixture_popen():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user