aboutsummaryrefslogtreecommitdiff
path: root/tests/codec
diff options
context:
space:
mode:
Diffstat (limited to 'tests/codec')
-rw-r--r--tests/codec/ber/test_decoder.py11
-rw-r--r--tests/codec/ber/test_encoder.py21
2 files changed, 25 insertions, 7 deletions
diff --git a/tests/codec/ber/test_decoder.py b/tests/codec/ber/test_decoder.py
index cd7262e..db5c217 100644
--- a/tests/codec/ber/test_decoder.py
+++ b/tests/codec/ber/test_decoder.py
@@ -167,8 +167,7 @@ class OctetStringDecoderTestCase(BaseTestCase):
def testIndefModeChunked(self):
assert decoder.decode(
- ints2octs((36, 128, 4, 4, 81, 117, 105, 99, 4, 4, 107, 32, 98, 114, 4, 4, 111, 119, 110, 32, 4, 3, 102, 111,
- 120, 0, 0))
+ ints2octs((36, 128, 4, 4, 81, 117, 105, 99, 4, 4, 107, 32, 98, 114, 4, 4, 111, 119, 110, 32, 4, 3, 102, 111, 120, 0, 0))
) == (str2octs('Quick brown fox'), null)
def testDefModeChunkedSubst(self):
@@ -381,7 +380,7 @@ class ObjectIdentifierDecoderTestCase(BaseTestCase):
except PyAsn1Error:
pass
else:
- assert 0, 'indefinite length tolarated'
+ assert 0, 'indefinite length tolerated'
def testReservedLength(self):
try:
@@ -393,14 +392,12 @@ class ObjectIdentifierDecoderTestCase(BaseTestCase):
def testLarge1(self):
assert decoder.decode(
- ints2octs((0x06, 0x11, 0x83, 0xC6, 0xDF, 0xD4, 0xCC, 0xB3, 0xFF, 0xFF, 0xFE, 0xF0, 0xB8, 0xD6, 0xB8, 0xCB,
- 0xE2, 0xB7, 0x17))
+ ints2octs((0x06, 0x11, 0x83, 0xC6, 0xDF, 0xD4, 0xCC, 0xB3, 0xFF, 0xFF, 0xFE, 0xF0, 0xB8, 0xD6, 0xB8, 0xCB, 0xE2, 0xB7, 0x17))
) == ((2, 18446744073709551535184467440737095), null)
def testLarge2(self):
assert decoder.decode(
- ints2octs((0x06, 0x13, 0x88, 0x37, 0x83, 0xC6, 0xDF, 0xD4, 0xCC, 0xB3, 0xFF, 0xFF, 0xFE, 0xF0, 0xB8, 0xD6,
- 0xB8, 0xCB, 0xE2, 0xB6, 0x47))
+ ints2octs((0x06, 0x13, 0x88, 0x37, 0x83, 0xC6, 0xDF, 0xD4, 0xCC, 0xB3, 0xFF, 0xFF, 0xFE, 0xF0, 0xB8, 0xD6, 0xB8, 0xCB, 0xE2, 0xB6, 0x47))
) == ((2, 999, 18446744073709551535184467440737095), null)
diff --git a/tests/codec/ber/test_encoder.py b/tests/codec/ber/test_encoder.py
index 78cb841..ba91919 100644
--- a/tests/codec/ber/test_encoder.py
+++ b/tests/codec/ber/test_encoder.py
@@ -436,18 +436,39 @@ if sys.version_info[0:2] > (2, 5):
(28, 12, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99)), 'Incorrect encoding'
+ class UniversalStringEncoderWithSchemaTestCase(BaseTestCase):
+ def testEncoding(self):
+ assert encoder.encode(
+ sys.version_info[0] == 3 and 'abc' or unicode('abc'), asn1Spec=char.UniversalString()
+ ) == ints2octs((28, 12, 0, 0, 0, 97, 0, 0, 0, 98, 0, 0, 0, 99)), 'Incorrect encoding'
+
+
class BMPStringEncoderTestCase(BaseTestCase):
def testEncoding(self):
assert encoder.encode(char.BMPString(sys.version_info[0] == 3 and 'abc' or unicode('abc'))) == ints2octs(
(30, 6, 0, 97, 0, 98, 0, 99)), 'Incorrect encoding'
+class BMPStringEncoderWithSchemaTestCase(BaseTestCase):
+ def testEncoding(self):
+ assert encoder.encode(
+ sys.version_info[0] == 3 and 'abc' or unicode('abc'), asn1Spec=char.BMPString()
+ ) == ints2octs((30, 6, 0, 97, 0, 98, 0, 99)), 'Incorrect encoding'
+
+
class UTF8StringEncoderTestCase(BaseTestCase):
def testEncoding(self):
assert encoder.encode(char.UTF8String(sys.version_info[0] == 3 and 'abc' or unicode('abc'))) == ints2octs(
(12, 3, 97, 98, 99)), 'Incorrect encoding'
+class UTF8StringEncoderWithSchemaTestCase(BaseTestCase):
+ def testEncoding(self):
+ assert encoder.encode(
+ sys.version_info[0] == 3 and 'abc' or unicode('abc'), asn1Spec=char.UTF8String()
+ ) == ints2octs((12, 3, 97, 98, 99)), 'Incorrect encoding'
+
+
class SequenceOfEncoderTestCase(BaseTestCase):
def testEmpty(self):
s = univ.SequenceOf()