def test_map_cert_tls_container(self, cert_mock): tls = data_models.TLSContainer( primary_cn=sample_certs.X509_CERT_CN, certificate=sample_certs.X509_CERT, private_key=sample_certs.X509_CERT_KEY_ENCRYPTED, passphrase=sample_certs.X509_CERT_KEY_PASSPHRASE, intermediates=sample_certs.X509_IMDS_LIST) cert_mock.get_private_key.return_value = tls.private_key cert_mock.get_certificate.return_value = tls.certificate cert_mock.get_intermediates.return_value = tls.intermediates cert_mock.get_private_key_passphrase.return_value = tls.passphrase with mock.patch.object(cert_parser, 'get_host_names') as cp: cp.return_value = {'cn': sample_certs.X509_CERT_CN} self.assertEqual( tls.primary_cn, cert_parser._map_cert_tls_container( cert_mock).primary_cn) self.assertEqual( tls.certificate, cert_parser._map_cert_tls_container( cert_mock).certificate) self.assertEqual( sample_certs.X509_CERT_KEY, cert_parser._map_cert_tls_container( cert_mock).private_key) self.assertEqual( tls.intermediates, cert_parser._map_cert_tls_container( cert_mock).intermediates)
def test_map_cert_tls_container(self, cert_mock): tls = data_models.TLSContainer( id=sample_certs.X509_CERT_SHA1, primary_cn=sample_certs.X509_CERT_CN, certificate=sample_certs.X509_CERT, private_key=sample_certs.X509_CERT_KEY_ENCRYPTED, passphrase=sample_certs.X509_CERT_KEY_PASSPHRASE, intermediates=sample_certs.X509_IMDS_LIST) cert_mock.get_private_key.return_value = tls.private_key cert_mock.get_certificate.return_value = tls.certificate cert_mock.get_intermediates.return_value = tls.intermediates cert_mock.get_private_key_passphrase.return_value = tls.passphrase with mock.patch.object(cert_parser, 'get_host_names') as cp: cp.return_value = {'cn': sample_certs.X509_CERT_CN} self.assertEqual(tls.id, cert_parser._map_cert_tls_container(cert_mock).id) self.assertEqual( tls.primary_cn, cert_parser._map_cert_tls_container(cert_mock).primary_cn) self.assertEqual( tls.certificate, cert_parser._map_cert_tls_container(cert_mock).certificate) self.assertEqual( sample_certs.X509_CERT_KEY, cert_parser._map_cert_tls_container(cert_mock).private_key) self.assertEqual( tls.intermediates, cert_parser._map_cert_tls_container(cert_mock).intermediates)
def test_map_cert_tls_container(self, cert_mock): tls = data_models.TLSContainer(primary_cn='fakeCN', certificate='imaCert', private_key='imaPrivateKey', intermediates=['imainter1', 'imainter2']) cert_mock.get_private_key.return_value = tls.private_key cert_mock.get_certificate.return_value = tls.certificate cert_mock.get_intermediates.return_value = tls.intermediates with mock.patch.object(cert_parser, 'get_host_names') as cp: cp.return_value = {'cn': 'fakeCN'} self.assertEqual( tls.primary_cn, cert_parser._map_cert_tls_container( cert_mock).primary_cn) self.assertEqual( tls.certificate, cert_parser._map_cert_tls_container( cert_mock).certificate) self.assertEqual( tls.private_key, cert_parser._map_cert_tls_container( cert_mock).private_key) self.assertEqual( tls.intermediates, cert_parser._map_cert_tls_container( cert_mock).intermediates)
def test_map_cert_tls_container(self, cert_mock): tls = data_models.TLSContainer( primary_cn='fakeCN', certificate='imaCert', private_key='imaPrivateKey', intermediates=['imainter1', 'imainter2']) cert_mock.get_private_key.return_value = tls.private_key cert_mock.get_certificate.return_value = tls.certificate cert_mock.get_intermediates.return_value = tls.intermediates with mock.patch.object(cert_parser, 'get_host_names') as cp: cp.return_value = {'cn': 'fakeCN'} self.assertEqual( tls.primary_cn, cert_parser._map_cert_tls_container(cert_mock).primary_cn) self.assertEqual( tls.certificate, cert_parser._map_cert_tls_container(cert_mock).certificate) self.assertEqual( tls.private_key, cert_parser._map_cert_tls_container(cert_mock).private_key) self.assertEqual( tls.intermediates, cert_parser._map_cert_tls_container(cert_mock).intermediates)