mirror of
https://github.com/certbot/certbot.git
synced 2026-06-07 07:42:08 -04:00
errors.LetsEncrypt -> errors. (fixes: #487)
This commit is contained in:
parent
655331c9cf
commit
cfa7e28106
30 changed files with 147 additions and 147 deletions
|
|
@ -127,7 +127,7 @@ class Account(object):
|
|||
acc_config = configobj.ConfigObj(
|
||||
infile=config_fp, file_error=True, create_empty=False)
|
||||
except IOError:
|
||||
raise errors.LetsEncryptClientError(
|
||||
raise errors.Error(
|
||||
"Account for %s does not exist" % os.path.basename(config_fp))
|
||||
|
||||
if os.path.basename(config_fp) != "default":
|
||||
|
|
@ -191,7 +191,7 @@ class Account(object):
|
|||
if code == display_util.OK:
|
||||
try:
|
||||
return cls.from_email(config, email)
|
||||
except errors.LetsEncryptClientError:
|
||||
except errors.Error:
|
||||
continue
|
||||
else:
|
||||
return None
|
||||
|
|
@ -205,7 +205,7 @@ class Account(object):
|
|||
|
||||
:param str email: Email address
|
||||
|
||||
:raises letsencrypt.errors.LetsEncryptClientError: If invalid
|
||||
:raises letsencrypt.errors.Error: If invalid
|
||||
email address is given.
|
||||
|
||||
"""
|
||||
|
|
@ -219,7 +219,7 @@ class Account(object):
|
|||
cls._get_config_filename(email))
|
||||
return cls(config, key, email)
|
||||
|
||||
raise errors.LetsEncryptClientError("Invalid email address.")
|
||||
raise errors.Error("Invalid email address.")
|
||||
|
||||
@classmethod
|
||||
def safe_email(cls, email):
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ class AuthHandler(object):
|
|||
:class:`letsencrypt.achallenges.Indexed`
|
||||
:rtype: tuple
|
||||
|
||||
:raises errors.LetsEncryptClientError: If Challenge type is not
|
||||
:raises errors.Error: If Challenge type is not
|
||||
recognized
|
||||
|
||||
"""
|
||||
|
|
@ -353,7 +353,7 @@ def challb_to_achall(challb, key, domain):
|
|||
challb=challb, domain=domain)
|
||||
|
||||
else:
|
||||
raise errors.LetsEncryptClientError(
|
||||
raise errors.Error(
|
||||
"Received unsupported challenge of type: %s",
|
||||
chall.typ)
|
||||
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@ def _account_init(args, config):
|
|||
# The way to get the default would be args.email = ""
|
||||
# First try existing account
|
||||
return account.Account.from_existing_account(config, args.email)
|
||||
except errors.LetsEncryptClientError:
|
||||
except errors.Error:
|
||||
try:
|
||||
# Try to make an account based on the email address
|
||||
return account.Account.from_email(config, args.email)
|
||||
except errors.LetsEncryptClientError:
|
||||
except errors.Error:
|
||||
return None
|
||||
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ def _common_run(args, config, acc, authenticator, installer):
|
|||
if acc.regr is None:
|
||||
try:
|
||||
acme.register()
|
||||
except errors.LetsEncryptClientError:
|
||||
except errors.Error:
|
||||
sys.exit("Unable to register an account with ACME server")
|
||||
|
||||
return acme, doms
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ class Client(object):
|
|||
self.account.regr = self.network.agree_to_tos(self.account.regr)
|
||||
else:
|
||||
# What is the proper response here...
|
||||
raise errors.LetsEncryptClientError("Must agree to TOS")
|
||||
raise errors.Error("Must agree to TOS")
|
||||
|
||||
self.account.save()
|
||||
self._report_new_account()
|
||||
|
|
@ -145,9 +145,9 @@ class Client(object):
|
|||
msg = ("Unable to obtain certificate because authenticator is "
|
||||
"not set.")
|
||||
logging.warning(msg)
|
||||
raise errors.LetsEncryptClientError(msg)
|
||||
raise errors.Error(msg)
|
||||
if self.account.regr is None:
|
||||
raise errors.LetsEncryptClientError(
|
||||
raise errors.Error(
|
||||
"Please register with the ACME server first.")
|
||||
|
||||
# Perform Challenges/Get Authorizations
|
||||
|
|
@ -310,7 +310,7 @@ class Client(object):
|
|||
if self.installer is None:
|
||||
logging.warning("No installer specified, client is unable to deploy"
|
||||
"the certificate")
|
||||
raise errors.LetsEncryptClientError("No installer available")
|
||||
raise errors.Error("No installer available")
|
||||
|
||||
chain_path = None if chain_path is None else os.path.abspath(chain_path)
|
||||
|
||||
|
|
@ -339,14 +339,14 @@ class Client(object):
|
|||
:param redirect: If traffic should be forwarded from HTTP to HTTPS.
|
||||
:type redirect: bool or None
|
||||
|
||||
:raises letsencrypt.errors.LetsEncryptClientError: if
|
||||
:raises letsencrypt.errors.Error: if
|
||||
no installer is specified in the client.
|
||||
|
||||
"""
|
||||
if self.installer is None:
|
||||
logging.warning("No installer is specified, there isn't any "
|
||||
"configuration to enhance.")
|
||||
raise errors.LetsEncryptClientError("No installer available")
|
||||
raise errors.Error("No installer available")
|
||||
|
||||
if redirect is None:
|
||||
redirect = enhancements.ask("redirect")
|
||||
|
|
@ -364,7 +364,7 @@ class Client(object):
|
|||
for dom in domains:
|
||||
try:
|
||||
self.installer.enhance(dom, "redirect")
|
||||
except errors.LetsEncryptConfiguratorError:
|
||||
except errors.ConfiguratorError:
|
||||
logging.warn("Unable to perform redirect for %s", dom)
|
||||
|
||||
self.installer.save("Add Redirects")
|
||||
|
|
@ -386,7 +386,7 @@ def validate_key_csr(privkey, csr=None):
|
|||
:param csr: CSR
|
||||
:type csr: :class:`letsencrypt.le_util.CSR`
|
||||
|
||||
:raises letsencrypt.errors.LetsEncryptClientError: when
|
||||
:raises letsencrypt.errors.Error: when
|
||||
validation fails
|
||||
|
||||
"""
|
||||
|
|
@ -396,7 +396,7 @@ def validate_key_csr(privkey, csr=None):
|
|||
|
||||
# Key must be readable and valid.
|
||||
if privkey.pem and not crypto_util.valid_privkey(privkey.pem):
|
||||
raise errors.LetsEncryptClientError(
|
||||
raise errors.Error(
|
||||
"The provided key is not a valid key")
|
||||
|
||||
if csr:
|
||||
|
|
@ -406,7 +406,7 @@ def validate_key_csr(privkey, csr=None):
|
|||
|
||||
# If CSR is provided, it must be readable and valid.
|
||||
if csr.data and not crypto_util.valid_csr(csr.data):
|
||||
raise errors.LetsEncryptClientError(
|
||||
raise errors.Error(
|
||||
"The provided CSR is not a valid CSR")
|
||||
|
||||
# If both CSR and key are provided, the key must be the same key used
|
||||
|
|
@ -414,7 +414,7 @@ def validate_key_csr(privkey, csr=None):
|
|||
if csr.data and privkey.pem:
|
||||
if not crypto_util.csr_matches_pubkey(
|
||||
csr.data, privkey.pem):
|
||||
raise errors.LetsEncryptClientError(
|
||||
raise errors.Error(
|
||||
"The key and CSR do not match")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class ContinuityAuthenticator(object):
|
|||
elif isinstance(achall, achallenges.RecoveryToken):
|
||||
responses.append(self.rec_token.perform(achall))
|
||||
else:
|
||||
raise errors.LetsEncryptContAuthError("Unexpected Challenge")
|
||||
raise errors.ContAuthError("Unexpected Challenge")
|
||||
return responses
|
||||
|
||||
def cleanup(self, achalls):
|
||||
|
|
@ -61,4 +61,4 @@ class ContinuityAuthenticator(object):
|
|||
if isinstance(achall, achallenges.RecoveryToken):
|
||||
self.rec_token.cleanup(achall)
|
||||
elif not isinstance(achall, achallenges.ProofOfPossession):
|
||||
raise errors.LetsEncryptContAuthError("Unexpected Challenge")
|
||||
raise errors.ContAuthError("Unexpected Challenge")
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ def ask(enhancement):
|
|||
:returns: True if feature is desired, False otherwise
|
||||
:rtype: bool
|
||||
|
||||
:raises letsencrypt.errors.LetsEncryptClientError: If
|
||||
:raises letsencrypt.errors.Error: If
|
||||
the enhancement provided is not supported.
|
||||
|
||||
"""
|
||||
|
|
@ -30,7 +30,7 @@ def ask(enhancement):
|
|||
return DISPATCH[enhancement]()
|
||||
except KeyError:
|
||||
logging.error("Unsupported enhancement given to ask(): %s", enhancement)
|
||||
raise errors.LetsEncryptClientError("Unsupported Enhancement")
|
||||
raise errors.Error("Unsupported Enhancement")
|
||||
|
||||
|
||||
def redirect_by_default():
|
||||
|
|
|
|||
|
|
@ -1,44 +1,44 @@
|
|||
"""Let's Encrypt client errors."""
|
||||
|
||||
|
||||
class LetsEncryptClientError(Exception):
|
||||
class Error(Exception):
|
||||
"""Generic Let's Encrypt client error."""
|
||||
|
||||
|
||||
class LetsEncryptReverterError(LetsEncryptClientError):
|
||||
class ReverterError(Error):
|
||||
"""Let's Encrypt Reverter error."""
|
||||
|
||||
|
||||
# Auth Handler Errors
|
||||
class AuthorizationError(LetsEncryptClientError):
|
||||
class AuthorizationError(Error):
|
||||
"""Authorization error."""
|
||||
|
||||
|
||||
class LetsEncryptContAuthError(AuthorizationError):
|
||||
class ContAuthError(AuthorizationError):
|
||||
"""Let's Encrypt Continuity Authenticator error."""
|
||||
|
||||
|
||||
class LetsEncryptDvAuthError(AuthorizationError):
|
||||
class DvAuthError(AuthorizationError):
|
||||
"""Let's Encrypt DV Authenticator error."""
|
||||
|
||||
|
||||
# Authenticator - Challenge specific errors
|
||||
class LetsEncryptDvsniError(LetsEncryptDvAuthError):
|
||||
class DvsniError(DvAuthError):
|
||||
"""Let's Encrypt DVSNI error."""
|
||||
|
||||
|
||||
# Configurator Errors
|
||||
class LetsEncryptConfiguratorError(LetsEncryptClientError):
|
||||
class ConfiguratorError(Error):
|
||||
"""Let's Encrypt Configurator error."""
|
||||
|
||||
|
||||
class LetsEncryptNoInstallationError(LetsEncryptConfiguratorError):
|
||||
class NoInstallationError(ConfiguratorError):
|
||||
"""Let's Encrypt No Installation error."""
|
||||
|
||||
|
||||
class LetsEncryptMisconfigurationError(LetsEncryptConfiguratorError):
|
||||
class MisconfigurationError(ConfiguratorError):
|
||||
"""Let's Encrypt Misconfiguration error."""
|
||||
|
||||
|
||||
class LetsEncryptRevokerError(LetsEncryptClientError):
|
||||
class RevokerError(Error):
|
||||
"""Let's Encrypt Revoker error."""
|
||||
|
|
|
|||
|
|
@ -68,10 +68,10 @@ class IPlugin(zope.interface.Interface):
|
|||
|
||||
Finish up any additional initialization.
|
||||
|
||||
:raises letsencrypt.errors.LetsEncryptMisconfigurationError:
|
||||
:raises letsencrypt.errors.MisconfigurationError:
|
||||
when full initialization cannot be completed. Plugin will be
|
||||
displayed on a list of available plugins.
|
||||
:raises letsencrypt.errors.LetsEncryptNoInstallationError:
|
||||
:raises letsencrypt.errors.NoInstallationError:
|
||||
when the necessary programs/files cannot be located. Plugin
|
||||
will NOT be displayed on a list of available plugins.
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ def make_or_verify_dir(directory, mode=0o755, uid=0):
|
|||
:param int mode: Directory mode.
|
||||
:param int uid: Directory owner.
|
||||
|
||||
:raises LetsEncryptClientError: if a directory already exists,
|
||||
:raises Error: if a directory already exists,
|
||||
but has wrong permissions or owner
|
||||
|
||||
:raises OSError: if invalid or inaccessible file names and
|
||||
|
|
@ -32,7 +32,7 @@ def make_or_verify_dir(directory, mode=0o755, uid=0):
|
|||
except OSError as exception:
|
||||
if exception.errno == errno.EEXIST:
|
||||
if not check_permissions(directory, mode, uid):
|
||||
raise errors.LetsEncryptClientError(
|
||||
raise errors.Error(
|
||||
"%s exists, but does not have the proper "
|
||||
"permissions or owner" % directory)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -89,10 +89,10 @@ class PluginEntryPoint(object):
|
|||
if self._prepared is None:
|
||||
try:
|
||||
self._initialized.prepare()
|
||||
except errors.LetsEncryptMisconfigurationError as error:
|
||||
except errors.MisconfigurationError as error:
|
||||
logging.debug("Misconfigured %r: %s", self, error)
|
||||
self._prepared = error
|
||||
except errors.LetsEncryptNoInstallationError as error:
|
||||
except errors.NoInstallationError as error:
|
||||
logging.debug("No installation (%r): %s", self, error)
|
||||
self._prepared = error
|
||||
else:
|
||||
|
|
@ -103,7 +103,7 @@ class PluginEntryPoint(object):
|
|||
def misconfigured(self):
|
||||
"""Is plugin misconfigured?"""
|
||||
return isinstance(
|
||||
self._prepared, errors.LetsEncryptMisconfigurationError)
|
||||
self._prepared, errors.MisconfigurationError)
|
||||
|
||||
@property
|
||||
def available(self):
|
||||
|
|
|
|||
|
|
@ -124,22 +124,22 @@ class PluginEntryPointTest(unittest.TestCase):
|
|||
|
||||
def test_prepare_misconfigured(self):
|
||||
plugin = mock.MagicMock()
|
||||
plugin.prepare.side_effect = errors.LetsEncryptMisconfigurationError
|
||||
plugin.prepare.side_effect = errors.MisconfigurationError
|
||||
# pylint: disable=protected-access
|
||||
self.plugin_ep._initialized = plugin
|
||||
self.assertTrue(isinstance(self.plugin_ep.prepare(),
|
||||
errors.LetsEncryptMisconfigurationError))
|
||||
errors.MisconfigurationError))
|
||||
self.assertTrue(self.plugin_ep.prepared)
|
||||
self.assertTrue(self.plugin_ep.misconfigured)
|
||||
self.assertTrue(self.plugin_ep.available)
|
||||
|
||||
def test_prepare_no_installation(self):
|
||||
plugin = mock.MagicMock()
|
||||
plugin.prepare.side_effect = errors.LetsEncryptNoInstallationError
|
||||
plugin.prepare.side_effect = errors.NoInstallationError
|
||||
# pylint: disable=protected-access
|
||||
self.plugin_ep._initialized = plugin
|
||||
self.assertTrue(isinstance(self.plugin_ep.prepare(),
|
||||
errors.LetsEncryptNoInstallationError))
|
||||
errors.NoInstallationError))
|
||||
self.assertTrue(self.plugin_ep.prepared)
|
||||
self.assertFalse(self.plugin_ep.misconfigured)
|
||||
self.assertFalse(self.plugin_ep.available)
|
||||
|
|
|
|||
|
|
@ -30,18 +30,18 @@ class Reverter(object):
|
|||
This function should reinstall the users original configuration files
|
||||
for all saves with temporary=True
|
||||
|
||||
:raises letsencrypt.errors.LetsEncryptReverterError: when
|
||||
:raises letsencrypt.errors.ReverterError: when
|
||||
unable to revert config
|
||||
|
||||
"""
|
||||
if os.path.isdir(self.config.temp_checkpoint_dir):
|
||||
try:
|
||||
self._recover_checkpoint(self.config.temp_checkpoint_dir)
|
||||
except errors.LetsEncryptReverterError:
|
||||
except errors.ReverterError:
|
||||
# We have a partial or incomplete recovery
|
||||
logging.fatal("Incomplete or failed recovery for %s",
|
||||
self.config.temp_checkpoint_dir)
|
||||
raise errors.LetsEncryptReverterError(
|
||||
raise errors.ReverterError(
|
||||
"Unable to revert temporary config")
|
||||
|
||||
def rollback_checkpoints(self, rollback=1):
|
||||
|
|
@ -50,7 +50,7 @@ class Reverter(object):
|
|||
:param int rollback: Number of checkpoints to reverse. A str num will be
|
||||
cast to an integer. So "2" is also acceptable.
|
||||
|
||||
:raises letsencrypt.errors.LetsEncryptReverterError: If
|
||||
:raises letsencrypt.errors.ReverterError: If
|
||||
there is a problem with the input or if the function is unable to
|
||||
correctly revert the configuration checkpoints.
|
||||
|
||||
|
|
@ -59,11 +59,11 @@ class Reverter(object):
|
|||
rollback = int(rollback)
|
||||
except ValueError:
|
||||
logging.error("Rollback argument must be a positive integer")
|
||||
raise errors.LetsEncryptReverterError("Invalid Input")
|
||||
raise errors.ReverterError("Invalid Input")
|
||||
# Sanity check input
|
||||
if rollback < 0:
|
||||
logging.error("Rollback argument must be a positive integer")
|
||||
raise errors.LetsEncryptReverterError("Invalid Input")
|
||||
raise errors.ReverterError("Invalid Input")
|
||||
|
||||
backups = os.listdir(self.config.backup_dir)
|
||||
backups.sort()
|
||||
|
|
@ -76,9 +76,9 @@ class Reverter(object):
|
|||
cp_dir = os.path.join(self.config.backup_dir, backups.pop())
|
||||
try:
|
||||
self._recover_checkpoint(cp_dir)
|
||||
except errors.LetsEncryptReverterError:
|
||||
except errors.ReverterError:
|
||||
logging.fatal("Failed to load checkpoint during rollback")
|
||||
raise errors.LetsEncryptReverterError(
|
||||
raise errors.ReverterError(
|
||||
"Unable to load checkpoint during rollback")
|
||||
rollback -= 1
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ class Reverter(object):
|
|||
for bkup in backups:
|
||||
float(bkup)
|
||||
except ValueError:
|
||||
raise errors.LetsEncryptReverterError(
|
||||
raise errors.ReverterError(
|
||||
"Invalid directories in {0}".format(self.config.backup_dir))
|
||||
|
||||
output = []
|
||||
|
|
@ -162,7 +162,7 @@ class Reverter(object):
|
|||
:param str save_notes: notes about changes made during the save
|
||||
|
||||
:raises IOError: If unable to open cp_dir + FILEPATHS file
|
||||
:raises letsencrypt.errors.LetsEncryptReverterError: If
|
||||
:raises letsencrypt.errors.ReverterError: If
|
||||
unable to add checkpoint
|
||||
|
||||
"""
|
||||
|
|
@ -191,7 +191,7 @@ class Reverter(object):
|
|||
logging.error(
|
||||
"Unable to add file %s to checkpoint %s",
|
||||
filename, cp_dir)
|
||||
raise errors.LetsEncryptReverterError(
|
||||
raise errors.ReverterError(
|
||||
"Unable to add file {0} to checkpoint "
|
||||
"{1}".format(filename, cp_dir))
|
||||
idx += 1
|
||||
|
|
@ -224,7 +224,7 @@ class Reverter(object):
|
|||
|
||||
:param str cp_dir: checkpoint directory file path
|
||||
|
||||
:raises errors.LetsEncryptReverterError: If unable to recover checkpoint
|
||||
:raises errors.ReverterError: If unable to recover checkpoint
|
||||
|
||||
"""
|
||||
if os.path.isfile(os.path.join(cp_dir, "FILEPATHS")):
|
||||
|
|
@ -238,7 +238,7 @@ class Reverter(object):
|
|||
except (IOError, OSError):
|
||||
# This file is required in all checkpoints.
|
||||
logging.error("Unable to recover files from %s", cp_dir)
|
||||
raise errors.LetsEncryptReverterError(
|
||||
raise errors.ReverterError(
|
||||
"Unable to recover files from %s" % cp_dir)
|
||||
|
||||
# Remove any newly added files if they exist
|
||||
|
|
@ -248,7 +248,7 @@ class Reverter(object):
|
|||
shutil.rmtree(cp_dir)
|
||||
except OSError:
|
||||
logging.error("Unable to remove directory: %s", cp_dir)
|
||||
raise errors.LetsEncryptReverterError(
|
||||
raise errors.ReverterError(
|
||||
"Unable to remove directory: %s" % cp_dir)
|
||||
|
||||
def _check_tempfile_saves(self, save_files):
|
||||
|
|
@ -256,7 +256,7 @@ class Reverter(object):
|
|||
|
||||
:param set save_files: Set of files about to be saved.
|
||||
|
||||
:raises letsencrypt.errors.LetsEncryptReverterError:
|
||||
:raises letsencrypt.errors.ReverterError:
|
||||
when save is attempting to overwrite a temporary file.
|
||||
|
||||
"""
|
||||
|
|
@ -277,7 +277,7 @@ class Reverter(object):
|
|||
# Verify no save_file is in protected_files
|
||||
for filename in protected_files:
|
||||
if filename in save_files:
|
||||
raise errors.LetsEncryptReverterError(
|
||||
raise errors.ReverterError(
|
||||
"Attempting to overwrite challenge "
|
||||
"file - %s" % filename)
|
||||
|
||||
|
|
@ -292,7 +292,7 @@ class Reverter(object):
|
|||
a temp or permanent save.
|
||||
:param \*files: file paths (str) to be registered
|
||||
|
||||
:raises letsencrypt.errors.LetsEncryptReverterError: If
|
||||
:raises letsencrypt.errors.ReverterError: If
|
||||
call does not contain necessary parameters or if the file creation
|
||||
is unable to be registered.
|
||||
|
||||
|
|
@ -300,7 +300,7 @@ class Reverter(object):
|
|||
# Make sure some files are provided... as this is an error
|
||||
# Made this mistake in my initial implementation of apache.dvsni.py
|
||||
if not files:
|
||||
raise errors.LetsEncryptReverterError(
|
||||
raise errors.ReverterError(
|
||||
"Forgot to provide files to registration call")
|
||||
|
||||
if temporary:
|
||||
|
|
@ -322,7 +322,7 @@ class Reverter(object):
|
|||
new_fd.write("{0}{1}".format(path, os.linesep))
|
||||
except (IOError, OSError):
|
||||
logging.error("Unable to register file creation(s) - %s", files)
|
||||
raise errors.LetsEncryptReverterError(
|
||||
raise errors.ReverterError(
|
||||
"Unable to register file creation(s) - {0}".format(files))
|
||||
finally:
|
||||
if new_fd is not None:
|
||||
|
|
@ -345,12 +345,12 @@ class Reverter(object):
|
|||
if os.path.isdir(self.config.in_progress_dir):
|
||||
try:
|
||||
self._recover_checkpoint(self.config.in_progress_dir)
|
||||
except errors.LetsEncryptReverterError:
|
||||
except errors.ReverterError:
|
||||
# We have a partial or incomplete recovery
|
||||
logging.fatal("Incomplete or failed recovery for IN_PROGRESS "
|
||||
"checkpoint - %s",
|
||||
self.config.in_progress_dir)
|
||||
raise errors.LetsEncryptReverterError(
|
||||
raise errors.ReverterError(
|
||||
"Incomplete or failed recovery for IN_PROGRESS checkpoint "
|
||||
"- %s" % self.config.in_progress_dir)
|
||||
|
||||
|
|
@ -362,7 +362,7 @@ class Reverter(object):
|
|||
:returns: Success
|
||||
:rtype: bool
|
||||
|
||||
:raises letsencrypt.errors.LetsEncryptReverterError: If
|
||||
:raises letsencrypt.errors.ReverterError: If
|
||||
all files within file_list cannot be removed
|
||||
|
||||
"""
|
||||
|
|
@ -386,7 +386,7 @@ class Reverter(object):
|
|||
except (IOError, OSError):
|
||||
logging.fatal(
|
||||
"Unable to remove filepaths contained within %s", file_list)
|
||||
raise errors.LetsEncryptReverterError(
|
||||
raise errors.ReverterError(
|
||||
"Unable to remove filepaths contained within "
|
||||
"{0}".format(file_list))
|
||||
|
||||
|
|
@ -400,7 +400,7 @@ class Reverter(object):
|
|||
|
||||
:param str title: Title describing checkpoint
|
||||
|
||||
:raises letsencrypt.errors.LetsEncryptReverterError: when the
|
||||
:raises letsencrypt.errors.ReverterError: when the
|
||||
checkpoint is not able to be finalized.
|
||||
|
||||
"""
|
||||
|
|
@ -426,7 +426,7 @@ class Reverter(object):
|
|||
shutil.move(changes_since_tmp_path, changes_since_path)
|
||||
except (IOError, OSError):
|
||||
logging.error("Unable to finalize checkpoint - adding title")
|
||||
raise errors.LetsEncryptReverterError("Unable to add title")
|
||||
raise errors.ReverterError("Unable to add title")
|
||||
|
||||
self._timestamp_progress_dir()
|
||||
|
||||
|
|
@ -451,5 +451,5 @@ class Reverter(object):
|
|||
logging.error(
|
||||
"Unable to finalize checkpoint, %s -> %s",
|
||||
self.config.in_progress_dir, final_dir)
|
||||
raise errors.LetsEncryptReverterError(
|
||||
raise errors.ReverterError(
|
||||
"Unable to finalize checkpoint renaming")
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class Revoker(object):
|
|||
authkey.pem).exportKey("PEM")
|
||||
# https://www.dlitz.net/software/pycrypto/api/current/Crypto.PublicKey.RSA-module.html
|
||||
except (IndexError, ValueError, TypeError):
|
||||
raise errors.LetsEncryptRevokerError(
|
||||
raise errors.RevokerError(
|
||||
"Invalid key file specified to revoke_from_key")
|
||||
|
||||
with open(self.list_path, "rb") as csvfile:
|
||||
|
|
@ -89,7 +89,7 @@ class Revoker(object):
|
|||
# This should never happen given the assumptions of the
|
||||
# module. If it does, it is probably best to delete the
|
||||
# the offending key/cert. For now... just raise an exception
|
||||
raise errors.LetsEncryptRevokerError(
|
||||
raise errors.RevokerError(
|
||||
"%s - backup file is corrupted.")
|
||||
|
||||
if clean_pem == test_pem:
|
||||
|
|
@ -218,7 +218,7 @@ class Revoker(object):
|
|||
if self.no_confirm or revocation.confirm_revocation(cert):
|
||||
try:
|
||||
self._acme_revoke(cert)
|
||||
except errors.LetsEncryptClientError:
|
||||
except errors.Error:
|
||||
# TODO: Improve error handling when networking is set...
|
||||
logging.error(
|
||||
"Unable to revoke cert:%s%s", os.linesep, str(cert))
|
||||
|
|
@ -250,7 +250,7 @@ class Revoker(object):
|
|||
|
||||
# If the key file doesn't exist... or is corrupted
|
||||
except (IndexError, ValueError, TypeError):
|
||||
raise errors.LetsEncryptRevokerError(
|
||||
raise errors.RevokerError(
|
||||
"Corrupted backup key file: %s" % cert.backup_key_path)
|
||||
|
||||
return self.network.revoke(cert=None) # XXX
|
||||
|
|
@ -293,7 +293,7 @@ class Revoker(object):
|
|||
|
||||
# This should never happen...
|
||||
if idx != len(cert_list):
|
||||
raise errors.LetsEncryptRevokerError(
|
||||
raise errors.RevokerError(
|
||||
"Did not find all cert_list items to remove from LIST")
|
||||
|
||||
shutil.copy2(list_path2, self.list_path)
|
||||
|
|
@ -398,7 +398,7 @@ class Cert(object):
|
|||
try:
|
||||
self._cert = M2Crypto.X509.load_cert(cert_path)
|
||||
except (IOError, M2Crypto.X509.X509Error):
|
||||
raise errors.LetsEncryptRevokerError(
|
||||
raise errors.RevokerError(
|
||||
"Error loading certificate: %s" % cert_path)
|
||||
|
||||
self.idx = -1
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class AccountTest(unittest.TestCase):
|
|||
def test_prompts_bad_email(self, mock_from_email, mock_util):
|
||||
from letsencrypt.account import Account
|
||||
|
||||
mock_from_email.side_effect = (errors.LetsEncryptClientError, "acc")
|
||||
mock_from_email.side_effect = (errors.Error, "acc")
|
||||
mock_util().input.return_value = (display_util.OK, self.email)
|
||||
|
||||
self.assertEqual(Account.from_prompts(self.config), "acc")
|
||||
|
|
@ -102,7 +102,7 @@ class AccountTest(unittest.TestCase):
|
|||
def test_from_email(self):
|
||||
from letsencrypt.account import Account
|
||||
|
||||
self.assertRaises(errors.LetsEncryptClientError,
|
||||
self.assertRaises(errors.Error,
|
||||
Account.from_email, self.config, "not_valid...email")
|
||||
|
||||
def test_save_from_existing_account(self):
|
||||
|
|
@ -171,7 +171,7 @@ class AccountTest(unittest.TestCase):
|
|||
from letsencrypt.account import Account
|
||||
|
||||
self.assertRaises(
|
||||
errors.LetsEncryptClientError,
|
||||
errors.Error,
|
||||
Account.from_existing_account,
|
||||
self.config, "non-existant@email.org")
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class ChallengeFactoryTest(unittest.TestCase):
|
|||
[mock.Mock(chall="chall", typ="unrecognized")],
|
||||
[messages.STATUS_PENDING])
|
||||
|
||||
self.assertRaises(errors.LetsEncryptClientError,
|
||||
self.assertRaises(errors.Error,
|
||||
self.handler._challenge_factory, "failure.com", [0])
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class PerformTest(unittest.TestCase):
|
|||
|
||||
def test_unexpected(self):
|
||||
self.assertRaises(
|
||||
errors.LetsEncryptContAuthError, self.auth.perform, [
|
||||
errors.ContAuthError, self.auth.perform, [
|
||||
achallenges.DVSNI(challb=None, domain="0", key="invalid_key")])
|
||||
|
||||
def test_chall_pref(self):
|
||||
|
|
@ -91,7 +91,7 @@ class CleanupTest(unittest.TestCase):
|
|||
token = achallenges.RecoveryToken(challb=None, domain="0")
|
||||
unexpected = achallenges.DVSNI(challb=None, domain="0", key="dummy_key")
|
||||
|
||||
self.assertRaises(errors.LetsEncryptContAuthError,
|
||||
self.assertRaises(errors.ContAuthError,
|
||||
self.auth.cleanup, [token, unexpected])
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class AskTest(unittest.TestCase):
|
|||
|
||||
def test_key_error(self):
|
||||
self.assertRaises(
|
||||
errors.LetsEncryptClientError, self._call, "unknown_enhancement")
|
||||
errors.Error, self._call, "unknown_enhancement")
|
||||
|
||||
|
||||
class RedirectTest(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class MakeOrVerifyDirTest(unittest.TestCase):
|
|||
|
||||
def test_existing_wrong_mode_fails(self):
|
||||
self.assertRaises(
|
||||
errors.LetsEncryptClientError, self._call, self.path, 0o600)
|
||||
errors.Error, self._call, self.path, 0o600)
|
||||
|
||||
def test_reraises_os_error(self):
|
||||
with mock.patch.object(os, 'makedirs') as makedirs:
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class ReverterCheckpointLocalTest(unittest.TestCase):
|
|||
def test_add_to_checkpoint_copy_failure(self):
|
||||
with mock.patch("letsencrypt.reverter.shutil.copy2") as mock_copy2:
|
||||
mock_copy2.side_effect = IOError("bad copy")
|
||||
self.assertRaises(errors.LetsEncryptReverterError,
|
||||
self.assertRaises(errors.ReverterError,
|
||||
self.reverter.add_to_checkpoint,
|
||||
self.sets[0],
|
||||
"save1")
|
||||
|
|
@ -66,14 +66,14 @@ class ReverterCheckpointLocalTest(unittest.TestCase):
|
|||
self.reverter.add_to_temp_checkpoint(self.sets[0], "save2")
|
||||
# Raise error
|
||||
self.assertRaises(
|
||||
errors.LetsEncryptReverterError, self.reverter.add_to_checkpoint,
|
||||
errors.ReverterError, self.reverter.add_to_checkpoint,
|
||||
self.sets[2], "save3")
|
||||
# Should not cause an error
|
||||
self.reverter.add_to_checkpoint(self.sets[1], "save4")
|
||||
|
||||
# Check to make sure new files are also checked...
|
||||
self.assertRaises(
|
||||
errors.LetsEncryptReverterError,
|
||||
errors.ReverterError,
|
||||
self.reverter.add_to_checkpoint,
|
||||
set([config3]), "invalid save")
|
||||
|
||||
|
|
@ -120,13 +120,13 @@ class ReverterCheckpointLocalTest(unittest.TestCase):
|
|||
m_open = mock.mock_open()
|
||||
with mock.patch("letsencrypt.reverter.open", m_open, create=True):
|
||||
m_open.side_effect = OSError("bad open")
|
||||
self.assertRaises(errors.LetsEncryptReverterError,
|
||||
self.assertRaises(errors.ReverterError,
|
||||
self.reverter.register_file_creation,
|
||||
True, self.config1)
|
||||
|
||||
def test_bad_registration(self):
|
||||
# Made this mistake and want to make sure it doesn't happen again...
|
||||
self.assertRaises(errors.LetsEncryptReverterError,
|
||||
self.assertRaises(errors.ReverterError,
|
||||
self.reverter.register_file_creation,
|
||||
"filepath")
|
||||
|
||||
|
|
@ -135,33 +135,33 @@ class ReverterCheckpointLocalTest(unittest.TestCase):
|
|||
|
||||
# pylint: disable=protected-access
|
||||
self.reverter._recover_checkpoint = mock.MagicMock(
|
||||
side_effect=errors.LetsEncryptReverterError)
|
||||
self.assertRaises(errors.LetsEncryptReverterError,
|
||||
side_effect=errors.ReverterError)
|
||||
self.assertRaises(errors.ReverterError,
|
||||
self.reverter.recovery_routine)
|
||||
|
||||
def test_recover_checkpoint_revert_temp_failures(self):
|
||||
# pylint: disable=invalid-name
|
||||
mock_recover = mock.MagicMock(
|
||||
side_effect=errors.LetsEncryptReverterError("e"))
|
||||
side_effect=errors.ReverterError("e"))
|
||||
|
||||
# pylint: disable=protected-access
|
||||
self.reverter._recover_checkpoint = mock_recover
|
||||
|
||||
self.reverter.add_to_temp_checkpoint(self.sets[0], "config1 save")
|
||||
|
||||
self.assertRaises(errors.LetsEncryptReverterError,
|
||||
self.assertRaises(errors.ReverterError,
|
||||
self.reverter.revert_temporary_config)
|
||||
|
||||
def test_recover_checkpoint_rollback_failure(self):
|
||||
mock_recover = mock.MagicMock(
|
||||
side_effect=errors.LetsEncryptReverterError("e"))
|
||||
side_effect=errors.ReverterError("e"))
|
||||
# pylint: disable=protected-access
|
||||
self.reverter._recover_checkpoint = mock_recover
|
||||
|
||||
self.reverter.add_to_checkpoint(self.sets[0], "config1 save")
|
||||
self.reverter.finalize_checkpoint("Title")
|
||||
|
||||
self.assertRaises(errors.LetsEncryptReverterError,
|
||||
self.assertRaises(errors.ReverterError,
|
||||
self.reverter.rollback_checkpoints, 1)
|
||||
|
||||
def test_recover_checkpoint_copy_failure(self):
|
||||
|
|
@ -169,7 +169,7 @@ class ReverterCheckpointLocalTest(unittest.TestCase):
|
|||
|
||||
with mock.patch("letsencrypt.reverter.shutil.copy2") as mock_copy2:
|
||||
mock_copy2.side_effect = OSError("bad copy")
|
||||
self.assertRaises(errors.LetsEncryptReverterError,
|
||||
self.assertRaises(errors.ReverterError,
|
||||
self.reverter.revert_temporary_config)
|
||||
|
||||
def test_recover_checkpoint_rm_failure(self):
|
||||
|
|
@ -177,7 +177,7 @@ class ReverterCheckpointLocalTest(unittest.TestCase):
|
|||
|
||||
with mock.patch("letsencrypt.reverter.shutil.rmtree") as mock_rmtree:
|
||||
mock_rmtree.side_effect = OSError("Cannot remove tree")
|
||||
self.assertRaises(errors.LetsEncryptReverterError,
|
||||
self.assertRaises(errors.ReverterError,
|
||||
self.reverter.revert_temporary_config)
|
||||
|
||||
@mock.patch("letsencrypt.reverter.logging.warning")
|
||||
|
|
@ -191,7 +191,7 @@ class ReverterCheckpointLocalTest(unittest.TestCase):
|
|||
def test_recover_checkpoint_remove_failure(self, mock_remove):
|
||||
self.reverter.register_file_creation(True, self.config1)
|
||||
mock_remove.side_effect = OSError("Can't remove")
|
||||
self.assertRaises(errors.LetsEncryptReverterError,
|
||||
self.assertRaises(errors.ReverterError,
|
||||
self.reverter.revert_temporary_config)
|
||||
|
||||
def test_recovery_routine_temp_and_perm(self):
|
||||
|
|
@ -251,13 +251,13 @@ class TestFullCheckpointsReverter(unittest.TestCase):
|
|||
|
||||
def test_rollback_improper_inputs(self):
|
||||
self.assertRaises(
|
||||
errors.LetsEncryptReverterError,
|
||||
errors.ReverterError,
|
||||
self.reverter.rollback_checkpoints, "-1")
|
||||
self.assertRaises(
|
||||
errors.LetsEncryptReverterError,
|
||||
errors.ReverterError,
|
||||
self.reverter.rollback_checkpoints, -1000)
|
||||
self.assertRaises(
|
||||
errors.LetsEncryptReverterError,
|
||||
errors.ReverterError,
|
||||
self.reverter.rollback_checkpoints, "one")
|
||||
|
||||
def test_rollback_finalize_checkpoint_valid_inputs(self):
|
||||
|
|
@ -299,7 +299,7 @@ class TestFullCheckpointsReverter(unittest.TestCase):
|
|||
self.reverter.add_to_checkpoint(self.sets[0], "perm save")
|
||||
mock_move.side_effect = OSError("cannot move")
|
||||
|
||||
self.assertRaises(errors.LetsEncryptReverterError,
|
||||
self.assertRaises(errors.ReverterError,
|
||||
self.reverter.finalize_checkpoint,
|
||||
"Title")
|
||||
|
||||
|
|
@ -309,7 +309,7 @@ class TestFullCheckpointsReverter(unittest.TestCase):
|
|||
self.reverter.add_to_checkpoint(self.sets[0], "perm save")
|
||||
mock_rename.side_effect = OSError
|
||||
|
||||
self.assertRaises(errors.LetsEncryptReverterError,
|
||||
self.assertRaises(errors.ReverterError,
|
||||
self.reverter.finalize_checkpoint,
|
||||
"Title")
|
||||
|
||||
|
|
@ -347,7 +347,7 @@ class TestFullCheckpointsReverter(unittest.TestCase):
|
|||
# It must just be clean checkpoints
|
||||
os.makedirs(os.path.join(self.config.backup_dir, "in_progress"))
|
||||
|
||||
self.assertRaises(errors.LetsEncryptReverterError,
|
||||
self.assertRaises(errors.ReverterError,
|
||||
self.reverter.view_config_changes)
|
||||
|
||||
def _setup_three_checkpoints(self):
|
||||
|
|
|
|||
|
|
@ -80,12 +80,12 @@ class RevokerTest(RevokerBase):
|
|||
@mock.patch("letsencrypt.revoker.Crypto.PublicKey.RSA.importKey")
|
||||
def test_revoke_by_invalid_keys(self, mock_import):
|
||||
mock_import.side_effect = ValueError
|
||||
self.assertRaises(errors.LetsEncryptRevokerError,
|
||||
self.assertRaises(errors.RevokerError,
|
||||
self.revoker.revoke_from_key,
|
||||
self.key)
|
||||
|
||||
mock_import.side_effect = [mock.Mock(), IndexError]
|
||||
self.assertRaises(errors.LetsEncryptRevokerError,
|
||||
self.assertRaises(errors.RevokerError,
|
||||
self.revoker.revoke_from_key,
|
||||
self.key)
|
||||
|
||||
|
|
@ -188,7 +188,7 @@ class RevokerTest(RevokerBase):
|
|||
@mock.patch("letsencrypt.revoker.logging")
|
||||
def test_safe_revoke_acme_fail(self, mock_log, mock_revoke, mock_display):
|
||||
# pylint: disable=protected-access
|
||||
mock_revoke.side_effect = errors.LetsEncryptClientError
|
||||
mock_revoke.side_effect = errors.Error
|
||||
mock_display().confirm_revocation.return_value = True
|
||||
|
||||
self.revoker._safe_revoke(self.certs)
|
||||
|
|
@ -198,7 +198,7 @@ class RevokerTest(RevokerBase):
|
|||
def test_acme_revoke_failure(self, mock_crypto):
|
||||
# pylint: disable=protected-access
|
||||
mock_crypto.side_effect = ValueError
|
||||
self.assertRaises(errors.LetsEncryptClientError,
|
||||
self.assertRaises(errors.Error,
|
||||
self.revoker._acme_revoke,
|
||||
self.certs[0])
|
||||
|
||||
|
|
@ -215,7 +215,7 @@ class RevokerTest(RevokerBase):
|
|||
new_cert.orig = Cert.PathStatus("false path", "not here")
|
||||
new_cert.orig_key = Cert.PathStatus("false path", "not here")
|
||||
|
||||
self.assertRaises(errors.LetsEncryptRevokerError,
|
||||
self.assertRaises(errors.RevokerError,
|
||||
self.revoker._remove_certs_from_list,
|
||||
[new_cert])
|
||||
|
||||
|
|
@ -330,7 +330,7 @@ class CertTest(unittest.TestCase):
|
|||
|
||||
def test_failed_load(self):
|
||||
from letsencrypt.revoker import Cert
|
||||
self.assertRaises(errors.LetsEncryptRevokerError, Cert, self.key_path)
|
||||
self.assertRaises(errors.RevokerError, Cert, self.key_path)
|
||||
|
||||
def test_no_row(self):
|
||||
self.assertEqual(self.certs[0].get_row(), None)
|
||||
|
|
|
|||
|
|
@ -554,9 +554,9 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||
return self._enhance_func[enhancement](
|
||||
self.choose_vhost(domain), options)
|
||||
except ValueError:
|
||||
raise errors.LetsEncryptConfiguratorError(
|
||||
raise errors.ConfiguratorError(
|
||||
"Unsupported enhancement: {}".format(enhancement))
|
||||
except errors.LetsEncryptConfiguratorError:
|
||||
except errors.ConfiguratorError:
|
||||
logging.warn("Failed %s for %s", enhancement, domain)
|
||||
|
||||
def _enable_redirect(self, ssl_vhost, unused_options):
|
||||
|
|
@ -602,7 +602,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||
return
|
||||
else:
|
||||
logging.info("Unknown redirect exists for this vhost")
|
||||
raise errors.LetsEncryptConfiguratorError(
|
||||
raise errors.ConfiguratorError(
|
||||
"Unknown redirect already exists "
|
||||
"in {}".format(general_v.filep))
|
||||
# Add directives to server
|
||||
|
|
@ -673,7 +673,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||
# Make sure adding the vhost will be safe
|
||||
conflict, host_or_addrs = self._conflicting_host(ssl_vhost)
|
||||
if conflict:
|
||||
raise errors.LetsEncryptConfiguratorError(
|
||||
raise errors.ConfiguratorError(
|
||||
"Unable to create a redirection vhost "
|
||||
"- {}".format(host_or_addrs))
|
||||
|
||||
|
|
@ -951,7 +951,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||
:returns: version
|
||||
:rtype: tuple
|
||||
|
||||
:raises errors.LetsEncryptConfiguratorError:
|
||||
:raises errors.ConfiguratorError:
|
||||
Unable to find Apache version
|
||||
|
||||
"""
|
||||
|
|
@ -962,14 +962,14 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||
stderr=subprocess.PIPE)
|
||||
text = proc.communicate()[0]
|
||||
except (OSError, ValueError):
|
||||
raise errors.LetsEncryptConfiguratorError(
|
||||
raise errors.ConfiguratorError(
|
||||
"Unable to run %s -v" % self.conf('ctl'))
|
||||
|
||||
regex = re.compile(r"Apache/([0-9\.]*)", re.IGNORECASE)
|
||||
matches = regex.findall(text)
|
||||
|
||||
if len(matches) != 1:
|
||||
raise errors.LetsEncryptConfiguratorError(
|
||||
raise errors.ConfiguratorError(
|
||||
"Unable to find Apache version")
|
||||
|
||||
return tuple([int(i) for i in matches[0].split(".")])
|
||||
|
|
@ -1079,12 +1079,12 @@ def mod_loaded(module, apache_ctl):
|
|||
except (OSError, ValueError):
|
||||
logging.error(
|
||||
"Error accessing %s for loaded modules!", apache_ctl)
|
||||
raise errors.LetsEncryptConfiguratorError(
|
||||
raise errors.ConfiguratorError(
|
||||
"Error accessing loaded modules")
|
||||
# Small errors that do not impede
|
||||
if proc.returncode != 0:
|
||||
logging.warn("Error in checking loaded module list: %s", stderr)
|
||||
raise errors.LetsEncryptMisconfigurationError(
|
||||
raise errors.MisconfigurationError(
|
||||
"Apache is unable to check whether or not the module is "
|
||||
"loaded because Apache is misconfigured.")
|
||||
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ class ApacheParser(object):
|
|||
if os.path.isfile(os.path.join(self.root, name)):
|
||||
return os.path.join(self.root, name)
|
||||
|
||||
raise errors.LetsEncryptNoInstallationError(
|
||||
raise errors.NoInstallationError(
|
||||
"Could not find configuration root")
|
||||
|
||||
def _set_user_config_file(self, root):
|
||||
|
|
|
|||
|
|
@ -198,16 +198,16 @@ class TwoVhost80Test(util.ApacheTest):
|
|||
mock_popen().communicate.return_value = (
|
||||
"Server Version: Apache (Debian)", "")
|
||||
self.assertRaises(
|
||||
errors.LetsEncryptConfiguratorError, self.config.get_version)
|
||||
errors.ConfiguratorError, self.config.get_version)
|
||||
|
||||
mock_popen().communicate.return_value = (
|
||||
"Server Version: Apache/2.3{0} Apache/2.4.7".format(os.linesep), "")
|
||||
self.assertRaises(
|
||||
errors.LetsEncryptConfiguratorError, self.config.get_version)
|
||||
errors.ConfiguratorError, self.config.get_version)
|
||||
|
||||
mock_popen.side_effect = OSError("Can't find program")
|
||||
self.assertRaises(
|
||||
errors.LetsEncryptConfiguratorError, self.config.get_version)
|
||||
errors.ConfiguratorError, self.config.get_version)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ class ApacheParserTest(util.ApacheTest):
|
|||
mock_path.isfile.return_value = False
|
||||
|
||||
# pylint: disable=protected-access
|
||||
self.assertRaises(errors.LetsEncryptConfiguratorError,
|
||||
self.assertRaises(errors.ConfiguratorError,
|
||||
self.parser._set_locations, self.ssl_options)
|
||||
|
||||
mock_path.isfile.side_effect = [True, False, False]
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class NginxConfigurator(common.Plugin):
|
|||
directives, True)
|
||||
logging.info("Deployed Certificate to VirtualHost %s for %s",
|
||||
vhost.filep, vhost.names)
|
||||
except errors.LetsEncryptMisconfigurationError:
|
||||
except errors.MisconfigurationError:
|
||||
logging.warn(
|
||||
"Cannot find a cert or key directive in %s for %s. "
|
||||
"VirtualHost was not modified.", vhost.filep, vhost.names)
|
||||
|
|
@ -315,9 +315,9 @@ class NginxConfigurator(common.Plugin):
|
|||
return self._enhance_func[enhancement](
|
||||
self.choose_vhost(domain), options)
|
||||
except (KeyError, ValueError):
|
||||
raise errors.LetsEncryptConfiguratorError(
|
||||
raise errors.ConfiguratorError(
|
||||
"Unsupported enhancement: {0}".format(enhancement))
|
||||
except errors.LetsEncryptConfiguratorError:
|
||||
except errors.ConfiguratorError:
|
||||
logging.warn("Failed %s for %s", enhancement, domain)
|
||||
|
||||
######################################
|
||||
|
|
@ -380,7 +380,7 @@ class NginxConfigurator(common.Plugin):
|
|||
:returns: version
|
||||
:rtype: tuple
|
||||
|
||||
:raises errors.LetsEncryptConfiguratorError:
|
||||
:raises errors.ConfiguratorError:
|
||||
Unable to find Nginx version or version is unsupported
|
||||
|
||||
"""
|
||||
|
|
@ -391,7 +391,7 @@ class NginxConfigurator(common.Plugin):
|
|||
stderr=subprocess.PIPE)
|
||||
text = proc.communicate()[1] # nginx prints output to stderr
|
||||
except (OSError, ValueError):
|
||||
raise errors.LetsEncryptConfiguratorError(
|
||||
raise errors.ConfiguratorError(
|
||||
"Unable to run %s -V" % self.conf('ctl'))
|
||||
|
||||
version_regex = re.compile(r"nginx/([0-9\.]*)", re.IGNORECASE)
|
||||
|
|
@ -404,13 +404,13 @@ class NginxConfigurator(common.Plugin):
|
|||
ssl_matches = ssl_regex.findall(text)
|
||||
|
||||
if not version_matches:
|
||||
raise errors.LetsEncryptConfiguratorError(
|
||||
raise errors.ConfiguratorError(
|
||||
"Unable to find Nginx version")
|
||||
if not ssl_matches:
|
||||
raise errors.LetsEncryptConfiguratorError(
|
||||
raise errors.ConfiguratorError(
|
||||
"Nginx build is missing SSL module (--with-http_ssl_module).")
|
||||
if not sni_matches:
|
||||
raise errors.LetsEncryptConfiguratorError(
|
||||
raise errors.ConfiguratorError(
|
||||
"Nginx build doesn't support SNI")
|
||||
|
||||
nginx_version = tuple([int(i) for i in version_matches[0].split(".")])
|
||||
|
|
@ -418,7 +418,7 @@ class NginxConfigurator(common.Plugin):
|
|||
# nginx < 0.8.48 uses machine hostname as default server_name instead of
|
||||
# the empty string
|
||||
if nginx_version < (0, 8, 48):
|
||||
raise errors.LetsEncryptConfiguratorError(
|
||||
raise errors.ConfiguratorError(
|
||||
"Nginx version must be 0.8.48+")
|
||||
|
||||
return nginx_version
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class NginxDvsni(common.Dvsni):
|
|||
:param list ll_addrs: list of lists of
|
||||
:class:`letsencrypt_nginx.obj.Addr` to apply
|
||||
|
||||
:raises errors.LetsEncryptMisconfigurationError:
|
||||
:raises errors.MisconfigurationError:
|
||||
Unable to find a suitable HTTP block to include DVSNI hosts.
|
||||
|
||||
"""
|
||||
|
|
@ -97,7 +97,7 @@ class NginxDvsni(common.Dvsni):
|
|||
included = True
|
||||
break
|
||||
if not included:
|
||||
raise errors.LetsEncryptMisconfigurationError(
|
||||
raise errors.MisconfigurationError(
|
||||
'LetsEncrypt could not find an HTTP block to include DVSNI '
|
||||
'challenges in %s.' % root)
|
||||
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ class NginxParser(object):
|
|||
if os.path.isfile(os.path.join(self.root, name)):
|
||||
return os.path.join(self.root, name)
|
||||
|
||||
raise errors.LetsEncryptNoInstallationError(
|
||||
raise errors.NoInstallationError(
|
||||
"Could not find configuration root")
|
||||
|
||||
def filedump(self, ext='tmp'):
|
||||
|
|
@ -486,7 +486,7 @@ def _add_directives(block, directives, replace=False):
|
|||
block[index] = directive
|
||||
changed = True
|
||||
if not changed:
|
||||
raise errors.LetsEncryptMisconfigurationError(
|
||||
raise errors.MisconfigurationError(
|
||||
'LetsEncrypt expected directive for %s in the Nginx '
|
||||
'config but did not find it.' % directive[0])
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class NginxConfiguratorTest(util.NginxTest):
|
|||
self.assertEqual([], self.config.supported_enhancements())
|
||||
|
||||
def test_enhance(self):
|
||||
self.assertRaises(errors.LetsEncryptConfiguratorError,
|
||||
self.assertRaises(errors.ConfiguratorError,
|
||||
self.config.enhance,
|
||||
'myhost',
|
||||
'redirect')
|
||||
|
|
@ -218,13 +218,13 @@ class NginxConfiguratorTest(util.NginxTest):
|
|||
" (based on LLVM 3.5svn)",
|
||||
"TLS SNI support enabled",
|
||||
"configure arguments: --with-http_ssl_module"]))
|
||||
self.assertRaises(errors.LetsEncryptConfiguratorError,
|
||||
self.assertRaises(errors.ConfiguratorError,
|
||||
self.config.get_version)
|
||||
|
||||
mock_popen().communicate.return_value = (
|
||||
"", "\n".join(["nginx version: nginx/1.4.2",
|
||||
"TLS SNI support enabled"]))
|
||||
self.assertRaises(errors.LetsEncryptConfiguratorError,
|
||||
self.assertRaises(errors.ConfiguratorError,
|
||||
self.config.get_version)
|
||||
|
||||
mock_popen().communicate.return_value = (
|
||||
|
|
@ -232,7 +232,7 @@ class NginxConfiguratorTest(util.NginxTest):
|
|||
"built by clang 6.0 (clang-600.0.56)"
|
||||
" (based on LLVM 3.5svn)",
|
||||
"configure arguments: --with-http_ssl_module"]))
|
||||
self.assertRaises(errors.LetsEncryptConfiguratorError,
|
||||
self.assertRaises(errors.ConfiguratorError,
|
||||
self.config.get_version)
|
||||
|
||||
mock_popen().communicate.return_value = (
|
||||
|
|
@ -241,12 +241,12 @@ class NginxConfiguratorTest(util.NginxTest):
|
|||
" (based on LLVM 3.5svn)",
|
||||
"TLS SNI support enabled",
|
||||
"configure arguments: --with-http_ssl_module"]))
|
||||
self.assertRaises(errors.LetsEncryptConfiguratorError,
|
||||
self.assertRaises(errors.ConfiguratorError,
|
||||
self.config.get_version)
|
||||
|
||||
mock_popen.side_effect = OSError("Can't find program")
|
||||
self.assertRaises(
|
||||
errors.LetsEncryptConfiguratorError, self.config.get_version)
|
||||
errors.ConfiguratorError, self.config.get_version)
|
||||
|
||||
@mock.patch("letsencrypt_nginx.configurator.subprocess.Popen")
|
||||
def test_nginx_restart(self, mock_popen):
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ class DvsniPerformTest(util.NginxTest):
|
|||
root = self.sni.configurator.parser.loc["root"]
|
||||
self.sni.configurator.parser.parsed[root] = [['include', 'foo.conf']]
|
||||
# pylint: disable=protected-access
|
||||
self.assertRaises(errors.LetsEncryptMisconfigurationError,
|
||||
self.assertRaises(errors.MisconfigurationError,
|
||||
self.sni._mod_config, [])
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import re
|
|||
import shutil
|
||||
import unittest
|
||||
|
||||
from letsencrypt.errors import LetsEncryptMisconfigurationError
|
||||
from letsencrypt import errors
|
||||
|
||||
from letsencrypt_nginx import nginxparser
|
||||
from letsencrypt_nginx import obj
|
||||
|
|
@ -163,7 +163,7 @@ class NginxParserTest(util.NginxTest):
|
|||
['listen', '127.0.0.1'],
|
||||
['server_name', 'foo bar'],
|
||||
['server_name', 'foo bar']]]])
|
||||
self.assertRaises(LetsEncryptMisconfigurationError,
|
||||
self.assertRaises(errors.MisconfigurationError,
|
||||
nparser.add_server_directives,
|
||||
filep, set(['foo', 'bar']),
|
||||
[['ssl_certificate', 'cert.pem']], True)
|
||||
|
|
|
|||
Loading…
Reference in a new issue