diff options
author | Ilya Etingof <etingof@gmail.com> | 2017-09-13 15:55:06 +0200 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2017-09-13 15:55:06 +0200 |
commit | 1183c6c9724de537971903a66b537144fe39111f (patch) | |
tree | 1866c4836169b604b2f95fce58b0606958641f02 /tests | |
parent | 5359bf1df4e64c1f2f19bff69670ed2f213d8c21 (diff) | |
download | pyasn1-1183c6c9724de537971903a66b537144fe39111f.tar.gz |
ASN.1 codecs to silently enforce proper length/chunk modes
Diffstat (limited to 'tests')
-rw-r--r-- | tests/codec/der/test_encoder.py | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/tests/codec/der/test_encoder.py b/tests/codec/der/test_encoder.py index d30dfc1..354781a 100644 --- a/tests/codec/der/test_encoder.py +++ b/tests/codec/der/test_encoder.py @@ -17,31 +17,28 @@ from pyasn1.error import PyAsn1Error class OctetStringEncoderTestCase(unittest.TestCase): - def testShortMode(self): + def testDefModeShort(self): assert encoder.encode( univ.OctetString('Quick brown fox') ) == ints2octs((4, 15, 81, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120)) - def testIndefMode(self): - try: - encoder.encode(univ.OctetString('Quick brown'), defMode=False) - except PyAsn1Error: - pass - else: - assert 0, 'Indefinite length encoding tolerated' - - def testChunkedMode(self): + def testDefModeLong(self): assert encoder.encode( - univ.OctetString('Quick brown'), maxChunkSize=2 - ) == ints2octs((4, 11, 81, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110)) + univ.OctetString('Q' * 10000) + ) == ints2octs((4, 130, 39, 16) + (81,) * 10000) class BitStringEncoderTestCase(unittest.TestCase): - def testShortMode(self): + def testDefModeShort(self): assert encoder.encode( univ.BitString((1,)) ) == ints2octs((3, 2, 7, 128)) + def testDefModeLong(self): + assert encoder.encode( + univ.BitString((1,) * 80000) + ) == ints2octs((3, 130, 39, 17, 0) + (255,) * 10000) + class SetOfEncoderTestCase(unittest.TestCase): def setUp(self): |