aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/pyasn1-modules/py2/tests/test_rfc8494.py
diff options
context:
space:
mode:
authoralexv-smirnov <alex@ydb.tech>2023-12-01 12:02:50 +0300
committeralexv-smirnov <alex@ydb.tech>2023-12-01 13:28:10 +0300
commit0e578a4c44d4abd539d9838347b9ebafaca41dfb (patch)
treea0c1969c37f818c830ebeff9c077eacf30be6ef8 /contrib/python/pyasn1-modules/py2/tests/test_rfc8494.py
parent84f2d3d4cc985e63217cff149bd2e6d67ae6fe22 (diff)
downloadydb-0e578a4c44d4abd539d9838347b9ebafaca41dfb.tar.gz
Change "ya.make"
Diffstat (limited to 'contrib/python/pyasn1-modules/py2/tests/test_rfc8494.py')
-rw-r--r--contrib/python/pyasn1-modules/py2/tests/test_rfc8494.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/contrib/python/pyasn1-modules/py2/tests/test_rfc8494.py b/contrib/python/pyasn1-modules/py2/tests/test_rfc8494.py
new file mode 100644
index 0000000000..2951e39200
--- /dev/null
+++ b/contrib/python/pyasn1-modules/py2/tests/test_rfc8494.py
@@ -0,0 +1,55 @@
+#
+# This file is part of pyasn1-modules software.
+#
+# Copyright (c) 2019, Vigil Security, LLC
+# License: http://snmplabs.com/pyasn1/license.html
+#
+import sys
+import unittest
+
+from pyasn1.codec.der.decoder import decode as der_decoder
+from pyasn1.codec.der.encoder import encode as der_encoder
+
+from pyasn1_modules import pem
+from pyasn1_modules import rfc8494
+
+
+class CompresssedDataTestCase(unittest.TestCase):
+ pem_text = """\
+MIIBNqADAgEAMIIBLaADAgEZoIIBJASCASB4nG2P0U7CQBBF3/cr5l2K3YpSF5YA
+bYmbWArtQsJjKVuogd1mO0T8e0ti1IjJZB4md07OHZbWnMbqkp/qo+oW5jSCWDqL
+VCSpkBveg2kSbrg/FTIWcQRpJPlLmGYQzdci5MvlA+3Rx2cyREO/KVrhCOaJFLMN
+n03E6yqNIEmDheS2LHzPG0zNdqw0dn89XAnev4RsFQRRlnW+SITMWmMGf72JNAyk
+oXCj0mnPHtzwSZijYuD1YVJb8FzaB/rE2n3nUtcl2Xn7pgpkkAOqBsm1vrNWtqmM
+ZkC7LgmMxraFgx91y0F1wfv6mFd6AMUht41CfsbS8X9yNtdNqayjdGF2ld4z8LcV
+EiIPVQPtvBuLBxjW5qx3TbXXo6vHJ1OhhLY=
+
+"""
+
+ def setUp(self):
+ self.asn1Spec = rfc8494.CompressedData()
+
+ def testDerCodec(self):
+ substrate = pem.readBase64fromText(self.pem_text)
+ asn1Object, rest = der_decoder(substrate, asn1Spec=self.asn1Spec)
+
+ self.assertFalse(rest)
+ self.assertTrue(asn1Object.prettyPrint())
+ self.assertEqual(substrate, der_encoder(asn1Object))
+
+ self.assertEqual(
+ 0, asn1Object['compressionAlgorithm']['algorithmID-ShortForm'])
+
+ cci = asn1Object['compressedContentInfo']
+
+ self.assertEqual(
+ 25, cci['unnamed']['contentType-ShortForm'])
+ self.assertEqual(
+ '0x789c6d8fd1', cci['compressedContent'].prettyPrint()[:12])
+
+
+suite = unittest.TestLoader().loadTestsFromModule(sys.modules[__name__])
+
+if __name__ == '__main__':
+ result = unittest.TextTestRunner(verbosity=2).run(suite)
+ sys.exit(not result.wasSuccessful())