Example #1
0
    def test_barbican_cert_text(self):
        # Certificate data
        self.certificate = six.text_type(sample.X509_CERT)
        self.intermediates = six.text_type(sample.X509_IMDS_LIST)
        self.private_key = six.text_type(sample.X509_CERT_KEY_ENCRYPTED)
        self.private_key_passphrase = six.text_type(
            sample.X509_CERT_KEY_PASSPHRASE)
        self._prepare()

        container = containers.CertificateContainer(
            api=mock.MagicMock(),
            certificate=self.certificate_secret,
            intermediates=self.intermediates_secret,
            private_key=self.private_key_secret,
            private_key_passphrase=self.private_key_passphrase_secret)
        # Create a cert
        cert = barbican_common.BarbicanCert(cert_container=container)

        # Validate the cert functions
        self.assertEqual(cert.get_certificate(),
                         six.b(six.text_type(sample.X509_CERT)))
        self.assertEqual(cert.get_intermediates(), sample.X509_IMDS_LIST)
        self.assertEqual(cert.get_private_key(),
                         six.b(six.text_type(sample.X509_CERT_KEY_ENCRYPTED)))
        self.assertEqual(cert.get_private_key_passphrase(),
                         six.b(sample.X509_CERT_KEY_PASSPHRASE))
Example #2
0
 def create_certificate(self, **props):
     return containers.CertificateContainer(
         self.client().containers._api, **props)