Example #1
0
    def test_parse_with_too_much_data(self):
        p = Parser(bytearray(b'\x00\x00'))

        cert_type = ServerCertTypeExtension()

        with self.assertRaises(SyntaxError):
            cert_type.parse(p)
Example #2
0
    def test_parse_with_too_much_data(self):
        p = Parser(bytearray(b'\x00\x00'))

        cert_type = ServerCertTypeExtension()

        with self.assertRaises(SyntaxError):
            cert_type.parse(p)
Example #3
0
    def test_write(self):
        cert_type = ServerCertTypeExtension().create(1)

        self.assertEqual(bytearray(
            b'\x00\x09' +       # extension type - cert_type (9)
            b'\x00\x01' +       # extension length - 1 byte
            b'\x01'             # selected certificate type - OpenPGP (1)
            ), cert_type.write())
Example #4
0
    def test_write(self):
        cert_type = ServerCertTypeExtension().create(1)

        self.assertEqual(
            bytearray(b'\x00\x09' +  # extension type - cert_type (9)
                      b'\x00\x01' +  # extension length - 1 byte
                      b'\x01'  # selected certificate type - OpenPGP (1)
                      ),
            cert_type.write())
Example #5
0
    def test_parse(self):
        p = Parser(bytearray(b'\x00'  # certificate type - X.509 (0)
                             ))

        cert_type = ServerCertTypeExtension().parse(p)

        self.assertEqual(0, cert_type.cert_type)
Example #6
0
    def test___repr__(self):
        cert_type = ServerCertTypeExtension().create(1)

        self.assertEqual("ServerCertTypeExtension(cert_type=1)",
                         repr(cert_type))
Example #7
0
    def test_create(self):
        cert_type = ServerCertTypeExtension().create(0)

        self.assertEqual(9, cert_type.extType)
        self.assertEqual(bytearray(b'\x00'), cert_type.extData)
        self.assertEqual(0, cert_type.cert_type)
Example #8
0
    def test___init__(self):
        cert_type = ServerCertTypeExtension()

        self.assertEqual(9, cert_type.extType)
        self.assertEqual(bytearray(0), cert_type.extData)
        self.assertIsNone(cert_type.cert_type)