mirror of
https://github.com/certbot/certbot.git
synced 2026-08-02 00:22:28 +02:00
Merge pull request #2963 from certbot/ok-directory
Allow unrecognized fields in Directory object
This commit is contained in:
+1
-10
@@ -143,12 +143,6 @@ class Directory(jose.JSONDeSerializable):
|
|||||||
|
|
||||||
def __init__(self, jobj):
|
def __init__(self, jobj):
|
||||||
canon_jobj = util.map_keys(jobj, self._canon_key)
|
canon_jobj = util.map_keys(jobj, self._canon_key)
|
||||||
if not set(canon_jobj).issubset(
|
|
||||||
set(self._REGISTERED_TYPES).union(['meta'])):
|
|
||||||
# TODO: acme-spec is not clear about this: 'It is a JSON
|
|
||||||
# dictionary, whose keys are the "resource" values listed
|
|
||||||
# in {{https-requests}}'
|
|
||||||
raise ValueError('Wrong directory fields')
|
|
||||||
# TODO: check that everything is an absolute URL; acme-spec is
|
# TODO: check that everything is an absolute URL; acme-spec is
|
||||||
# not clear on that
|
# not clear on that
|
||||||
self._jobj = canon_jobj
|
self._jobj = canon_jobj
|
||||||
@@ -171,10 +165,7 @@ class Directory(jose.JSONDeSerializable):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, jobj):
|
def from_json(cls, jobj):
|
||||||
jobj['meta'] = cls.Meta.from_json(jobj.pop('meta', {}))
|
jobj['meta'] = cls.Meta.from_json(jobj.pop('meta', {}))
|
||||||
try:
|
return cls(jobj)
|
||||||
return cls(jobj)
|
|
||||||
except ValueError as error:
|
|
||||||
raise jose.DeserializationError(str(error))
|
|
||||||
|
|
||||||
|
|
||||||
class Resource(jose.JSONObjectWithFields):
|
class Resource(jose.JSONObjectWithFields):
|
||||||
|
|||||||
@@ -105,9 +105,9 @@ class DirectoryTest(unittest.TestCase):
|
|||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_init_wrong_key_value_error(self):
|
def test_init_wrong_key_value_success(self): # pylint: disable=no-self-use
|
||||||
from acme.messages import Directory
|
from acme.messages import Directory
|
||||||
self.assertRaises(ValueError, Directory, {'foo': 'bar'})
|
Directory({'foo': 'bar'})
|
||||||
|
|
||||||
def test_getitem(self):
|
def test_getitem(self):
|
||||||
self.assertEqual('reg', self.dir['new-reg'])
|
self.assertEqual('reg', self.dir['new-reg'])
|
||||||
@@ -135,10 +135,9 @@ class DirectoryTest(unittest.TestCase):
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
def test_from_json_deserialization_error_on_wrong_key(self):
|
def test_from_json_deserialization_unknown_key_success(self): # pylint: disable=no-self-use
|
||||||
from acme.messages import Directory
|
from acme.messages import Directory
|
||||||
self.assertRaises(
|
Directory.from_json({'foo': 'bar'})
|
||||||
jose.DeserializationError, Directory.from_json, {'foo': 'bar'})
|
|
||||||
|
|
||||||
|
|
||||||
class RegistrationTest(unittest.TestCase):
|
class RegistrationTest(unittest.TestCase):
|
||||||
|
|||||||
Reference in New Issue
Block a user