"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/test_automated_install.py" between
pi-hole-5.3.1.tar.gz and pi-hole-5.4.tar.gz

About: Pi-hole is a DNS sinkhole that protects your devices from unwanted content like Internet advertisements, without installing any client-side software.

test_automated_install.py  (pi-hole-5.3.1):test_automated_install.py  (pi-hole-5.4)
skipping to change at line 20 skipping to change at line 20
run_script run_script
) )
def test_supported_operating_system(Pihole): def test_supported_operating_system(Pihole):
''' '''
confirm installer exists on unsupported distribution confirm installer exists on unsupported distribution
''' '''
# break supported package managers to emulate an unsupported distribution # break supported package managers to emulate an unsupported distribution
Pihole.run('rm -rf /usr/bin/apt-get') Pihole.run('rm -rf /usr/bin/apt-get')
Pihole.run('rm -rf /usr/bin/rpm') Pihole.run('rm -rf /usr/bin/rpm')
distro_check = Pihole.run(''' package_manager_detect = Pihole.run('''
source /opt/pihole/basic-install.sh source /opt/pihole/basic-install.sh
distro_check package_manager_detect
''') ''')
expected_stdout = cross_box + ' OS distribution not supported' expected_stdout = cross_box + ' OS distribution not supported'
assert expected_stdout in distro_check.stdout assert expected_stdout in package_manager_detect.stdout
# assert distro_check.rc == 1 # assert package_manager_detect.rc == 1
def test_setupVars_are_sourced_to_global_scope(Pihole): def test_setupVars_are_sourced_to_global_scope(Pihole):
''' '''
currently update_dialogs sources setupVars with a dot, currently update_dialogs sources setupVars with a dot,
then various other functions use the variables. then various other functions use the variables.
This confirms the sourced variables are in scope between functions This confirms the sourced variables are in scope between functions
''' '''
setup_var_file = 'cat <<EOF> /etc/pihole/setupVars.conf\n' setup_var_file = 'cat <<EOF> /etc/pihole/setupVars.conf\n'
for k, v in SETUPVARS.items(): for k, v in SETUPVARS.items():
setup_var_file += "{}={}\n".format(k, v) setup_var_file += "{}={}\n".format(k, v)
setup_var_file += "EOF\n" setup_var_file += "EOF\n"
Pihole.run(setup_var_file) Pihole.run(setup_var_file)
script = dedent('''\ script = dedent('''\
set -e set -e
printSetupVars() { printSetupVars() {
# Currently debug test function only # Currently debug test function only
echo "Outputting sourced variables" echo "Outputting sourced variables"
echo "PIHOLE_INTERFACE=${PIHOLE_INTERFACE}" echo "PIHOLE_INTERFACE=${PIHOLE_INTERFACE}"
echo "IPV4_ADDRESS=${IPV4_ADDRESS}"
echo "IPV6_ADDRESS=${IPV6_ADDRESS}"
echo "PIHOLE_DNS_1=${PIHOLE_DNS_1}" echo "PIHOLE_DNS_1=${PIHOLE_DNS_1}"
echo "PIHOLE_DNS_2=${PIHOLE_DNS_2}" echo "PIHOLE_DNS_2=${PIHOLE_DNS_2}"
} }
update_dialogs() { update_dialogs() {
. /etc/pihole/setupVars.conf . /etc/pihole/setupVars.conf
} }
update_dialogs update_dialogs
printSetupVars printSetupVars
''') ''')
skipping to change at line 134 skipping to change at line 132
web_directory = Pihole.run('ls -r /var/www/html/pihole').stdout web_directory = Pihole.run('ls -r /var/www/html/pihole').stdout
assert 'index.php' in web_directory assert 'index.php' in web_directory
assert 'blockingpage.css' in web_directory assert 'blockingpage.css' in web_directory
def test_update_package_cache_success_no_errors(Pihole): def test_update_package_cache_success_no_errors(Pihole):
''' '''
confirms package cache was updated without any errors confirms package cache was updated without any errors
''' '''
updateCache = Pihole.run(''' updateCache = Pihole.run('''
source /opt/pihole/basic-install.sh source /opt/pihole/basic-install.sh
distro_check package_manager_detect
update_package_cache update_package_cache
''') ''')
expected_stdout = tick_box + ' Update local cache of available packages' expected_stdout = tick_box + ' Update local cache of available packages'
assert expected_stdout in updateCache.stdout assert expected_stdout in updateCache.stdout
assert 'error' not in updateCache.stdout.lower() assert 'error' not in updateCache.stdout.lower()
def test_update_package_cache_failure_no_errors(Pihole): def test_update_package_cache_failure_no_errors(Pihole):
''' '''
confirms package cache was not updated confirms package cache was not updated
''' '''
mock_command('apt-get', {'update': ('', '1')}, Pihole) mock_command('apt-get', {'update': ('', '1')}, Pihole)
updateCache = Pihole.run(''' updateCache = Pihole.run('''
source /opt/pihole/basic-install.sh source /opt/pihole/basic-install.sh
distro_check package_manager_detect
update_package_cache update_package_cache
''') ''')
expected_stdout = cross_box + ' Update local cache of available packages' expected_stdout = cross_box + ' Update local cache of available packages'
assert expected_stdout in updateCache.stdout assert expected_stdout in updateCache.stdout
assert 'Error: Unable to update package cache.' in updateCache.stdout assert 'Error: Unable to update package cache.' in updateCache.stdout
def test_FTL_detect_aarch64_no_errors(Pihole): def test_FTL_detect_aarch64_no_errors(Pihole):
''' '''
confirms only aarch64 package is downloaded for FTL engine confirms only aarch64 package is downloaded for FTL engine
''' '''
skipping to change at line 346 skipping to change at line 344
assert expected_stdout in detectPlatform.stdout assert expected_stdout in detectPlatform.stdout
def test_FTL_download_aarch64_no_errors(Pihole): def test_FTL_download_aarch64_no_errors(Pihole):
''' '''
confirms only aarch64 package is downloaded for FTL engine confirms only aarch64 package is downloaded for FTL engine
''' '''
# mock whiptail answers and ensure installer dependencies # mock whiptail answers and ensure installer dependencies
mock_command('whiptail', {'*': ('', '0')}, Pihole) mock_command('whiptail', {'*': ('', '0')}, Pihole)
Pihole.run(''' Pihole.run('''
source /opt/pihole/basic-install.sh source /opt/pihole/basic-install.sh
distro_check package_manager_detect
install_dependent_packages ${INSTALLER_DEPS[@]} install_dependent_packages ${INSTALLER_DEPS[@]}
''') ''')
download_binary = Pihole.run(''' download_binary = Pihole.run('''
source /opt/pihole/basic-install.sh source /opt/pihole/basic-install.sh
create_pihole_user create_pihole_user
FTLinstall "pihole-FTL-aarch64-linux-gnu" FTLinstall "pihole-FTL-aarch64-linux-gnu"
''') ''')
expected_stdout = tick_box + ' Downloading and Installing FTL' expected_stdout = tick_box + ' Downloading and Installing FTL'
assert expected_stdout in download_binary.stdout assert expected_stdout in download_binary.stdout
assert 'error' not in download_binary.stdout.lower() assert 'error' not in download_binary.stdout.lower()
skipping to change at line 547 skipping to change at line 545
test_address('0.0.0.0#00', False) test_address('0.0.0.0#00', False)
test_address('0.0.0.0#01', False) test_address('0.0.0.0#01', False)
test_address('0.0.0.0#001', False) test_address('0.0.0.0#001', False)
test_address('0.0.0.0#0001', False) test_address('0.0.0.0#0001', False)
test_address('0.0.0.0#00001', False) test_address('0.0.0.0#00001', False)
def test_os_check_fails(Pihole): def test_os_check_fails(Pihole):
''' Confirms install fails on unsupported OS ''' ''' Confirms install fails on unsupported OS '''
Pihole.run(''' Pihole.run('''
source /opt/pihole/basic-install.sh source /opt/pihole/basic-install.sh
distro_check package_manager_detect
install_dependent_packages ${OS_CHECK_DEPS[@]}
install_dependent_packages ${INSTALLER_DEPS[@]} install_dependent_packages ${INSTALLER_DEPS[@]}
cat <<EOT > /etc/os-release cat <<EOT > /etc/os-release
ID=UnsupportedOS ID=UnsupportedOS
VERSION_ID="2" VERSION_ID="2"
EOT EOT
''') ''')
detectOS = Pihole.run('''t detectOS = Pihole.run('''t
source /opt/pihole/basic-install.sh source /opt/pihole/basic-install.sh
os_check os_check
''') ''')
expected_stdout = 'Unsupported OS detected: UnsupportedOS' expected_stdout = 'Unsupported OS detected: UnsupportedOS'
assert expected_stdout in detectOS.stdout assert expected_stdout in detectOS.stdout
def test_os_check_passes(Pihole): def test_os_check_passes(Pihole):
''' Confirms OS meets the requirements ''' ''' Confirms OS meets the requirements '''
Pihole.run(''' Pihole.run('''
source /opt/pihole/basic-install.sh source /opt/pihole/basic-install.sh
distro_check package_manager_detect
install_dependent_packages ${OS_CHECK_DEPS[@]}
install_dependent_packages ${INSTALLER_DEPS[@]} install_dependent_packages ${INSTALLER_DEPS[@]}
''') ''')
detectOS = Pihole.run(''' detectOS = Pihole.run('''
source /opt/pihole/basic-install.sh source /opt/pihole/basic-install.sh
os_check os_check
''') ''')
expected_stdout = 'Supported OS detected' expected_stdout = 'Supported OS detected'
assert expected_stdout in detectOS.stdout assert expected_stdout in detectOS.stdout
def test_package_manager_has_installer_deps(Pihole):
''' Confirms OS is able to install the required packages for the installer''
'
mock_command('whiptail', {'*': ('', '0')}, Pihole)
output = Pihole.run('''
source /opt/pihole/basic-install.sh
package_manager_detect
install_dependent_packages ${INSTALLER_DEPS[@]}
''')
assert 'No package' not in output.stdout # centos7 still exits 0...
assert output.rc == 0
def test_package_manager_has_pihole_deps(Pihole):
''' Confirms OS is able to install the required packages for Pi-hole '''
mock_command('whiptail', {'*': ('', '0')}, Pihole)
output = Pihole.run('''
source /opt/pihole/basic-install.sh
package_manager_detect
install_dependent_packages ${PIHOLE_DEPS[@]}
''')
assert 'No package' not in output.stdout # centos7 still exits 0...
assert output.rc == 0
def test_package_manager_has_web_deps(Pihole):
''' Confirms OS is able to install the required packages for web '''
mock_command('whiptail', {'*': ('', '0')}, Pihole)
output = Pihole.run('''
source /opt/pihole/basic-install.sh
package_manager_detect
install_dependent_packages ${PIHOLE_WEB_DEPS[@]}
''')
assert 'No package' not in output.stdout # centos7 still exits 0...
assert output.rc == 0
 End of changes. 10 change blocks. 
11 lines changed or deleted 11 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)