1
0
mirror of https://github.com/certbot/certbot.git synced 2026-01-21 19:01:07 +03:00

Merge pull request #388 from kuba/acme

More readable message2.Error exceptions + small test.
This commit is contained in:
James Kasten
2015-05-05 12:38:52 -07:00
2 changed files with 14 additions and 0 deletions

View File

@@ -46,6 +46,11 @@ class Error(jose.JSONObjectWithFields, Exception):
"""Hardcoded error description based on its type."""
return self.ERROR_TYPE_DESCRIPTIONS[self.typ]
def __str__(self):
if self.typ is not None:
return ' :: '.join([self.typ, self.description, self.detail])
else:
return str(self.detail)
class _Constant(jose.JSONDeSerializable):
"""ACME constant."""

View File

@@ -50,6 +50,12 @@ class ErrorTest(unittest.TestCase):
from letsencrypt.acme.messages2 import Error
hash(Error.from_json(self.error.to_json()))
def test_str(self):
self.assertEqual(
'malformed :: The request message was malformed :: foo',
str(self.error))
self.assertEqual('foo', str(self.error.update(typ=None)))
class ConstantTest(unittest.TestCase):
"""Tests for letsencrypt.acme.messages2._Constant."""
@@ -163,6 +169,9 @@ class ChallengeBodyTest(unittest.TestCase):
from letsencrypt.acme.messages2 import ChallengeBody
hash(ChallengeBody.from_json(self.jobj_from))
def test_proxy(self):
self.assertEqual('foo', self.challb.token)
class AuthorizationTest(unittest.TestCase):
"""Tests for letsencrypt.acme.messages2.Authorization."""