def _get_and_save_cert(le_client, config, domains=None, certname=None, lineage=None): """Authenticate and enroll certificate. This method finds the relevant lineage, figures out what to do with it, then performs that action. Includes calls to hooks, various reports, checks, and requests for user input. :returns: the issued certificate or `None` if doing a dry run :rtype: `storage.RenewableCert` or `None` """ hooks.pre_hook(config) try: if lineage is not None: # Renewal, where we already know the specific lineage we're # interested in logger.info("Renewing an existing certificate") renewal.renew_cert(config, domains, le_client, lineage) else: # TREAT AS NEW REQUEST assert domains is not None logger.info("Obtaining a new certificate") lineage = le_client.obtain_and_enroll_certificate(domains, certname) if lineage is False: raise errors.Error("Certificate could not be obtained") elif lineage is not None: hooks.deploy_hook(config, lineage.names(), lineage.live_dir) finally: hooks.post_hook(config) return lineage
def test_no_deploy_hook(self, mock_renew_hook): args = ( mock.Mock(deploy_hook=None), ['example.org'], 'path', ) hooks.deploy_hook(*args) # pylint: disable=star-args mock_renew_hook.assert_not_called()
def test_deploy_hook(self, mock_renew_hook): args = ( mock.Mock(deploy_hook='foo'), ['example.org'], 'path', ) # pylint: disable=star-args hooks.deploy_hook(*args) mock_renew_hook.assert_called_once_with(*args)
def _call(cls, *args, **kwargs): from certbot.hooks import deploy_hook return deploy_hook(*args, **kwargs)
def test_no_deploy_hook(self, mock_renew_hook): args = (mock.Mock(deploy_hook=None), ['example.org'], 'path',) hooks.deploy_hook(*args) # pylint: disable=star-args mock_renew_hook.assert_not_called()
def test_deploy_hook(self, mock_renew_hook): args = (mock.Mock(deploy_hook='foo'), ['example.org'], 'path',) # pylint: disable=star-args hooks.deploy_hook(*args) mock_renew_hook.assert_called_once_with(*args)