2020-12-01 10:02:31 +00:00
|
|
|
import pytest
|
|
|
|
from .conftest import (
|
|
|
|
tick_box,
|
|
|
|
info_box,
|
|
|
|
cross_box,
|
|
|
|
mock_command,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-11-18 01:03:37 +00:00
|
|
|
def test_release_supported_version_check_centos(host):
|
2020-12-01 10:02:31 +00:00
|
|
|
'''
|
|
|
|
confirms installer exits on unsupported releases of CentOS
|
|
|
|
'''
|
|
|
|
# modify /etc/redhat-release to mock an unsupported CentOS release
|
2021-11-18 01:03:37 +00:00
|
|
|
host.run('echo "CentOS Linux release 6.9" > /etc/redhat-release')
|
|
|
|
package_manager_detect = host.run('''
|
2020-12-01 10:02:31 +00:00
|
|
|
source /opt/pihole/basic-install.sh
|
2021-08-03 20:48:26 +00:00
|
|
|
package_manager_detect
|
2021-09-12 20:40:37 +00:00
|
|
|
select_rpm_php
|
2020-12-01 10:02:31 +00:00
|
|
|
''')
|
|
|
|
expected_stdout = cross_box + (' CentOS 6 is not supported.')
|
2021-08-03 20:48:26 +00:00
|
|
|
assert expected_stdout in package_manager_detect.stdout
|
2020-12-01 10:02:31 +00:00
|
|
|
expected_stdout = 'Please update to CentOS release 7 or later'
|
2021-08-03 20:48:26 +00:00
|
|
|
assert expected_stdout in package_manager_detect.stdout
|
2020-12-01 10:02:31 +00:00
|
|
|
|
|
|
|
|
2021-11-18 01:03:37 +00:00
|
|
|
def test_enable_epel_repository_centos(host):
|
2020-12-01 10:02:31 +00:00
|
|
|
'''
|
|
|
|
confirms the EPEL package repository is enabled when installed on CentOS
|
|
|
|
'''
|
2021-11-18 01:03:37 +00:00
|
|
|
package_manager_detect = host.run('''
|
2020-12-01 10:02:31 +00:00
|
|
|
source /opt/pihole/basic-install.sh
|
2021-08-03 20:48:26 +00:00
|
|
|
package_manager_detect
|
2021-09-12 20:40:37 +00:00
|
|
|
select_rpm_php
|
2020-12-01 10:02:31 +00:00
|
|
|
''')
|
|
|
|
expected_stdout = info_box + (' Enabling EPEL package repository '
|
|
|
|
'(https://fedoraproject.org/wiki/EPEL)')
|
2021-08-03 20:48:26 +00:00
|
|
|
assert expected_stdout in package_manager_detect.stdout
|
2022-07-03 00:47:41 +00:00
|
|
|
expected_stdout = tick_box + ' Installed'
|
2021-08-03 20:48:26 +00:00
|
|
|
assert expected_stdout in package_manager_detect.stdout
|
2021-11-18 01:03:37 +00:00
|
|
|
epel_package = host.package('epel-release')
|
2020-12-01 10:02:31 +00:00
|
|
|
assert epel_package.is_installed
|
|
|
|
|
|
|
|
|
2021-11-18 01:03:37 +00:00
|
|
|
def test_php_version_lt_7_detected_upgrade_default_optout_centos(host):
|
2020-12-01 10:02:31 +00:00
|
|
|
'''
|
|
|
|
confirms the default behavior to opt-out of upgrading to PHP7 from REMI
|
|
|
|
'''
|
|
|
|
# first we will install the default php version to test installer behavior
|
2021-11-18 01:03:37 +00:00
|
|
|
php_install = host.run('yum install -y php')
|
2020-12-01 10:02:31 +00:00
|
|
|
assert php_install.rc == 0
|
2021-11-18 01:03:37 +00:00
|
|
|
php_package = host.package('php')
|
2020-12-01 10:02:31 +00:00
|
|
|
default_centos_php_version = php_package.version.split('.')[0]
|
|
|
|
if int(default_centos_php_version) >= 7: # PHP7 is supported/recommended
|
|
|
|
pytest.skip("Test deprecated . Detected default PHP version >= 7")
|
2021-11-18 01:03:37 +00:00
|
|
|
package_manager_detect = host.run('''
|
2020-12-01 10:02:31 +00:00
|
|
|
source /opt/pihole/basic-install.sh
|
2021-08-03 20:48:26 +00:00
|
|
|
package_manager_detect
|
2021-09-12 20:40:37 +00:00
|
|
|
select_rpm_php
|
2020-12-01 10:02:31 +00:00
|
|
|
''')
|
|
|
|
expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. '
|
|
|
|
'Deprecated PHP may be in use.')
|
2021-08-03 20:48:26 +00:00
|
|
|
assert expected_stdout in package_manager_detect.stdout
|
2021-11-18 01:03:37 +00:00
|
|
|
remi_package = host.package('remi-release')
|
2020-12-01 10:02:31 +00:00
|
|
|
assert not remi_package.is_installed
|
|
|
|
|
|
|
|
|
2021-11-18 01:03:37 +00:00
|
|
|
def test_php_version_lt_7_detected_upgrade_user_optout_centos(host):
|
2020-12-01 10:02:31 +00:00
|
|
|
'''
|
|
|
|
confirms installer behavior when user opt-out to upgrade to PHP7 via REMI
|
|
|
|
'''
|
|
|
|
# first we will install the default php version to test installer behavior
|
2021-11-18 01:03:37 +00:00
|
|
|
php_install = host.run('yum install -y php')
|
2020-12-01 10:02:31 +00:00
|
|
|
assert php_install.rc == 0
|
2021-11-18 01:03:37 +00:00
|
|
|
php_package = host.package('php')
|
2020-12-01 10:02:31 +00:00
|
|
|
default_centos_php_version = php_package.version.split('.')[0]
|
|
|
|
if int(default_centos_php_version) >= 7: # PHP7 is supported/recommended
|
|
|
|
pytest.skip("Test deprecated . Detected default PHP version >= 7")
|
|
|
|
# Whiptail dialog returns Cancel for user prompt
|
2021-11-18 01:03:37 +00:00
|
|
|
mock_command('whiptail', {'*': ('', '1')}, host)
|
|
|
|
package_manager_detect = host.run('''
|
2020-12-01 10:02:31 +00:00
|
|
|
source /opt/pihole/basic-install.sh
|
2021-08-03 20:48:26 +00:00
|
|
|
package_manager_detect
|
2021-09-12 20:40:37 +00:00
|
|
|
select_rpm_php
|
2020-12-01 10:02:31 +00:00
|
|
|
''')
|
|
|
|
expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. '
|
|
|
|
'Deprecated PHP may be in use.')
|
2021-08-03 20:48:26 +00:00
|
|
|
assert expected_stdout in package_manager_detect.stdout
|
2021-11-18 01:03:37 +00:00
|
|
|
remi_package = host.package('remi-release')
|
2020-12-01 10:02:31 +00:00
|
|
|
assert not remi_package.is_installed
|
|
|
|
|
|
|
|
|
2021-11-18 01:03:37 +00:00
|
|
|
def test_php_version_lt_7_detected_upgrade_user_optin_centos(host):
|
2020-12-01 10:02:31 +00:00
|
|
|
'''
|
|
|
|
confirms installer behavior when user opt-in to upgrade to PHP7 via REMI
|
|
|
|
'''
|
|
|
|
# first we will install the default php version to test installer behavior
|
2021-11-18 01:03:37 +00:00
|
|
|
php_install = host.run('yum install -y php')
|
2020-12-01 10:02:31 +00:00
|
|
|
assert php_install.rc == 0
|
2021-11-18 01:03:37 +00:00
|
|
|
php_package = host.package('php')
|
2020-12-01 10:02:31 +00:00
|
|
|
default_centos_php_version = php_package.version.split('.')[0]
|
|
|
|
if int(default_centos_php_version) >= 7: # PHP7 is supported/recommended
|
|
|
|
pytest.skip("Test deprecated . Detected default PHP version >= 7")
|
|
|
|
# Whiptail dialog returns Continue for user prompt
|
2021-11-18 01:03:37 +00:00
|
|
|
mock_command('whiptail', {'*': ('', '0')}, host)
|
|
|
|
package_manager_detect = host.run('''
|
2020-12-01 10:02:31 +00:00
|
|
|
source /opt/pihole/basic-install.sh
|
2021-08-03 20:48:26 +00:00
|
|
|
package_manager_detect
|
2021-09-12 20:40:37 +00:00
|
|
|
select_rpm_php
|
2020-12-01 10:02:31 +00:00
|
|
|
install_dependent_packages PIHOLE_WEB_DEPS[@]
|
|
|
|
''')
|
|
|
|
expected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS. '
|
|
|
|
'Deprecated PHP may be in use.')
|
2021-08-03 20:48:26 +00:00
|
|
|
assert expected_stdout not in package_manager_detect.stdout
|
2020-12-01 10:02:31 +00:00
|
|
|
expected_stdout = info_box + (' Enabling Remi\'s RPM repository '
|
|
|
|
'(https://rpms.remirepo.net)')
|
2021-08-03 20:48:26 +00:00
|
|
|
assert expected_stdout in package_manager_detect.stdout
|
2020-12-01 10:02:31 +00:00
|
|
|
expected_stdout = tick_box + (' Remi\'s RPM repository has '
|
|
|
|
'been enabled for PHP7')
|
2021-08-03 20:48:26 +00:00
|
|
|
assert expected_stdout in package_manager_detect.stdout
|
2021-11-18 01:03:37 +00:00
|
|
|
remi_package = host.package('remi-release')
|
2020-12-01 10:02:31 +00:00
|
|
|
assert remi_package.is_installed
|
2021-11-18 01:03:37 +00:00
|
|
|
updated_php_package = host.package('php')
|
2020-12-01 10:02:31 +00:00
|
|
|
updated_php_version = updated_php_package.version.split('.')[0]
|
2020-12-01 10:13:36 +00:00
|
|
|
assert int(updated_php_version) == 7
|