mirror of
https://github.com/pi-hole/pi-hole.git
synced 2025-04-19 05:40:13 +00:00
Update the tests (#4427)
* unpin the requirements and update all to latest available - needs more work still. see notes in `def host()` Signed-off-by: Adam Warner <me@adamwarner.co.uk> * fix py3 monkey patch of testinfra docker using bash Signed-off-by: Adam Hill <adam@diginc.us> * update the other test files to use `host` instead of `Pihole` Address some sticklr and codefactor update python version from 3.7 to 3.8 preload `git` onto the centos/fedora test images, and switch which with command -v in the passthrough mock testinfra is deprecated, use pytest-testinfra Signed-off-by: Adam Warner <me@adamwarner.co.uk> Co-authored-by: Adam Hill <adam@diginc.us>
This commit is contained in:
parent
cedd1a2591
commit
cdd4d9ea9e
25 changed files with 285 additions and 322 deletions
|
@ -5,7 +5,7 @@ from .conftest import (
|
|||
)
|
||||
|
||||
|
||||
def mock_selinux_config(state, Pihole):
|
||||
def mock_selinux_config(state, host):
|
||||
'''
|
||||
Creates a mock SELinux config file with expected content
|
||||
'''
|
||||
|
@ -13,20 +13,20 @@ def mock_selinux_config(state, Pihole):
|
|||
valid_states = ['enforcing', 'permissive', 'disabled']
|
||||
assert state in valid_states
|
||||
# getenforce returns the running state of SELinux
|
||||
mock_command('getenforce', {'*': (state.capitalize(), '0')}, Pihole)
|
||||
mock_command('getenforce', {'*': (state.capitalize(), '0')}, host)
|
||||
# create mock configuration with desired content
|
||||
Pihole.run('''
|
||||
host.run('''
|
||||
mkdir /etc/selinux
|
||||
echo "SELINUX={state}" > /etc/selinux/config
|
||||
'''.format(state=state.lower()))
|
||||
|
||||
|
||||
def test_selinux_enforcing_exit(Pihole):
|
||||
def test_selinux_enforcing_exit(host):
|
||||
'''
|
||||
confirms installer prompts to exit when SELinux is Enforcing by default
|
||||
'''
|
||||
mock_selinux_config("enforcing", Pihole)
|
||||
check_selinux = Pihole.run('''
|
||||
mock_selinux_config("enforcing", host)
|
||||
check_selinux = host.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
checkSelinux
|
||||
''')
|
||||
|
@ -37,12 +37,12 @@ def test_selinux_enforcing_exit(Pihole):
|
|||
assert check_selinux.rc == 1
|
||||
|
||||
|
||||
def test_selinux_permissive(Pihole):
|
||||
def test_selinux_permissive(host):
|
||||
'''
|
||||
confirms installer continues when SELinux is Permissive
|
||||
'''
|
||||
mock_selinux_config("permissive", Pihole)
|
||||
check_selinux = Pihole.run('''
|
||||
mock_selinux_config("permissive", host)
|
||||
check_selinux = host.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
checkSelinux
|
||||
''')
|
||||
|
@ -51,12 +51,12 @@ def test_selinux_permissive(Pihole):
|
|||
assert check_selinux.rc == 0
|
||||
|
||||
|
||||
def test_selinux_disabled(Pihole):
|
||||
def test_selinux_disabled(host):
|
||||
'''
|
||||
confirms installer continues when SELinux is Disabled
|
||||
'''
|
||||
mock_selinux_config("disabled", Pihole)
|
||||
check_selinux = Pihole.run('''
|
||||
mock_selinux_config("disabled", host)
|
||||
check_selinux = host.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
checkSelinux
|
||||
''')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue