示例#1
0
 def test_enhancement_no_deployer(self):
     FAKEINDEX = [{
         "name": "Test",
         "class": enhancements.AutoHSTSEnhancement,
         "updater_function": "deploy_autohsts",
         "deployer_function": None,
         "enable_function": "enable_autohsts"
     }]
     with mock.patch("certbot.plugins.enhancements._INDEX", FAKEINDEX):
         updater.run_renewal_deployer(self.config, mock.MagicMock(),
                                      self.mockinstaller)
     self.assertFalse(self.mockinstaller.deploy_autohsts.called)
示例#2
0
def renew_cert(config, plugins, lineage):
    """Renew & save an existing cert. Do not install it.

    :param config: Configuration object
    :type config: interfaces.IConfig

    :param plugins: List of plugins
    :type plugins: `list` of `str`

    :param lineage: Certificate lineage object
    :type lineage: storage.RenewableCert

    :returns: `None`
    :rtype: None

    :raises errors.PluginSelectionError: MissingCommandlineFlag if supplied parameters do not pass

    """
    try:
        # installers are used in auth mode to determine domain names
        installer, auth = plug_sel.choose_configurator_plugins(
            config, plugins, "certonly")
    except errors.PluginSelectionError as e:
        logger.info("Could not choose appropriate plugin: %s", e)
        raise
    le_client = _init_le_client(config, auth, installer)

    renewed_lineage = _get_and_save_cert(le_client, config, lineage=lineage)

    notify = zope.component.getUtility(interfaces.IDisplay).notification
    if installer is None:
        notify(
            "new certificate deployed without reload, fullchain is {0}".format(
                lineage.fullchain),
            pause=False)
    else:
        # In case of a renewal, reload server to pick up new certificate.
        # In principle we could have a configuration option to inhibit this
        # from happening.
        # Run deployer
        updater.run_renewal_deployer(config, renewed_lineage, installer)
        installer.restart()
        notify(
            "new certificate deployed with reload of {0} server; fullchain is {1}"
            .format(config.installer, lineage.fullchain),
            pause=False)
示例#3
0
 def test_enhancement_deployer_not_called(self):
     self.config.disable_renew_updates = True
     updater.run_renewal_deployer(self.config, mock.MagicMock(),
                                  self.mockinstaller)
     self.assertFalse(self.mockinstaller.deploy_autohsts.called)
示例#4
0
 def test_enhancement_deployer(self):
     updater.run_renewal_deployer(self.config, mock.MagicMock(),
                                  self.mockinstaller)
     self.assertTrue(self.mockinstaller.deploy_autohsts.called)
示例#5
0
 def test_deployer_skip_dry_run(self, mock_log):
     self.config.dry_run = True
     updater.run_renewal_deployer(self.config, None, None)
     self.assertTrue(mock_log.called)
     self.assertEqual(mock_log.call_args[0][0],
                      "Skipping renewal deployer in dry-run mode.")
示例#6
0
 def test_renew_deployer(self):
     lineage = mock.MagicMock()
     mock_deployer = self.renew_deployer
     updater.run_renewal_deployer(self.config, lineage, mock_deployer)
     self.assertTrue(mock_deployer.renew_deploy.called_with(lineage))