X-Git-Url: http://www.git.cypherpunks.ru/?p=pyderasn.git;a=blobdiff_plain;f=tests%2Ftest_pyderasn.py;h=f2e73b4202a0a626f762e71b94b54f94f9548aff;hp=630aeadc6a605402e967b2daf5ffe091da7b03db;hb=8cc4587b4ebd0a488db45dfdf51ce8ebbf562e0b;hpb=58f8218f3a0a7bc77ba5cc7f2696fb214559d3c7 diff --git a/tests/test_pyderasn.py b/tests/test_pyderasn.py index 630aead..f2e73b4 100644 --- a/tests/test_pyderasn.py +++ b/tests/test_pyderasn.py @@ -4054,6 +4054,35 @@ class TestGeneralizedTime(TimeMixin, CommonMixin, TestCase): with assertRaisesRegex(self, DecodeError, "only microsecond fractions"): GeneralizedTime(b"20010101000000.0000001Z") + def test_non_pure_integers(self): + for data in (( + # b"20000102030405Z, + b"+2000102030405Z", + b"2000+102030405Z", + b"200001+2030405Z", + b"20000102+30405Z", + b"2000010203+405Z", + b"200001020304+5Z", + b"20000102030405.+6Z", + b"20000102030405.-6Z", + b" 2000102030405Z", + b"2000 102030405Z", + b"200001 2030405Z", + b"20000102 30405Z", + b"2000010203 405Z", + b"200001020304 5Z", + b"20000102030405. 6Z", + b"200 0102030405Z", + b"20001 02030405Z", + b"2000012 030405Z", + b"200001023 0405Z", + b"20000102034 05Z", + b"2000010203045 Z", + b"20000102030405.6 Z", + )): + with self.assertRaises(DecodeError): + GeneralizedTime(data) + class TestUTCTime(TimeMixin, CommonMixin, TestCase): base_klass = UTCTime @@ -4124,6 +4153,31 @@ class TestUTCTime(TimeMixin, CommonMixin, TestCase): datetime(1991, 5, 6, 23, 45, 40, 0), ) + def test_non_pure_integers(self): + for data in (( + # b"000102030405Z", + b"+10102030405Z", + b"00+102030405Z", + b"0001+2030405Z", + b"000102+30405Z", + b"00010203+405Z", + b"0001020304+5Z", + b" 10102030405Z", + b"00 102030405Z", + b"0001 2030405Z", + b"000102 30405Z", + b"00010203 405Z", + b"0001020304 5Z", + b"1 0102030405Z", + b"001 02030405Z", + b"00012 030405Z", + b"0001023 0405Z", + b"000102034 05Z", + b"00010203045 Z", + )): + with self.assertRaises(DecodeError): + UTCTime(data) + @given(integers(min_value=0, max_value=49)) def test_pre50(self, year): self.assertEqual(