UnrecognizedChallenge: fix tests and lint.

This commit is contained in:
Jakub Warmuz 2015-09-29 07:02:33 +00:00
parent ad1fce03f7
commit 0ffef20a20
No known key found for this signature in database
GPG key ID: 2A7BAD3A489B52EA
3 changed files with 28 additions and 18 deletions

View file

@ -64,9 +64,11 @@ class UnrecognizedChallenge(Challenge):
"""
def __init__(self, jobj):
super(UnrecognizedChallenge, self).__init__()
object.__setattr__(self, "jobj", jobj)
def to_partial_json(self):
# pylint: disable=no-member
return self.jobj
@classmethod

View file

@ -17,6 +17,32 @@ CERT = test_util.load_cert('cert.pem')
KEY = test_util.load_rsa_private_key('rsa512_key.pem')
class ChallengeTest(unittest.TestCase):
def test_from_json_unrecognized(self):
from acme.challenges import Challenge
from acme.challenges import UnrecognizedChallenge
chall = UnrecognizedChallenge({"type": "foo"})
# pylint: disable=no-member
self.assertEqual(chall, Challenge.from_json(chall.jobj))
class UnrecognizedChallengeTest(unittest.TestCase):
def setUp(self):
from acme.challenges import UnrecognizedChallenge
self.jobj = {"type": "foo"}
self.chall = UnrecognizedChallenge(self.jobj)
def test_to_partial_json(self):
self.assertEqual(self.jobj, self.chall.to_partial_json())
def test_from_json(self):
from acme.challenges import UnrecognizedChallenge
self.assertEqual(
self.chall, UnrecognizedChallenge.from_json(self.jobj))
class SimpleHTTPTest(unittest.TestCase):
def setUp(self):

View file

@ -301,19 +301,6 @@ class AuthorizationTest(unittest.TestCase):
'combinations': combinations,
}
# For unknown challenge types
self.jmsg_unknown_chall = {
'resource': 'challenge',
'uri': 'random_uri',
'type': 'unknown',
'tls': True,
}
self.jobj_from_unknown = {
'identifier': identifier.to_json(),
'challenges': [self.jmsg_unknown_chall],
}
def test_from_json(self):
from acme.messages import Authorization
Authorization.from_json(self.jobj_from)
@ -328,11 +315,6 @@ class AuthorizationTest(unittest.TestCase):
(self.challbs[1], self.challbs[2]),
))
def test_unknown_chall_type(self):
"""Just make sure an error isn't thrown."""
from acme.messages import Authorization
Authorization.from_json(self.jobj_from_unknown)
class AuthorizationResourceTest(unittest.TestCase):
"""Tests for acme.messages.AuthorizationResource."""