| |
@@ -1,51 +0,0 @@
|
| |
- From ec0fa884fe5f3880c76fa08a6dac1fd3abee9d30 Mon Sep 17 00:00:00 2001
|
| |
- From: Jan Zarsky <jzarsky@redhat.com>
|
| |
- Date: Tue, 7 May 2019 10:48:00 +0200
|
| |
- Subject: [PATCH 1/2] Add an option for running tests with real modules
|
| |
-
|
| |
- For testing purposes, the selinux and semanage modules are mocked. This
|
| |
- allows running the tests without SELinux enabled (e.g. in a container).
|
| |
- On SELinux-enabled systems, it makes sense to rerun the tests with the
|
| |
- actual selinux and semanage modules present on the system. For this
|
| |
- purpose, add a global constant named 'SELINUX_ENABLED'.
|
| |
- ---
|
| |
- tests/test_main.py | 11 +++++++++++
|
| |
- 1 file changed, 11 insertions(+)
|
| |
-
|
| |
- diff --git a/tests/test_main.py b/tests/test_main.py
|
| |
- index 9d8ac6d..08805db 100644
|
| |
- --- a/tests/test_main.py
|
| |
- +++ b/tests/test_main.py
|
| |
- @@ -22,6 +22,11 @@ from unittest.mock import patch
|
| |
- sys.path.insert(0, os.path.abspath('..'))
|
| |
- import udica.__main__
|
| |
-
|
| |
- +# Use the selinux and semanage packages provided by the system instead of the mock ones. When
|
| |
- +# running on a system with SELinux disabled (e.g. in a container), it must be set to False.
|
| |
- +# On RHEL, CentOS or Fedora it may be set to True.
|
| |
- +SELINUX_ENABLED = False
|
| |
- +
|
| |
- class TestMain(unittest.TestCase):
|
| |
- """Test basic functionality of udica"""
|
| |
-
|
| |
- @@ -72,11 +77,17 @@ class TestMain(unittest.TestCase):
|
| |
- # FIXME: the load_policy function is not properly restoring current working directory
|
| |
- self.cwd = os.getcwd()
|
| |
-
|
| |
- + if SELINUX_ENABLED:
|
| |
- + sys.path = [path for path in sys.path if path not in (os.getcwd(), '')]
|
| |
- +
|
| |
- import selinux
|
| |
- importlib.reload(selinux)
|
| |
- import semanage
|
| |
- importlib.reload(semanage)
|
| |
-
|
| |
- + if SELINUX_ENABLED:
|
| |
- + sys.path = [''] + sys.path
|
| |
- +
|
| |
- with patch('sys.argv', args):
|
| |
- with patch('sys.stderr.write') as mock_err, patch('sys.stdout.write') as mock_out:
|
| |
- mock_out.output = ""
|
| |
- --
|
| |
- 2.20.1
|
| |
-
|
| |
Please merge this, after these upstream patches land in udica:
https://github.com/containers/udica/commit/87026feebe82e7432a47564160b055986ed71e65
https://github.com/containers/udica/commit/bc7b40a7fdff883c483ffc267ac9a5143e0609c8