From 05b6717187cbc8d300401c7a2e5b862167690d02 Mon Sep 17 00:00:00 2001 From: bcambl Date: Sun, 9 Aug 2020 12:30:51 -0600 Subject: [PATCH] test PHP optin/optout separately for CentOS 7 & 8 Signed-off-by: bcambl --- test/test_centos_fedora_support.py | 85 ++++++++++++++++++++++++++---- 1 file changed, 74 insertions(+), 11 deletions(-) diff --git a/test/test_centos_fedora_support.py b/test/test_centos_fedora_support.py index e0d25634..9f772f4f 100644 --- a/test/test_centos_fedora_support.py +++ b/test/test_centos_fedora_support.py @@ -88,7 +88,7 @@ def test_epel_and_remi_not_installed_fedora(Pihole): assert not remi_package.is_installed -@pytest.mark.parametrize("tag", [('centos'), ]) +@pytest.mark.parametrize("tag", [('centos7'), ('centos'), ]) def test_release_supported_version_check_centos(Pihole): ''' confirms installer exits on unsupported releases of CentOS @@ -105,7 +105,7 @@ def test_release_supported_version_check_centos(Pihole): assert expected_stdout in distro_check.stdout -@pytest.mark.parametrize("tag", [('centos'), ]) +@pytest.mark.parametrize("tag", [('centos7'), ('centos'), ]) def test_enable_epel_repository_centos(Pihole): ''' confirms the EPEL package repository is enabled when installed on CentOS @@ -123,8 +123,8 @@ def test_enable_epel_repository_centos(Pihole): assert epel_package.is_installed -@pytest.mark.parametrize("tag", [('centos7'), ('centos8'), ]) -def test_php_upgrade_default_optout_centos(Pihole): +@pytest.mark.parametrize("tag", [('centos7'), ]) +def test_php_upgrade_default_optout_centos_eq_7(Pihole): ''' confirms the default behavior to opt-out of installing PHP7 from REMI ''' @@ -139,8 +139,26 @@ def test_php_upgrade_default_optout_centos(Pihole): assert not remi_package.is_installed -@pytest.mark.parametrize("tag", [('centos7'), ('centos8'), ]) -def test_php_upgrade_user_optout_centos(Pihole): +@pytest.mark.parametrize("tag", [('centos'), ]) +def test_php_upgrade_default_continue_centos_gte_8(Pihole): + ''' + confirms the latest version of CentOS continues / does not optout + (should trigger on CentOS7 only) + ''' + distro_check = Pihole.run(''' + source /opt/pihole/basic-install.sh + distro_check + ''') + unexpected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS.' + ' Deprecated PHP may be in use.') + assert unexpected_stdout not in distro_check.stdout + # ensure remi was not installed on latest CentOS + remi_package = Pihole.package('remi-release') + assert not remi_package.is_installed + + +@pytest.mark.parametrize("tag", [('centos7'), ]) +def test_php_upgrade_user_optout_centos_eq_7(Pihole): ''' confirms installer behavior when user opt-out of installing PHP7 from REMI (php not currently installed) @@ -158,8 +176,29 @@ def test_php_upgrade_user_optout_centos(Pihole): assert not remi_package.is_installed -@pytest.mark.parametrize("tag", [('centos7'), ('centos8'), ]) -def test_php_upgrade_user_optin_centos(Pihole): +@pytest.mark.parametrize("tag", [('centos'), ]) +def test_php_upgrade_user_optout_skipped_centos_gte_8(Pihole): + ''' + confirms installer skips user opt-out of installing PHP7 from REMI on + latest CentOS (should trigger on CentOS7 only) + (php not currently installed) + ''' + # Whiptail dialog returns Cancel for user prompt + mock_command('whiptail', {'*': ('', '1')}, Pihole) + distro_check = Pihole.run(''' + source /opt/pihole/basic-install.sh + distro_check + ''') + unexpected_stdout = info_box + (' User opt-out of PHP 7 upgrade on CentOS.' + ' Deprecated PHP may be in use.') + assert unexpected_stdout not in distro_check.stdout + # ensure remi was not installed on latest CentOS + remi_package = Pihole.package('remi-release') + assert not remi_package.is_installed + + +@pytest.mark.parametrize("tag", [('centos7'), ]) +def test_php_upgrade_user_optin_centos_eq_7(Pihole): ''' confirms installer behavior when user opt-in to installing PHP7 from REMI (php not currently installed) @@ -181,7 +220,31 @@ def test_php_upgrade_user_optin_centos(Pihole): assert remi_package.is_installed -@pytest.mark.parametrize("tag", [('centos7'), ('centos8'), ]) +@pytest.mark.parametrize("tag", [('centos'), ]) +def test_php_upgrade_user_optin_skipped_centos_gte_8(Pihole): + ''' + confirms installer skips user opt-in to installing PHP7 from REMI on + latest CentOS (should trigger on CentOS7 only) + (php not currently installed) + ''' + # Whiptail dialog returns Continue for user prompt + mock_command('whiptail', {'*': ('', '0')}, Pihole) + distro_check = Pihole.run(''' + source /opt/pihole/basic-install.sh + distro_check + ''') + assert 'opt-out' not in distro_check.stdout + unexpected_stdout = info_box + (' Enabling Remi\'s RPM repository ' + '(https://rpms.remirepo.net)') + assert unexpected_stdout not in distro_check.stdout + unexpected_stdout = tick_box + (' Remi\'s RPM repository has ' + 'been enabled for PHP7') + assert unexpected_stdout not in distro_check.stdout + remi_package = Pihole.package('remi-release') + assert not remi_package.is_installed + + +@pytest.mark.parametrize("tag", [('centos7'), ('centos'), ]) def test_php_version_lt_7_detected_upgrade_default_optout_centos(Pihole): ''' confirms the default behavior to opt-out of upgrading to PHP7 from REMI @@ -204,7 +267,7 @@ def test_php_version_lt_7_detected_upgrade_default_optout_centos(Pihole): assert not remi_package.is_installed -@pytest.mark.parametrize("tag", [('centos'), ]) +@pytest.mark.parametrize("tag", [('centos7'), ('centos'), ]) def test_php_version_lt_7_detected_upgrade_user_optout_centos(Pihole): ''' confirms installer behavior when user opt-out to upgrade to PHP7 via REMI @@ -229,7 +292,7 @@ def test_php_version_lt_7_detected_upgrade_user_optout_centos(Pihole): assert not remi_package.is_installed -@pytest.mark.parametrize("tag", [('centos'), ]) +@pytest.mark.parametrize("tag", [('centos7'), ('centos'), ]) def test_php_version_lt_7_detected_upgrade_user_optin_centos(Pihole): ''' confirms installer behavior when user opt-in to upgrade to PHP7 via REMI