From 89279a72bd03c5f05b8b00813e7ea3801059aa4d Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Wed, 25 May 2016 22:23:36 -0700 Subject: [PATCH] Interatively ask for e-mail with register verb --- certbot/main.py | 9 ++++++--- certbot/tests/cli_test.py | 11 ++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/certbot/main.py b/certbot/main.py index 20b9a7ce5..c048d9277 100644 --- a/certbot/main.py +++ b/certbot/main.py @@ -391,9 +391,12 @@ def register(config, unused_plugins): if len(accounts) == 0: return "Could not find an existing account to update." if config.email is None: - return ("Currently, --update-registration can only change the e-mail " - "address\nassociated with an account. A new e-mail address is " - "required\n(hint: --email)") + if config.register_unsafely_without_email: + return ("--register-unsafely-without-email provided, however, a " + "new e-mail address must\ncurrently be provided when " + "updating a registration.") + config.namespace.email = display_ops.get_email(optional=False) + acc, acme = _determine_account(config) acme_client = client.Client(config, acc, None, None, acme=acme) # We rely on an exception to interrupt this process if it didn't work. diff --git a/certbot/tests/cli_test.py b/certbot/tests/cli_test.py index b348e8ea7..b6103c2e8 100644 --- a/certbot/tests/cli_test.py +++ b/certbot/tests/cli_test.py @@ -942,16 +942,17 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods "user@example.org"]) self.assertTrue("Could not find an existing account" in x[0]) - def test_update_registration_no_email(self): + def test_update_registration_unsafely(self): # This test will become obsolete when register --update-registration - # supports updating something other than the e-mail address! - # with mock.patch('certbot.main.client') as mocked_client: + # supports removing an e-mail address from the account with mock.patch('certbot.main.account') as mocked_account: mocked_storage = mock.MagicMock() mocked_account.AccountFileStorage.return_value = mocked_storage mocked_storage.find_all.return_value = ["an account"] - x = self._call_no_clientmock(["register", "--update-registration"]) - self.assertTrue("can only change the e-mail" in x[0]) + x = self._call_no_clientmock( + "register --update-registration " + "--register-unsafely-without-email".split()) + self.assertTrue("--register-unsafely-without-email" in x[0]) def test_update_registration_with_email(self): with mock.patch('certbot.main.client') as mocked_client: