X-Git-Url: http://www.git.cypherpunks.ru/?p=pyderasn.git;a=blobdiff_plain;f=tests%2Ftest_pyderasn.py;h=73eea21c6151a8ac3979f103eb42c3b7632cf0b5;hp=8225fc02eaef4be07fc42093a3f28e4cbc88b933;hb=3eb38566e734d6f5b274f4bb99fadb55f99ff2c7;hpb=bba84f2f3b5fbc860f51cf76f2f504cb2aa8d899 diff --git a/tests/test_pyderasn.py b/tests/test_pyderasn.py index 8225fc0..73eea21 100644 --- a/tests/test_pyderasn.py +++ b/tests/test_pyderasn.py @@ -33,6 +33,7 @@ from time import mktime from time import time from unittest import TestCase +from dateutil.tz import UTC from hypothesis import assume from hypothesis import given from hypothesis import settings @@ -3081,6 +3082,10 @@ class TestObjectIdentifier(CommonMixin, TestCase): data, ))) + def test_go_non_minimal_encoding(self): + with self.assertRaises(DecodeError): + ObjectIdentifier().decode(hexdec("060a2a80864886f70d01010b")) + def test_x690_vector(self): self.assertEqual( ObjectIdentifier().decode(hexdec("0603883703"))[0], @@ -4494,8 +4499,13 @@ class TestGeneralizedTime(TimeMixin, CommonMixin, TestCase): mktime(obj.todatetime().timetuple()), mktime(dt.timetuple()), ) - elif not PY2: - self.assertEqual(obj.todatetime().timestamp(), dt.timestamp()) + else: + try: + obj.todatetime().timestamp() + except: + pass + else: + self.assertEqual(obj.todatetime().timestamp(), dt.timestamp()) self.assertEqual(obj.ber_encoded, not dered) self.assertEqual(obj.bered, not dered) self.assertEqual(obj.ber_raw, None if dered else data) @@ -4727,6 +4737,10 @@ class TestGeneralizedTime(TimeMixin, CommonMixin, TestCase): with self.assertRaises(DecodeError): GeneralizedTime(data) + def test_aware(self): + with assertRaisesRegex(self, ValueError, "only naive"): + GeneralizedTime(datetime(2000, 1, 1, 1, tzinfo=UTC)) + class TestUTCTime(TimeMixin, CommonMixin, TestCase): base_klass = UTCTime @@ -5060,6 +5074,10 @@ class TestUTCTime(TimeMixin, CommonMixin, TestCase): junk ) + def test_aware(self): + with assertRaisesRegex(self, ValueError, "only naive"): + UTCTime(datetime(2000, 1, 1, 1, tzinfo=UTC)) + @composite def tlv_value_strategy(draw):