Write enhance()

This commit is contained in:
Brad Warren 2017-08-24 15:26:52 -07:00
parent 00e28592b6
commit 60c6cc5f2a
2 changed files with 15 additions and 14 deletions

View file

@ -142,6 +142,16 @@ class Installer(plugins_common.Plugin):
return set(self.get_config_var(var)
for var in ('mydomain', 'myhostname', 'myorigin',))
def enhance(self, domain, enhancement, options=None):
"""Raises an exception for request for unsupported enhancement.
:raises .PluginError: this is always raised as no enhancements
are currently supported
"""
raise errors.PluginError(
"Unsupported enhancement: {0}".format(enhancement))
def supported_enhancements(self):
"""Returns a list of supported enhancements.
@ -253,20 +263,6 @@ class Installer(plugins_common.Plugin):
self.set_domainwise_tls_policies()
self.update_CAfile()
def enhance(self, domain, enhancement, options=None):
"""Perform a configuration enhancement.
:param str domain: domain for which to provide enhancement
:param str enhancement: An enhancement as defined in
:const:`~letsencrypt.constants.ENHANCEMENTS`
:param options: Flexible options parameter for enhancement.
Check documentation of
:const:`~letsencrypt.constants.ENHANCEMENTS`
for expected options for each enhancement.
:raises .PluginError: If Enhancement is not supported, or if
an error occurs during the enhancement.
"""
def save(self, title=None, temporary=False):
"""Saves all changes to the configuration files.
Both title and temporary are needed because a save may be

View file

@ -84,6 +84,11 @@ class InstallerTest(certbot_test_util.TempDirTestCase):
self.assertTrue("fubard.org" in result)
self.assertTrue("mail.fubard.org" in result)
def test_enhance(self):
self.assertRaises(errors.PluginError,
self._create_prepared_installer().enhance,
"example.org", "redirect")
def test_supported_enhancements(self):
self.assertEqual(
self._create_prepared_installer().supported_enhancements(), [])