From a70611a2e9318dbd60e3fb22ff43381d3acbdab1 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 11 Aug 2025 11:07:31 -0700 Subject: [PATCH] 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 Reviewed-by: Joseph Nuthalapati --- plinth/conftest.py | 12 ++++++++++++ plinth/modules/backups/tests/test_backups.py | 3 ++- plinth/tests/test_actions.py | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/plinth/conftest.py b/plinth/conftest.py index aa23d287b..fecb13b8f 100644 --- a/plinth/conftest.py +++ b/plinth/conftest.py @@ -6,6 +6,7 @@ pytest configuration for all tests. import importlib import os import pathlib +from unittest.mock import patch import pytest @@ -109,6 +110,17 @@ def fixture_needs_sudo(): 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') def splinter_selenium_implicit_wait(): """Disable implicit waiting.""" diff --git a/plinth/modules/backups/tests/test_backups.py b/plinth/modules/backups/tests/test_backups.py index 517a63dd1..ea5002ad9 100644 --- a/plinth/modules/backups/tests/test_backups.py +++ b/plinth/modules/backups/tests/test_backups.py @@ -15,7 +15,8 @@ from plinth.modules.backups import privileged from plinth.modules.backups.repository import BorgRepository, SshBorgRepository 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 # grant access diff --git a/plinth/tests/test_actions.py b/plinth/tests/test_actions.py index e9b67f14e..fc3f045f3 100644 --- a/plinth/tests/test_actions.py +++ b/plinth/tests/test_actions.py @@ -20,6 +20,8 @@ from plinth.actions import privileged, secret_str actions_name = 'actions' +pytestmark = pytest.mark.usefixtures('no_privileged_server') + @pytest.fixture(name='popen') def fixture_popen():