Interatively ask for e-mail with register verb

This commit is contained in:
Brad Warren 2016-05-25 22:23:36 -07:00
parent 8d802ef6fd
commit 89279a72bd
2 changed files with 12 additions and 8 deletions

View file

@ -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.

View file

@ -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: