':py:obj:`X509.get_extension` takes an integer and returns an :py:obj:`X509Extension`
corresponding to the extension at that index.'

def test_get_extension(self):

    pkey = load_privatekey(FILETYPE_PEM, client_key_pem)
    ca = X509Extension(b('basicConstraints'), True, b('CA:FALSE'))
    key = X509Extension(b('keyUsage'), True, b('digitalSignature'))
    subjectAltName = X509Extension(b('subjectAltName'), False, b('DNS:example.com'))
    cert = self._extcert(pkey, [ca, key, subjectAltName])
    ext = cert.get_extension(0)
    self.assertTrue(isinstance(ext, X509Extension))
    self.assertTrue(ext.get_critical())
    self.assertEqual(ext.get_short_name(), b('basicConstraints'))
    ext = cert.get_extension(1)
    self.assertTrue(isinstance(ext, X509Extension))
    self.assertTrue(ext.get_critical())
    self.assertEqual(ext.get_short_name(), b('keyUsage'))
    ext = cert.get_extension(2)
    self.assertTrue(isinstance(ext, X509Extension))
    self.assertFalse(ext.get_critical())
    self.assertEqual(ext.get_short_name(), b('subjectAltName'))
    self.assertRaises(IndexError, cert.get_extension, (-1))
    self.assertRaises(IndexError, cert.get_extension, 4)
    self.assertRaises(TypeError, cert.get_extension, 'hello')
