def test_key_usage_bad(self): allowed_usage = [ 'Digital Signature', 'Non Repudiation', 'Key Encipherment' ] csr = x509_csr.X509Csr() ext = x509_ext.X509ExtensionKeyUsage() ext.set_usage('keyCertSign', True) csr.add_extension(ext) with self.assertRaises(errors.ValidationError) as e: custom.key_usage(csr=csr, allowed_usage=allowed_usage) self.assertEqual("Found some prohibited key usages: " "keyCertSign", str(e.exception))
def test_key_usage_bad(self): allowed_usage = ['Digital Signature', 'Non Repudiation', 'Key Encipherment'] csr = x509_csr.X509Csr() ext = x509_ext.X509ExtensionKeyUsage() ext.set_usage('keyCertSign', True) csr.add_extension(ext) with self.assertRaises(errors.ValidationError) as e: custom.key_usage( csr=csr, allowed_usage=allowed_usage) self.assertEqual("Found some prohibited key usages: " "keyCertSign", str(e.exception))
def test_key_usage_good(self): allowed_usage = [ 'Digital Signature', 'Non Repudiation', 'Key Encipherment' ] csr = x509_csr.X509Csr() ext = x509_ext.X509ExtensionKeyUsage() ext.set_usage('keyEncipherment', True) ext.set_usage('digitalSignature', True) csr.add_extension(ext) self.assertEqual( None, custom.key_usage(csr=csr, allowed_usage=allowed_usage))
def test_key_usage_good(self): allowed_usage = ['Digital Signature', 'Non Repudiation', 'Key Encipherment'] csr = x509_csr.X509Csr() ext = x509_ext.X509ExtensionKeyUsage() ext.set_usage('keyEncipherment', True) ext.set_usage('digitalSignature', True) csr.add_extension(ext) self.assertEqual( None, custom.key_usage( csr=csr, allowed_usage=allowed_usage ) )