@ -254,73 +254,16 @@ def test_configureFirewall_IPTables_enabled_not_exist_no_errors(Pihole):
assert len ( re . findall ( r ' tcp --dport 4711:4720 ' , firewall_calls ) ) == 2
def test_selinux_ enforcing_default_exit ( Pihole ) :
def test_selinux_ not_detected ( Pihole ) :
'''
confirms installer prompts to exit when SELinux is Enforcing by defaul t
confirms installer continues when SELinux configuration file does not exis t
'''
# getenforce returns the running state of SELinux
mock_command ( ' getenforce ' , { ' * ' : ( ' Enforcing ' , ' 0 ' ) } , Pihole )
# Whiptail dialog returns Cancel for user prompt
mock_command ( ' whiptail ' , { ' * ' : ( ' ' , ' 1 ' ) } , Pihole )
check_selinux = Pihole . run ( '''
source / opt / pihole / basic - install . sh
checkSelinux
''' )
expected_stdout = info_box + ' SELinux mode detected: Enforcing '
assert expected_stdout in check_selinux . stdout
expected_stdout = ' SELinux Enforcing detected, exiting installer '
assert expected_stdout in check_selinux . stdout
assert check_selinux . rc == 1
def test_selinux_enforcing_continue ( Pihole ) :
'''
confirms installer prompts to continue with custom policy warning
'''
# getenforce returns the running state of SELinux
mock_command ( ' getenforce ' , { ' * ' : ( ' Enforcing ' , ' 0 ' ) } , Pihole )
# Whiptail dialog returns Continue for user prompt
mock_command ( ' whiptail ' , { ' * ' : ( ' ' , ' 0 ' ) } , Pihole )
check_selinux = Pihole . run ( '''
source / opt / pihole / basic - install . sh
checkSelinux
''' )
expected_stdout = info_box + ' SELinux mode detected: Enforcing '
assert expected_stdout in check_selinux . stdout
expected_stdout = info_box + ( ' Continuing installation with SELinux '
' Enforcing ' )
assert expected_stdout in check_selinux . stdout
expected_stdout = info_box + ( ' Please refer to official SELinux '
' documentation to create a custom policy ' )
assert expected_stdout in check_selinux . stdout
assert check_selinux . rc == 0
def test_selinux_permissive ( Pihole ) :
'''
confirms installer continues when SELinux is Permissive
'''
# getenforce returns the running state of SELinux
mock_command ( ' getenforce ' , { ' * ' : ( ' Permissive ' , ' 0 ' ) } , Pihole )
check_selinux = Pihole . run ( '''
rm - f / etc / selinux / config
source / opt / pihole / basic - install . sh
checkSelinux
''' )
expected_stdout = info_box + ' SELinux mode detected: Permissive '
assert expected_stdout in check_selinux . stdout
assert check_selinux . rc == 0
def test_selinux_disabled ( Pihole ) :
'''
confirms installer continues when SELinux is Disabled
'''
mock_command ( ' getenforce ' , { ' * ' : ( ' Disabled ' , ' 0 ' ) } , Pihole )
check_selinux = Pihole . run ( '''
source / opt / pihole / basic - install . sh
checkSelinux
''' )
expected_stdout = info_box + ' SELinux mode detected: Disabled '
expected_stdout = info_box + ' SELinux not detected '
assert expected_stdout in check_selinux . stdout
assert check_selinux . rc == 0
@ -399,7 +342,10 @@ def test_FTL_detect_aarch64_no_errors(Pihole):
detectPlatform = Pihole . run ( '''
source / opt / pihole / basic - install . sh
create_pihole_user
FTLdetect
funcOutput = $ ( get_binary_name )
binary = " pihole-FTL$ { funcOutput##*pihole-FTL} "
theRest = " $ { funcOutput % pihole-FTL*} "
FTLdetect " $ {binary} " " $ {theRest} "
''' )
expected_stdout = info_box + ' FTL Checks... '
assert expected_stdout in detectPlatform . stdout
@ -420,7 +366,10 @@ def test_FTL_detect_armv6l_no_errors(Pihole):
detectPlatform = Pihole . run ( '''
source / opt / pihole / basic - install . sh
create_pihole_user
FTLdetect
funcOutput = $ ( get_binary_name )
binary = " pihole-FTL$ { funcOutput##*pihole-FTL} "
theRest = " $ { funcOutput % pihole-FTL*} "
FTLdetect " $ {binary} " " $ {theRest} "
''' )
expected_stdout = info_box + ' FTL Checks... '
assert expected_stdout in detectPlatform . stdout
@ -442,7 +391,10 @@ def test_FTL_detect_armv7l_no_errors(Pihole):
detectPlatform = Pihole . run ( '''
source / opt / pihole / basic - install . sh
create_pihole_user
FTLdetect
funcOutput = $ ( get_binary_name )
binary = " pihole-FTL$ { funcOutput##*pihole-FTL} "
theRest = " $ { funcOutput % pihole-FTL*} "
FTLdetect " $ {binary} " " $ {theRest} "
''' )
expected_stdout = info_box + ' FTL Checks... '
assert expected_stdout in detectPlatform . stdout
@ -459,7 +411,10 @@ def test_FTL_detect_x86_64_no_errors(Pihole):
detectPlatform = Pihole . run ( '''
source / opt / pihole / basic - install . sh
create_pihole_user
FTLdetect
funcOutput = $ ( get_binary_name )
binary = " pihole-FTL$ { funcOutput##*pihole-FTL} "
theRest = " $ { funcOutput % pihole-FTL*} "
FTLdetect " $ {binary} " " $ {theRest} "
''' )
expected_stdout = info_box + ' FTL Checks... '
assert expected_stdout in detectPlatform . stdout
@ -476,7 +431,10 @@ def test_FTL_detect_unknown_no_errors(Pihole):
detectPlatform = Pihole . run ( '''
source / opt / pihole / basic - install . sh
create_pihole_user
FTLdetect
funcOutput = $ ( get_binary_name )
binary = " pihole-FTL$ { funcOutput##*pihole-FTL} "
theRest = " $ { funcOutput % pihole-FTL*} "
FTLdetect " $ {binary} " " $ {theRest} "
''' )
expected_stdout = ' Not able to detect architecture (unknown: mips) '
assert expected_stdout in detectPlatform . stdout
@ -495,64 +453,14 @@ def test_FTL_download_aarch64_no_errors(Pihole):
''' )
download_binary = Pihole . run ( '''
source / opt / pihole / basic - install . sh
binary = " pihole-FTL-aarch64-linux-gnu "
create_pihole_user
FTLinstall
FTLinstall " pihole-FTL-aarch64-linux-gnu "
''' )
expected_stdout = tick_box + ' Downloading and Installing FTL '
assert expected_stdout in download_binary . stdout
assert ' error ' not in download_binary . stdout . lower ( )
def test_FTL_download_unknown_fails_no_errors ( Pihole ) :
'''
confirms unknown binary is not downloaded for FTL engine
'''
# mock whiptail answers and ensure installer dependencies
mock_command ( ' whiptail ' , { ' * ' : ( ' ' , ' 0 ' ) } , Pihole )
Pihole . run ( '''
source / opt / pihole / basic - install . sh
distro_check
install_dependent_packages $ { INSTALLER_DEPS [ @ ] }
''' )
download_binary = Pihole . run ( '''
source / opt / pihole / basic - install . sh
binary = " pihole-FTL-mips "
create_pihole_user
FTLinstall
''' )
expected_stdout = cross_box + ' Downloading and Installing FTL '
assert expected_stdout in download_binary . stdout
error1 = ' Error: URL https://github.com/pi-hole/FTL/releases/download/ '
assert error1 in download_binary . stdout
error2 = ' not found '
assert error2 in download_binary . stdout
def test_FTL_download_binary_unset_no_errors ( Pihole ) :
'''
confirms unset binary variable does not download FTL engine
'''
# mock whiptail answers and ensure installer dependencies
mock_command ( ' whiptail ' , { ' * ' : ( ' ' , ' 0 ' ) } , Pihole )
Pihole . run ( '''
source / opt / pihole / basic - install . sh
distro_check
install_dependent_packages $ { INSTALLER_DEPS [ @ ] }
''' )
download_binary = Pihole . run ( '''
source / opt / pihole / basic - install . sh
create_pihole_user
FTLinstall
''' )
expected_stdout = cross_box + ' Downloading and Installing FTL '
assert expected_stdout in download_binary . stdout
error1 = ' Error: URL https://github.com/pi-hole/FTL/releases/download/ '
assert error1 in download_binary . stdout
error2 = ' not found '
assert error2 in download_binary . stdout
def test_FTL_binary_installed_and_responsive_no_errors ( Pihole ) :
'''
confirms FTL binary is copied and functional in installed location
@ -560,7 +468,10 @@ def test_FTL_binary_installed_and_responsive_no_errors(Pihole):
installed_binary = Pihole . run ( '''
source / opt / pihole / basic - install . sh
create_pihole_user
FTLdetect
funcOutput = $ ( get_binary_name )
binary = " pihole-FTL$ { funcOutput##*pihole-FTL} "
theRest = " $ { funcOutput % pihole-FTL*} "
FTLdetect " $ {binary} " " $ {theRest} "
pihole - FTL version
''' )
expected_stdout = ' v '