Python pyasn1.type.univ.SequenceOf() Examples

The following are 1 code examples of pyasn1.type.univ.SequenceOf(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pyasn1.type.univ , or try the search function .
Example #1
Source File: test_rfc3739.py    From pyasn1-modules with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def testExtensionsMap(self):

        class SequenceOfOID(univ.SequenceOf):
            componentType = univ.ObjectIdentifier()

        openTypesMap = {
            univ.ObjectIdentifier('0.4.0.1862.1.6'): SequenceOfOID()
        }

        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))

        count = 0
        found_qc_stmt_oid = False
        for extn in asn1Object['tbsCertificate']['extensions']:
            if extn['extnID'] == rfc3739.id_pe_qcStatements:
                qc_stmts, rest = der_decoder(
                    extn['extnValue'],
                    asn1Spec=rfc5280.certificateExtensionsMap[extn['extnID']],
                    openTypes=openTypesMap,
                    decodeOpenTypes=True)
                self.assertFalse(rest)
                self.assertTrue(qc_stmts.prettyPrint())
                self.assertEqual(extn['extnValue'], der_encoder(qc_stmts))

                for qcs in qc_stmts:
                    count += 1
                    if qcs['statementId'] in openTypesMap.keys():
                        for oid in qcs['statementInfo']:
                            if oid == univ.ObjectIdentifier('0.4.0.1862.1.6.1'):
                                found_qc_stmt_oid = True

        self.assertEqual(2, count)
        self.assertTrue(found_qc_stmt_oid)