From 8390c65a95e94daf15ea636daa68d1280fae0cef Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Wed, 30 Nov 2022 13:56:09 -0800 Subject: [PATCH] fix certbot plugins output (#9488) --- certbot/CHANGELOG.md | 1 + certbot/certbot/_internal/plugins/disco.py | 26 +++++----------------- certbot/tests/plugins/disco_test.py | 6 +++++ 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/certbot/CHANGELOG.md b/certbot/CHANGELOG.md index 90ef2f66f..b60f94eb0 100644 --- a/certbot/CHANGELOG.md +++ b/certbot/CHANGELOG.md @@ -14,6 +14,7 @@ Certbot adheres to [Semantic Versioning](https://semver.org/). ### Fixed +* Interfaces which plugins register themselves as implementing without inheriting from them now show up in `certbot plugins` output. * `IPluginFactory`, `IPlugin`, `IAuthenticator` and `IInstaller` have been re-added to `certbot.interfaces`. - This is to fix compatibility with a number of third-party DNS plugins which may diff --git a/certbot/certbot/_internal/plugins/disco.py b/certbot/certbot/_internal/plugins/disco.py index 62e75ead1..5e767ae6d 100644 --- a/certbot/certbot/_internal/plugins/disco.py +++ b/certbot/certbot/_internal/plugins/disco.py @@ -24,25 +24,9 @@ from certbot.errors import Error logger = logging.getLogger(__name__) -PREFIX_FREE_DISTRIBUTIONS = [ - "certbot", - "certbot-apache", - "certbot-dns-cloudflare", - "certbot-dns-digitalocean", - "certbot-dns-dnsimple", - "certbot-dns-dnsmadeeasy", - "certbot-dns-gehirn", - "certbot-dns-google", - "certbot-dns-linode", - "certbot-dns-luadns", - "certbot-dns-nsone", - "certbot-dns-ovh", - "certbot-dns-rfc2136", - "certbot-dns-route53", - "certbot-dns-sakuracloud", - "certbot-nginx", -] -"""Distributions for which prefix will be omitted.""" + +PLUGIN_INTERFACES = [interfaces.Authenticator, interfaces.Installer, interfaces.Plugin] +"""Interfaces that should be listed in `certbot plugins` output""" class PluginEntryPoint: @@ -165,8 +149,8 @@ class PluginEntryPoint: "* {0}".format(self.name), "Description: {0}".format(self.plugin_cls.description), "Interfaces: {0}".format(", ".join( - cls.__name__ for cls in self.plugin_cls.mro() - if cls.__module__ == 'certbot.interfaces' + iface.__name__ for iface in PLUGIN_INTERFACES + if issubclass(self.plugin_cls, iface) )), "Entry point: {0}".format(self.entry_point), ] diff --git a/certbot/tests/plugins/disco_test.py b/certbot/tests/plugins/disco_test.py index 17677792f..673a8d04b 100644 --- a/certbot/tests/plugins/disco_test.py +++ b/certbot/tests/plugins/disco_test.py @@ -152,6 +152,12 @@ class PluginEntryPointTest(unittest.TestCase): self.assertIs(self.plugin_ep.misconfigured, False) self.assertIs(self.plugin_ep.available, False) + def test_str(self): + output = str(self.plugin_ep) + self.assertIn("Authenticator", output) + self.assertNotIn("Installer", output) + self.assertIn("Plugin", output) + def test_repr(self): self.assertEqual("PluginEntryPoint#sa", repr(self.plugin_ep))