Merge remote-tracking branch 'upstream/master' into sysd_os

This commit is contained in:
Joona Hoikkala
2016-04-29 16:24:36 +03:00
28 changed files with 1151 additions and 6 deletions
+3 -2
View File
@@ -245,8 +245,9 @@ class Client(object):
domains,
self.config.allow_subset_of_names)
domains = [a.body.identifier.value.encode('ascii')
for a in authzr]
auth_domains = set(a.body.identifier.value.encode('ascii')
for a in authzr)
domains = [d for d in domains if d in auth_domains]
# Create CSR from names
key = crypto_util.init_save_key(
+1 -1
View File
@@ -528,7 +528,7 @@ def obtain_cert(config, plugins, lineage=None):
notify("new certificate deployed with reload of {0} server; fullchain is {1}".format(
config.installer, lineage.fullchain), pause=False)
elif action == "reinstall" and config.verb == "certonly":
notify("Certificate not yet due for renewal; no action taken.")
notify("Certificate not yet due for renewal; no action taken.", pause=False)
_suggest_donation_if_appropriate(config, action)
+1 -1
View File
@@ -287,7 +287,7 @@ def _renew_describe_results(config, renew_successes, renew_failures,
if parse_failures:
notify("\nAdditionally, the following renewal configuration files "
"were invalid: ")
notify(parse_failures, "parsefail")
notify(report(parse_failures, "parsefail"))
if config.dry_run:
notify("** DRY RUN: simulating 'certbot renew' close to cert expiry")
+4
View File
@@ -78,6 +78,10 @@ def write_renewal_config(o_filename, n_filename, target, relevant_data):
if k not in relevant_data:
del config["renewalparams"][k]
if "renew_before_expiry" not in config:
default_interval = constants.RENEWER_DEFAULTS["renew_before_expiry"]
config.initial_comment = ["renew_before_expiry = " + default_interval]
# TODO: add human-readable comments explaining other available
# parameters
logger.debug("Writing new config %s.", n_filename)
+2 -1
View File
@@ -201,7 +201,8 @@ class ClientTest(unittest.TestCase):
authzr = []
for domain in domains:
# domain ordering should not be affected by authorization order
for domain in reversed(domains):
authzr.append(
mock.MagicMock(
body=mock.MagicMock(
+48
View File
@@ -0,0 +1,48 @@
"""Tests for certbot.main."""
import unittest
import mock
from certbot import cli
from certbot import configuration
from certbot.plugins import disco as plugins_disco
class ObtainCertTest(unittest.TestCase):
"""Tests for certbot.main.obtain_cert."""
def setUp(self):
self.get_utility_patch = mock.patch(
'certbot.main.zope.component.getUtility')
self.mock_get_utility = self.get_utility_patch.start()
def tearDown(self):
self.get_utility_patch.stop()
def _call(self, args):
plugins = plugins_disco.PluginsRegistry.find_all()
config = configuration.NamespaceConfig(
cli.prepare_and_parse_args(plugins, args))
from certbot import main
with mock.patch('certbot.main._init_le_client') as mock_init:
main.obtain_cert(config, plugins)
return mock_init() # returns the client
@mock.patch('certbot.main._auth_from_domains')
def test_no_reinstall_text_pause(self, mock_auth):
mock_notification = self.mock_get_utility().notification
mock_notification.side_effect = self._assert_no_pause
mock_auth.return_value = (mock.ANY, 'reinstall')
self._call('certonly --webroot -d example.com -t'.split())
def _assert_no_pause(self, message, height=42, pause=True):
# pylint: disable=unused-argument
self.assertFalse(pause)
if __name__ == '__main__':
unittest.main() # pragma: no cover