test: '{. -> ./mod}/test_util_selinux.py'
Move the 'test_util_selinux.py' test into the module-unittest subdirectory. Drop the '__main__' hookup while at it. `python -m unittest --help` explains how you can run individual tests.
This commit is contained in:
parent
ff8cd76def
commit
6a7e811af2
3 changed files with 5 additions and 9 deletions
1
test/mod/__init__.py
Normal file
1
test/mod/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
# The `unittest` module requires `__init__.py` to discover a directory.
|
||||
42
test/mod/test_util_selinux.py
Normal file
42
test/mod/test_util_selinux.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#
|
||||
# Tests for the 'osbuild.util.selinux' module.
|
||||
#
|
||||
|
||||
import io
|
||||
import unittest
|
||||
|
||||
from osbuild.util import selinux
|
||||
|
||||
|
||||
class TestObjectStore(unittest.TestCase):
|
||||
|
||||
def test_selinux_config(self):
|
||||
f = io.StringIO()
|
||||
cfg = selinux.parse_config(f)
|
||||
self.assertIsNotNone(cfg)
|
||||
policy = selinux.config_get_policy(cfg)
|
||||
self.assertIsNone(policy)
|
||||
|
||||
example_good = """
|
||||
# This file controls the state of SELinux on the system.
|
||||
# SELINUX= can take one of these three values:
|
||||
# enforcing - SELinux security policy is enforced.
|
||||
# permissive - SELinux prints warnings instead of enforcing.
|
||||
# disabled - No SELinux policy is loaded.
|
||||
SELINUX=enforcing
|
||||
# SELINUXTYPE= can take one of these three values:
|
||||
# targeted - Targeted processes are protected,
|
||||
# minimum - Modification of targeted policy.
|
||||
# mls - Multi Level Security protection.
|
||||
SELINUXTYPE=targeted
|
||||
"""
|
||||
|
||||
f = io.StringIO(example_good)
|
||||
cfg = selinux.parse_config(f)
|
||||
self.assertIn('SELINUX', cfg)
|
||||
self.assertIn('SELINUXTYPE', cfg)
|
||||
self.assertEqual(cfg['SELINUX'], 'enforcing')
|
||||
self.assertEqual(cfg['SELINUXTYPE'], 'targeted')
|
||||
|
||||
policy = selinux.config_get_policy(cfg)
|
||||
self.assertEqual(policy, 'targeted')
|
||||
Loading…
Add table
Add a link
Reference in a new issue