Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/certbot/certbot.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/acme
diff options
context:
space:
mode:
authorJacob Hoffman-Andrews <github@hoffman-andrews.com>2017-05-18 00:24:59 +0300
committerohemorange <ebportnoy@gmail.com>2017-05-18 00:24:59 +0300
commit10bac107ee6e7a565ce8bb60c1c6b37661012ed2 (patch)
treea70fc4a035d4f68237eccce8cf4f29599544658d /acme
parent686f5d6c81c3797e30c54c2bb34aa407121e8ca8 (diff)
Add an account deactivate utility script. (#4254)
* Add an account deactivate utility script. This is handy if you created an account with a tool other than Certbot, and want to deactivate the account. * Move deactivate.py to tools. * Add test for ConflictError. * Fix lint error. * Document how to set server.
Diffstat (limited to 'acme')
-rw-r--r--acme/acme/client.py3
-rw-r--r--acme/acme/client_test.py6
-rw-r--r--acme/acme/errors.py11
3 files changed, 20 insertions, 0 deletions
diff --git a/acme/acme/client.py b/acme/acme/client.py
index a069876d5..9455159de 100644
--- a/acme/acme/client.py
+++ b/acme/acme/client.py
@@ -564,6 +564,9 @@ class ClientNetwork(object): # pylint: disable=too-many-instance-attributes
except ValueError:
jobj = None
+ if response.status_code == 409:
+ raise errors.ConflictError(response.headers.get('Location'))
+
if not response.ok:
if jobj is not None:
if response_ct != cls.JSON_ERROR_CONTENT_TYPE:
diff --git a/acme/acme/client_test.py b/acme/acme/client_test.py
index 09bb38c00..cd1a90645 100644
--- a/acme/acme/client_test.py
+++ b/acme/acme/client_test.py
@@ -513,6 +513,12 @@ class ClientNetworkTest(unittest.TestCase):
self.assertEqual(
self.response, self.net._check_response(self.response))
+ def test_check_response_conflict(self):
+ self.response.ok = False
+ self.response.status_code = 409
+ # pylint: disable=protected-access
+ self.assertRaises(errors.ConflictError, self.net._check_response, self.response)
+
def test_check_response_jobj(self):
self.response.json.return_value = {}
for response_ct in [self.net.JSON_CONTENT_TYPE, 'foo']:
diff --git a/acme/acme/errors.py b/acme/acme/errors.py
index 7446b60fc..9d991fd75 100644
--- a/acme/acme/errors.py
+++ b/acme/acme/errors.py
@@ -82,3 +82,14 @@ class PollError(ClientError):
def __repr__(self):
return '{0}(exhausted={1!r}, updated={2!r})'.format(
self.__class__.__name__, self.exhausted, self.updated)
+
+class ConflictError(ClientError):
+ """Error for when the server returns a 409 (Conflict) HTTP status.
+
+ In the version of ACME implemented by Boulder, this is used to find an
+ account if you only have the private key, but don't know the account URL.
+ """
+ def __init__(self, location):
+ self.location = location
+ super(ConflictError, self).__init__()
+