mirror of
https://github.com/certbot/certbot.git
synced 2026-01-21 19:01:07 +03:00
Fix some of #362 nitpicks
This commit is contained in:
@@ -164,8 +164,8 @@ class ChallengeBody(ResourceBody):
|
||||
|
||||
.. todo::
|
||||
Confusingly, this has a similar name to `.challenges.Challenge`,
|
||||
as well as `.achallenges.AnnotateChallenge`. Please use names
|
||||
such as ``challb`` to distinguish instanced of this class from
|
||||
as well as `.achallenges.AnnotatedChallenge`. Please use names
|
||||
such as ``challb`` to distinguish instances of this class from
|
||||
``achall``.
|
||||
|
||||
:ivar letsencrypt.acme.challenges.Challenge: Wrapped challenge.
|
||||
|
||||
@@ -55,6 +55,8 @@ class Account(object):
|
||||
"""URI link for new registrations."""
|
||||
if self.regr is not None:
|
||||
return self.regr.uri
|
||||
else:
|
||||
return None
|
||||
|
||||
@property
|
||||
def new_authzr_uri(self): # pylint: disable=missing-docstring
|
||||
@@ -65,16 +67,22 @@ class Account(object):
|
||||
# Default: spec says they "may" provide the header
|
||||
# ugh.. acme-spec #93
|
||||
return "https://%s/acme/new-authz" % self.config.server
|
||||
else:
|
||||
return None
|
||||
|
||||
@property
|
||||
def terms_of_service(self): # pylint: disable=missing-docstring
|
||||
if self.regr is not None:
|
||||
return self.regr.terms_of_service
|
||||
else:
|
||||
return None
|
||||
|
||||
@property
|
||||
def recovery_token(self): # pylint: disable=missing-docstring
|
||||
if self.regr is not None and self.regr.body is not None:
|
||||
return self.regr.body.recovery_token
|
||||
else:
|
||||
return None
|
||||
|
||||
def save(self):
|
||||
"""Save account to disk."""
|
||||
@@ -112,7 +120,6 @@ class Account(object):
|
||||
@classmethod
|
||||
def from_existing_account(cls, config, email=None):
|
||||
"""Populate an account from an existing email."""
|
||||
|
||||
config_fp = os.path.join(
|
||||
config.accounts_dir, cls._get_config_filename(email))
|
||||
return cls._from_config_fp(config, config_fp)
|
||||
|
||||
@@ -201,13 +201,10 @@ class Network(object):
|
||||
"""
|
||||
details = (
|
||||
"mailto:" + account.email if account.email is not None else None,
|
||||
"tel:" + account.phone if account.phone is not None else None
|
||||
"tel:" + account.phone if account.phone is not None else None,
|
||||
)
|
||||
|
||||
contact_tuple = tuple(det for det in details if det is not None)
|
||||
|
||||
account.regr = self.register(contact=contact_tuple)
|
||||
|
||||
account.regr = self.register(contact=tuple(
|
||||
det for det in details if det is not None))
|
||||
return account
|
||||
|
||||
def update_registration(self, regr):
|
||||
@@ -376,7 +373,6 @@ class Network(object):
|
||||
updated_authzr = self._authzr_from_response(
|
||||
response, authzr.body.identifier, authzr.uri, authzr.new_cert_uri)
|
||||
# TODO: check and raise UnexpectedUpdate
|
||||
|
||||
return updated_authzr, response
|
||||
|
||||
def request_issuance(self, csr, authzrs):
|
||||
@@ -534,6 +530,8 @@ class Network(object):
|
||||
"""
|
||||
if certr.cert_chain_uri is not None:
|
||||
return self._get_cert(certr.cert_chain_uri)[1]
|
||||
else:
|
||||
return None
|
||||
|
||||
def revoke(self, certr, when=messages2.Revocation.NOW):
|
||||
"""Revoke certificate.
|
||||
|
||||
@@ -169,7 +169,7 @@ class SafeEmailTest(unittest.TestCase):
|
||||
addrs = [
|
||||
"letsencrypt@letsencrypt.org",
|
||||
"tbd.ade@gmail.com",
|
||||
"abc_def.jdk@hotmail.museum"
|
||||
"abc_def.jdk@hotmail.museum",
|
||||
]
|
||||
for addr in addrs:
|
||||
self.assertTrue(self._call(addr), "%s failed." % addr)
|
||||
|
||||
@@ -75,7 +75,7 @@ def chall_to_challb(chall, status): # pylint: disable=redefined-outer-name
|
||||
"""Return ChallengeBody from Challenge."""
|
||||
kwargs = {
|
||||
"chall": chall,
|
||||
"uri": chall.typ+"_uri",
|
||||
"uri": chall.typ + "_uri",
|
||||
"status": status,
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ def gen_authzr(authz_status, domain, challs, statuses, combos=True):
|
||||
now = datetime.datetime.now()
|
||||
authz_kwargs.update({
|
||||
"status": authz_status,
|
||||
"expires": datetime.datetime(now.year, now.month+1, now.day),
|
||||
"expires": datetime.datetime(now.year, now.month + 1, now.day),
|
||||
})
|
||||
else:
|
||||
authz_kwargs.update({
|
||||
|
||||
@@ -7,10 +7,10 @@ import unittest
|
||||
import mock
|
||||
import zope.component
|
||||
|
||||
from letsencrypt.client import account
|
||||
from letsencrypt.client import le_util
|
||||
from letsencrypt.client.display import util as display_util
|
||||
|
||||
|
||||
class ChooseAuthenticatorTest(unittest.TestCase):
|
||||
"""Test choose_authenticator function."""
|
||||
def setUp(self):
|
||||
@@ -59,7 +59,6 @@ class ChooseAuthenticatorTest(unittest.TestCase):
|
||||
class ChooseAccountTest(unittest.TestCase):
|
||||
"""Test choose_account."""
|
||||
def setUp(self):
|
||||
from letsencrypt.client import account
|
||||
zope.component.provideUtility(display_util.FileDisplay(sys.stdout))
|
||||
|
||||
self.accounts_dir = tempfile.mkdtemp("accounts")
|
||||
|
||||
@@ -49,7 +49,8 @@ class RecoveryTokenTest(unittest.TestCase):
|
||||
# SHOULD throw an error (OSError other than nonexistent file)
|
||||
self.assertRaises(
|
||||
OSError, self.rec_token.cleanup,
|
||||
achallenges.RecoveryToken(challb=None, domain="a"+"r"*10000+".com"))
|
||||
achallenges.RecoveryToken(
|
||||
challb=None, domain=("a" + "r" * 10000 + ".com")))
|
||||
|
||||
def test_perform_stored(self):
|
||||
self.rec_token.store_token("example4.com", 444)
|
||||
|
||||
Reference in New Issue
Block a user