Ejemplo n.º 1
0
    def setUp(self):
        super(WhenTestingDogtagCAPlugin, self).setUp()
        self.certclient_mock = mock.MagicMock(name="CertClient mock")
        self.patcher = mock.patch('pki.crypto.NSSCryptoProvider')
        self.patcher.start()

        # create nss db for test only
        self.nss_dir = tempfile.mkdtemp()

        self.cfg_mock = mock.MagicMock(name='config mock')
        self.cfg_mock.dogtag_plugin = mock.MagicMock(
            nss_db_path=self.nss_dir)
        self.plugin = dogtag_import.DogtagCAPlugin(self.cfg_mock)
        self.plugin.certclient = self.certclient_mock
        self.order_id = mock.MagicMock()
        self.profile_id = mock.MagicMock()

        # request generated
        self.request = mock.MagicMock()
        self.request_id_mock = mock.MagicMock()
        self.request.request_id = self.request_id_mock
        self.request.request_status = dogtag_cert.CertRequestStatus.COMPLETE
        self.cert_id_mock = mock.MagicMock()
        self.request.cert_id = self.cert_id_mock

        # cert generated
        self.cert = mock.MagicMock()
        self.cert_encoded_mock = mock.MagicMock()
        self.cert.encoded = self.cert_encoded_mock
        self.cert_pkcs7_mock = mock.MagicMock()
        self.cert.pkcs7_cert_chain = self.cert_pkcs7_mock

        # for cancel/modify
        self.review_response = mock.MagicMock()

        # modified request
        self.modified_request = mock.MagicMock()
        self.modified_request_id_mock = mock.MagicMock()
        self.modified_request.request_id = self.modified_request_id_mock
        self.modified_request.request_status = (
            dogtag_cert.CertRequestStatus.COMPLETE)
        self.modified_request.cert_id = self.cert_id_mock

        self.barbican_meta_dto = cm.BarbicanMetaDTO()
Ejemplo n.º 2
0
    def setUp(self):
        super(WhenTestingDogtagCAPlugin, self).setUp()
        self.certclient_mock = mock.MagicMock(name="CertClient mock")
        self.patcher = mock.patch('pki.crypto.NSSCryptoProvider')
        self.patcher2 = mock.patch('pki.client.PKIConnection')
        self.patcher.start()
        self.patcher2.start()

        # create nss db for test only
        self.nss_dir = tempfile.mkdtemp()

        # create expiration file for test
        fh, self.expiration_data_path = tempfile.mkstemp()
        exp_time = datetime.datetime.utcnow() + datetime.timedelta(days=2)
        os.write(fh, exp_time.strftime(
            "%Y-%m-%d %H:%M:%S.%f"))
        os.close(fh)

        # create host CA file for test
        fh, self.host_ca_path = tempfile.mkstemp()
        os.write(fh, "host_ca_aid")
        os.close(fh)

        self.approved_profile_id = "caServerCert"
        CONF = dogtag_import.CONF
        CONF.dogtag_plugin.nss_db_path = self.nss_dir
        CONF.dogtag_plugin.ca_expiration_data_path = self.expiration_data_path
        CONF.dogtag_plugin.ca_host_aid_path = self.host_ca_path
        CONF.dogtag_plugin.auto_approved_profiles = [self.approved_profile_id]
        CONF.dogtag_plugin.dogtag_host = "localhost"
        CONF.dogtag_plugin.dogtag_port = 8443
        CONF.dogtag_plugin.simple_cmc_profile = "caOtherCert"
        self.cfg = CONF

        self.plugin = dogtag_import.DogtagCAPlugin(CONF)
        self.plugin.certclient = self.certclient_mock
        self.order_id = mock.MagicMock()
        self.profile_id = mock.MagicMock()

        # request generated
        self.request_id_mock = mock.MagicMock()
        self.request = dogtag_cert.CertRequestInfo()
        self.request.request_id = self.request_id_mock
        self.request.request_status = dogtag_cert.CertRequestStatus.COMPLETE
        self.cert_id_mock = mock.MagicMock()
        self.request.cert_id = self.cert_id_mock

        # cert generated
        self.cert = mock.MagicMock()
        self.cert.encoded = keys.get_certificate_pem()
        self.cert.pkcs7_cert_chain = keys.get_certificate_der()

        # for cancel/modify
        self.review_response = mock.MagicMock()

        # modified request
        self.modified_request = mock.MagicMock()
        self.modified_request_id_mock = mock.MagicMock()
        self.modified_request.request_id = self.modified_request_id_mock
        self.modified_request.request_status = (
            dogtag_cert.CertRequestStatus.COMPLETE)
        self.modified_request.cert_id = self.cert_id_mock

        self.barbican_meta_dto = cm.BarbicanMetaDTO()