diff options
author | Will Greenberg <willg@eff.org> | 2022-10-08 02:56:05 +0300 |
---|---|---|
committer | Will Greenberg <willg@eff.org> | 2022-10-08 03:00:10 +0300 |
commit | 7742f69407920cadcab4b329f1478f4f020271ea (patch) | |
tree | daa5e62bad4f93059e870b4d556aed91d8bd5886 | |
parent | aecb2690c8fa07a97d866ff36b84ee76f2e3f4a3 (diff) |
Fix linting/coverage issuesfix-9386
-rw-r--r-- | certbot-apache/certbot_apache/_internal/entrypoint.py | 7 | ||||
-rw-r--r-- | certbot-apache/certbot_apache/_internal/override_centos.py | 6 | ||||
-rw-r--r-- | certbot-apache/tests/entrypoint_test.py | 4 |
3 files changed, 9 insertions, 8 deletions
diff --git a/certbot-apache/certbot_apache/_internal/entrypoint.py b/certbot-apache/certbot_apache/_internal/entrypoint.py index 74c59ca0e..1fa9039e0 100644 --- a/certbot-apache/certbot_apache/_internal/entrypoint.py +++ b/certbot-apache/certbot_apache/_internal/entrypoint.py @@ -31,14 +31,14 @@ OVERRIDE_CLASSES: Dict[str, Type[configurator.ApacheConfigurator]] = { } -def rhel_derived_os(os_name) -> bool: +def rhel_derived_os(os_name: str) -> bool: """ Returns whether the given OS is RHEL derived, i.e. tracks RHEL's versioning scheme, and thus should use our CentOS configurator """ return os_name in [ - "cloudlinux", "centos", "centos linux", + "cloudlinux", "ol", "oracle", "rhel", "redhatenterpriseserver", "red hat enterprise linux server", "scientific", "scientific linux", @@ -56,6 +56,9 @@ def get_configurator() -> Type[configurator.ApacheConfigurator]: if os_name == 'fedora' and util.parse_loose_version(os_version) < min_version: return override_centos.OldCentOSConfigurator + # For CentOS and other RHEL-like distros (that use RHEL's versioning + # scheme), Apache's behavior changed in RHEL v9 (see issue #9386). Determine + # whether we're using the newer or older overrides class based on the version if rhel_derived_os(os_name): old = util.parse_loose_version(os_version) < util.parse_loose_version('9') if old: diff --git a/certbot-apache/certbot_apache/_internal/override_centos.py b/certbot-apache/certbot_apache/_internal/override_centos.py index fbc2cd50d..cd392b38a 100644 --- a/certbot-apache/certbot_apache/_internal/override_centos.py +++ b/certbot-apache/certbot_apache/_internal/override_centos.py @@ -17,7 +17,7 @@ logger = logging.getLogger(__name__) class BaseCentOSConfigurator(configurator.ApacheConfigurator): - """CentOS specific ApacheConfigurator override class""" + """Base class for CentOS specific ApacheConfigurator override class""" def config_test(self) -> None: """ @@ -134,7 +134,7 @@ class BaseCentOSConfigurator(configurator.ApacheConfigurator): class CentOSConfigurator(BaseCentOSConfigurator): - + """CentOS/RHEL-like overrides for CentOS version 9 and above""" OS_DEFAULTS = OsOptions( server_root="/etc/httpd", vhost_root="/etc/httpd/conf.d", @@ -161,7 +161,7 @@ class CentOSConfigurator(BaseCentOSConfigurator): class OldCentOSConfigurator(BaseCentOSConfigurator): - + """CentOS/RHEL-like overrides for CentOS version 8 and below""" OS_DEFAULTS = OsOptions( server_root="/etc/httpd", vhost_root="/etc/httpd/conf.d", diff --git a/certbot-apache/tests/entrypoint_test.py b/certbot-apache/tests/entrypoint_test.py index ca2481fce..2bfd55906 100644 --- a/certbot-apache/tests/entrypoint_test.py +++ b/certbot-apache/tests/entrypoint_test.py @@ -21,9 +21,7 @@ class EntryPointTest(unittest.TestCase): with mock.patch("certbot.util.get_os_info") as mock_info: for distro in entrypoint.OVERRIDE_CLASSES: return_value = (distro, "whatever") - if distro == 'fedora_old': - return_value = ('fedora', '28') - elif distro == 'fedora': + if distro == 'fedora': return_value = ('fedora', '29') mock_info.return_value = return_value self.assertEqual(entrypoint.get_configurator(), |