mirror of
https://github.com/certbot/certbot.git
synced 2026-01-26 07:41:33 +03:00
* Start to plug specific logic for Fedora >= 29 * Invert the logic * Implement specifics for Fedora 29 * Fix config * Add documentation * Fix parser, fix tests * Fix import * Fix lint * Use LooseVersion to be fail safe on versions comparison * Remove conditional restart on fedora override * Use parent logic * Update certbot-apache/certbot_apache/tests/fedora_test.py Co-Authored-By: adferrand <adferrand@users.noreply.github.com> * Simplify restart test * Update certbot-apache/certbot_apache/override_fedora.py Co-Authored-By: adferrand <adferrand@users.noreply.github.com> * Correct test assertion * Fix pylint errors * Revert to a direct call to systemctl
48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
"""Test for certbot_apache.entrypoint for override class resolution"""
|
|
import unittest
|
|
|
|
import mock
|
|
|
|
from certbot_apache import configurator
|
|
from certbot_apache import entrypoint
|
|
|
|
|
|
class EntryPointTest(unittest.TestCase):
|
|
"""Entrypoint tests"""
|
|
|
|
_multiprocess_can_split_ = True
|
|
|
|
def test_get_configurator(self):
|
|
|
|
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':
|
|
return_value = ('fedora', '29')
|
|
mock_info.return_value = return_value
|
|
self.assertEqual(entrypoint.get_configurator(),
|
|
entrypoint.OVERRIDE_CLASSES[distro])
|
|
|
|
def test_nonexistent_like(self):
|
|
with mock.patch("certbot.util.get_os_info") as mock_info:
|
|
mock_info.return_value = ("nonexistent", "irrelevant")
|
|
with mock.patch("certbot.util.get_systemd_os_like") as mock_like:
|
|
for like in entrypoint.OVERRIDE_CLASSES:
|
|
mock_like.return_value = [like]
|
|
self.assertEqual(entrypoint.get_configurator(),
|
|
entrypoint.OVERRIDE_CLASSES[like])
|
|
|
|
def test_nonexistent_generic(self):
|
|
with mock.patch("certbot.util.get_os_info") as mock_info:
|
|
mock_info.return_value = ("nonexistent", "irrelevant")
|
|
with mock.patch("certbot.util.get_systemd_os_like") as mock_like:
|
|
mock_like.return_value = ["unknonwn"]
|
|
self.assertEqual(entrypoint.get_configurator(),
|
|
configurator.ApacheConfigurator)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main() # pragma: no cover
|