#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
+# published by the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
pprint(obj, big_blobs=True, with_decode_path=True)
self.assertFalse(obj.expled)
obj_encoded = obj.encode()
+ self.additional_symmetric_check(value, obj_encoded)
obj_expled = obj(value, expl=tag_expl)
self.assertTrue(obj_expled.expled)
repr(obj_expled)
min_datetime = datetime(1900, 1, 1)
max_datetime = datetime(9999, 12, 31)
+ def additional_symmetric_check(self, value, obj_encoded):
+ if value.microsecond > 0:
+ self.assertFalse(obj_encoded.endswith(b"0Z"))
+
+ def test_x690_vector_valid(self):
+ for data in ((
+ b"19920521000000Z",
+ b"19920622123421Z",
+ b"19920722132100.3Z",
+ )):
+ GeneralizedTime(data)
+
+ def test_x690_vector_invalid(self):
+ for data in ((
+ b"19920520240000Z",
+ b"19920622123421.0Z",
+ b"19920722132100.30Z",
+ )):
+ with self.assertRaises(DecodeError) as err:
+ GeneralizedTime(data)
+ repr(err.exception)
+
def test_go_vectors_invalid(self):
for data in ((
b"20100102030405",
junk
)
+ def test_ns_fractions(self):
+ GeneralizedTime(b"20010101000000.000001Z")
+ with assertRaisesRegex(self, DecodeError, "only microsecond fractions"):
+ GeneralizedTime(b"20010101000000.0000001Z")
+
class TestUTCTime(TimeMixin, CommonMixin, TestCase):
base_klass = UTCTime
min_datetime = datetime(2000, 1, 1)
max_datetime = datetime(2049, 12, 31)
+ def additional_symmetric_check(self, value, obj_encoded):
+ pass
+
+ def test_x690_vector_valid(self):
+ for data in ((
+ b"920521000000Z",
+ b"920622123421Z",
+ b"920722132100Z",
+ )):
+ UTCTime(data)
+
+ def test_x690_vector_invalid(self):
+ for data in ((
+ b"920520240000Z",
+ b"9207221321Z",
+ )):
+ with self.assertRaises(DecodeError) as err:
+ UTCTime(data)
+ repr(err.exception)
+
def test_go_vectors_invalid(self):
for data in ((
b"a10506234540Z",
chosen_id = oids[chosen]
pp = _pp(asn1_type_name=ObjectIdentifier.asn1_type_name, value=chosen)
self.assertNotIn(chosen_id, pp_console_row(pp))
- self.assertIn(chosen_id, pp_console_row(pp, oids=oids))
+ self.assertIn(
+ chosen_id,
+ pp_console_row(pp, oid_maps=[{'whatever': 'whenever'}, oids]),
+ )
class TestAutoAddSlots(TestCase):