mirror of
https://github.com/certbot/certbot.git
synced 2026-06-13 18:50:20 -04:00
Merge pull request #2761 from letsencrypt/fix-dry-run
Fix --dry-run interactions
This commit is contained in:
commit
7fca2f01e4
4 changed files with 28 additions and 6 deletions
|
|
@ -339,7 +339,7 @@ class HelpfulArgumentParser(object):
|
|||
if glob.glob(os.path.join(parsed_args.config_dir, constants.ACCOUNTS_DIR, "*")):
|
||||
# The user has a prod account, but might not have a staging
|
||||
# one; we don't want to start trying to perform interactive registration
|
||||
parsed_args.agree_tos = True
|
||||
parsed_args.tos = True
|
||||
parsed_args.register_unsafely_without_email = True
|
||||
|
||||
if parsed_args.csr:
|
||||
|
|
|
|||
|
|
@ -105,7 +105,8 @@ def register(config, account_storage, tos_cb=None):
|
|||
"--register-unsafely-without-email was not present.")
|
||||
logger.warn(msg)
|
||||
raise errors.Error(msg)
|
||||
logger.warn("Registering without email!")
|
||||
if not config.dry_run:
|
||||
logger.warn("Registering without email!")
|
||||
|
||||
# Each new registration shall use a fresh new key
|
||||
key = jose.JWKRSA(key=jose.ComparableRSAKey(
|
||||
|
|
|
|||
|
|
@ -427,20 +427,40 @@ class CLITest(unittest.TestCase): # pylint: disable=too-many-public-methods
|
|||
short_args += '--server example.com'.split()
|
||||
self._check_server_conflict_message(short_args, '--staging')
|
||||
|
||||
def _assert_dry_run_flag_worked(self, namespace):
|
||||
def _assert_dry_run_flag_worked(self, namespace, existing_account):
|
||||
self.assertTrue(namespace.dry_run)
|
||||
self.assertTrue(namespace.break_my_certs)
|
||||
self.assertTrue(namespace.staging)
|
||||
self.assertEqual(namespace.server, constants.STAGING_URI)
|
||||
|
||||
if existing_account:
|
||||
self.assertTrue(namespace.tos)
|
||||
self.assertTrue(namespace.register_unsafely_without_email)
|
||||
else:
|
||||
self.assertFalse(namespace.tos)
|
||||
self.assertFalse(namespace.register_unsafely_without_email)
|
||||
|
||||
def test_dry_run_flag(self):
|
||||
parse = self._get_argument_parser()
|
||||
short_args = ['--dry-run']
|
||||
config_dir = tempfile.mkdtemp()
|
||||
short_args = '--dry-run --config-dir {0}'.format(config_dir).split()
|
||||
self.assertRaises(errors.Error, parse, short_args)
|
||||
|
||||
self._assert_dry_run_flag_worked(parse(short_args + ['auth']))
|
||||
self._assert_dry_run_flag_worked(
|
||||
parse(short_args + ['auth']), False)
|
||||
self._assert_dry_run_flag_worked(
|
||||
parse(short_args + ['certonly']), False)
|
||||
self._assert_dry_run_flag_worked(
|
||||
parse(short_args + ['renew']), False)
|
||||
|
||||
account_dir = os.path.join(config_dir, constants.ACCOUNTS_DIR)
|
||||
os.mkdir(account_dir)
|
||||
os.mkdir(os.path.join(account_dir, 'fake_account_dir'))
|
||||
|
||||
self._assert_dry_run_flag_worked(parse(short_args + ['auth']), True)
|
||||
self._assert_dry_run_flag_worked(parse(short_args + ['renew']), True)
|
||||
short_args += ['certonly']
|
||||
self._assert_dry_run_flag_worked(parse(short_args))
|
||||
self._assert_dry_run_flag_worked(parse(short_args), True)
|
||||
|
||||
short_args += '--server example.com'.split()
|
||||
conflicts = ['--dry-run']
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ class RegisterTest(unittest.TestCase):
|
|||
with mock.patch("letsencrypt.account.report_new_account"):
|
||||
self.config.email = None
|
||||
self.config.register_unsafely_without_email = True
|
||||
self.config.dry_run = False
|
||||
self._call()
|
||||
mock_logger.warn.assert_called_once_with(mock.ANY)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue