ChallengeBody __getattr__ proxy

This commit is contained in:
Jakub Warmuz
2015-04-14 13:06:14 +00:00
parent 458a61a177
commit 5298d8123d
3 changed files with 14 additions and 2 deletions
+6
View File
@@ -167,6 +167,9 @@ class ChallengeBody(ResourceBody):
such as ``challb`` to distinguish instanced of this class from
``achall``.
:ivar letsencrypt.acme.challenges.Challenge: Wrapped challenge.
Conveniently, all challenge fields are proxied, i.e. you can
call ``challb.x`` to get ``challb.chall.x`` contents.
:ivar letsencrypt.acme.messages2.Status status:
:ivar datetime.datetime validated:
@@ -187,6 +190,9 @@ class ChallengeBody(ResourceBody):
jobj_fields['chall'] = challenges.Challenge.from_json(jobj)
return jobj_fields
def __getattr__(self, name):
return getattr(self.chall, name)
class AuthorizationResource(Resource):
"""Authorization Resource.
+3
View File
@@ -103,6 +103,9 @@ class ChallengeBodyTest(unittest.TestCase):
from letsencrypt.acme.messages2 import ChallengeBody
self.assertEqual(self.challb, ChallengeBody.from_json(self.jobj_from))
def test_getattr_proxy(self):
self.assertEqual('foo', self.challb.token)
class AuthorizationTest(unittest.TestCase):
"""Tests for letsencrypt.acme.messages2.Authorization."""
+5 -2
View File
@@ -26,10 +26,13 @@ from letsencrypt.client import crypto_util
class AnnotatedChallenge(jose_util.ImmutableMap):
"""Client annotated challenge.
Wraps around :class:`~letsencrypt.acme.challenges.Challenge` and
annotates with data useful for the client.
Wraps around server provided challenge and annotates with data
useful for the client.
:ivar chall: Wrapped `~.ChallengeBody` (or just `~.challenges.Challenge`).
"""
__slots__ = ('chall',)
acme_type = NotImplemented
def __getattr__(self, name):