Esempio n. 1
0
    def test_create_simple_cmc_order(self):
        test_model = order_models.OrderModel(**self.simple_cmc_data)
        test_model.meta['request_data'] = certutil.create_good_csr()

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(202, create_resp.status_code)
        self.assertIsNotNone(order_ref)

        order_resp = self.behaviors.get_order(order_ref)
        self.verify_pending_waiting_for_ca(order_resp)
    def test_create_cert_order_with_invalid_type(self):
        test_model = order_models.OrderModel(**self.simple_cmc_data)
        test_model.meta['request_data'] = base64.b64encode(
            certutil.create_good_csr())
        test_model.meta['request_type'] = "invalid_type"

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(400, create_resp.status_code)
        self.confirm_error_message(create_resp,
                                   "Invalid Certificate Request Type")
    def test_create_full_cmc_order(self):
        test_model = order_models.OrderModel(**self.full_cmc_data)
        test_model.meta['request_data'] = base64.b64encode(
            certutil.create_good_csr())

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(400, create_resp.status_code)
        self.assertIsNone(order_ref)
        self.confirm_error_message(create_resp,
                                   "Full CMC Requests are not yet supported.")
Esempio n. 4
0
 def setUp(self):
     super(WhenTestingSimpleCMCOrderValidator, self).setUp()
     self.type = 'certificate'
     self.meta = {'request_type': 'simple-cmc',
                  'request_data': base64.b64encode(certs.create_good_csr()),
                  'requestor_name': 'Barbican User',
                  'requestor_email': '*****@*****.**',
                  'requestor_phone': '555-1212'}
     self._set_order()
     self.validator = validators.TypeOrderValidator()
    def test_create_simple_cmc_with_profile_and_no_ca_id(self):
        test_model = order_models.OrderModel(**self.simple_cmc_data)
        test_model.meta['request_data'] = base64.b64encode(
            certutil.create_good_csr())
        test_model.meta['profile'] = 'caServerCert'

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(400, create_resp.status_code)
        self.assertIsNone(order_ref)
        self.confirm_error_message(
            create_resp, "Missing required metadata field for ca_id")
Esempio n. 6
0
    def test_create_full_cmc_order(self):
        test_model = order_models.OrderModel(**self.full_cmc_data)
        test_model.meta['request_data'] = certutil.create_good_csr()

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(create_resp.status_code, 400)
        self.assertIsNone(order_ref)
        self.confirm_error_message(
            create_resp,
            "Full CMC Requests are not yet supported."
        )
Esempio n. 7
0
    def test_create_cert_order_with_invalid_type(self):
        test_model = order_models.OrderModel(**self.simple_cmc_data)
        test_model.meta['request_data'] = certutil.create_good_csr()
        test_model.meta['request_type'] = "invalid_type"

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(400, create_resp.status_code)
        self.confirm_error_message(
            create_resp,
            "Invalid Certificate Request Type"
        )
Esempio n. 8
0
 def setUp(self):
     super(WhenTestingSimpleCMCOrderValidator, self).setUp()
     self.type = "certificate"
     self.meta = {
         "request_type": "simple-cmc",
         "request_data": base64.b64encode(certs.create_good_csr()),
         "requestor_name": "Barbican User",
         "requestor_email": "*****@*****.**",
         "requestor_phone": "555-1212",
     }
     self._set_order()
     self.validator = validators.TypeOrderValidator()
Esempio n. 9
0
 def setUp(self):
     super(WhenTestingSimpleCMCOrderValidator, self).setUp()
     self.type = 'certificate'
     self.meta = {
         'request_type': 'simple-cmc',
         'request_data': base64.b64encode(certs.create_good_csr()),
         'requestor_name': 'Barbican User',
         'requestor_email': '*****@*****.**',
         'requestor_phone': '555-1212'
     }
     self._set_order()
     self.validator = validators.TypeOrderValidator()
Esempio n. 10
0
    def test_create_simple_cmc_order_with_non_approved_dogtag_profile(self):
        test_model = order_models.OrderModel(**self.simple_cmc_data)
        test_model.meta['request_data'] = certutil.create_good_csr()
        test_model.meta['profile'] = 'caTPSCert'
        test_model.meta['ca_id'] = self.get_dogtag_ca_id()

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(202, create_resp.status_code)
        self.assertIsNotNone(order_ref)

        order_resp = self.wait_for_order(order_ref)
        self.verify_pending_waiting_for_ca(order_resp)
Esempio n. 11
0
    def test_create_cert_order_with_missing_request_type(self):
        # defaults to 'custom' type
        test_model = order_models.OrderModel(**self.dogtag_custom_data)
        test_model.meta['cert_request'] = certutil.create_good_csr()
        test_model.meta['profile_id'] = 'caTPSCert'

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(202, create_resp.status_code)
        self.assertIsNotNone(order_ref)

        order_resp = self.behaviors.get_order(order_ref)
        self.verify_pending_waiting_for_ca(order_resp)
Esempio n. 12
0
    def test_create_custom_order_with_valid_dogtag_data(self):
        # defaults to 'custom' type
        test_model = order_models.OrderModel(**self.dogtag_custom_data)
        test_model.meta['cert_request'] = certutil.create_good_csr()

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(create_resp.status_code, 202)
        self.assertIsNotNone(order_ref)

        order_resp = self.wait_for_order(order_ref)
        self.assertEqual('ACTIVE', order_resp.model.status)
        self.verify_cert_returned(order_resp)
Esempio n. 13
0
    def test_create_simple_cmc_with_profile_and_no_ca_id(self):
        test_model = order_models.OrderModel(**self.simple_cmc_data)
        test_model.meta['request_data'] = certutil.create_good_csr()
        test_model.meta['profile'] = 'caServerCert'

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(400, create_resp.status_code)
        self.assertIsNone(order_ref)
        self.confirm_error_message(
            create_resp,
            "Missing required metadata field for ca_id"
        )
Esempio n. 14
0
    def test_create_simple_cmc_with_profile_and_incorrect_ca_id(self):
        test_model = order_models.OrderModel(**self.simple_cmc_data)
        test_model.meta['request_data'] = base64.b64encode(
            certutil.create_good_csr())
        test_model.meta['profile'] = 'caServerCert'
        test_model.meta['ca_id'] = 'incorrect_ca_id'

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(400, create_resp.status_code)
        self.assertIsNone(order_ref)
        self.confirm_error_message(
            create_resp, "Order creation issue seen - The ca_id provided "
            "in the request is invalid.")
Esempio n. 15
0
    def test_create_cert_order_with_missing_request_type_auto_enroll(self):
        # defaults to 'custom' type
        test_model = order_models.OrderModel(**self.dogtag_custom_data)
        test_model.meta['cert_request'] = base64.b64encode(
            certutil.create_good_csr())

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(202, create_resp.status_code)
        self.assertIsNotNone(order_ref)

        order_resp = self.wait_for_order(order_ref)
        self.assertEqual('ACTIVE', order_resp.model.status)
        self.verify_cert_returned(order_resp)
Esempio n. 16
0
    def test_create_cert_order_with_missing_request_type(self):
        # defaults to 'custom' type
        test_model = order_models.OrderModel(**self.dogtag_custom_data)
        test_model.meta['cert_request'] = base64.b64encode(
            certutil.create_good_csr())
        test_model.meta['profile_id'] = 'caTPSCert'

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(202, create_resp.status_code)
        self.assertIsNotNone(order_ref)

        order_resp = self.behaviors.get_order(order_ref)
        self.verify_pending_waiting_for_ca(order_resp)
Esempio n. 17
0
    def test_create_simple_cmc_order_with_non_approved_dogtag_profile(self):
        test_model = order_models.OrderModel(**self.simple_cmc_data)
        test_model.meta['request_data'] = base64.b64encode(
            certutil.create_good_csr())
        test_model.meta['profile'] = 'caTPSCert'
        test_model.meta['ca_id'] = self.get_dogtag_ca_id()

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(202, create_resp.status_code)
        self.assertIsNotNone(order_ref)

        order_resp = self.wait_for_order(order_ref)
        self.verify_pending_waiting_for_ca(order_resp)
Esempio n. 18
0
    def test_create_custom_order_with_valid_dogtag_data(self):
        # defaults to 'custom' type
        test_model = order_models.OrderModel(**self.dogtag_custom_data)
        test_model.meta['cert_request'] = base64.b64encode(
            certutil.create_good_csr())

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(202, create_resp.status_code)
        self.assertIsNotNone(order_ref)

        order_resp = self.wait_for_order(order_ref)
        self.assertEqual('ACTIVE', order_resp.model.status)
        self.verify_cert_returned(order_resp)
Esempio n. 19
0
    def test_create_simple_cmc_order_with_dogtag_profile(self):
        test_model = order_models.OrderModel(**self.simple_cmc_data)
        test_model.meta['request_data'] = certutil.create_good_csr()
        test_model.meta['profile'] = 'caServerCert'
        test_model.meta['ca_id'] = self.get_dogtag_ca_id()

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(202, create_resp.status_code)
        self.assertIsNotNone(order_ref)

        order_resp = self.wait_for_order(order_ref)

        self.assertEqual('ACTIVE', order_resp.model.status)
        self.verify_cert_returned(order_resp)
Esempio n. 20
0
    def test_create_simple_cmc_with_profile_and_incorrect_ca_id(self):
        test_model = order_models.OrderModel(**self.simple_cmc_data)
        test_model.meta['request_data'] = certutil.create_good_csr()
        test_model.meta['profile'] = 'caServerCert'
        test_model.meta['ca_id'] = 'incorrect_ca_id'

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(400, create_resp.status_code)
        self.assertIsNone(order_ref)
        self.confirm_error_message(
            create_resp,
            "Order creation issue seen - The ca_id provided "
            "in the request is invalid."
        )
Esempio n. 21
0
    def test_create_simple_cmc_order_without_requestor_info(self):
        self.simple_cmc_data.pop("requestor_name", None)
        self.simple_cmc_data.pop("requestor_email", None)
        self.simple_cmc_data.pop("requestor_phone", None)

        test_model = order_models.OrderModel(**self.simple_cmc_data)
        test_model.meta['request_data'] = base64.b64encode(
            certutil.create_good_csr())

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(202, create_resp.status_code)
        self.assertIsNotNone(order_ref)

        order_resp = self.behaviors.get_order(order_ref)
        self.verify_pending_waiting_for_ca(order_resp)
Esempio n. 22
0
    def test_create_simple_cmc_order_with_dogtag_profile(self):
        test_model = order_models.OrderModel(**self.simple_cmc_data)
        test_model.meta['request_data'] = base64.b64encode(
            certutil.create_good_csr())
        test_model.meta['profile'] = 'caServerCert'
        test_model.meta['ca_id'] = self.get_dogtag_ca_id()

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(202, create_resp.status_code)
        self.assertIsNotNone(order_ref)

        order_resp = self.wait_for_order(order_ref)

        self.assertEqual('ACTIVE', order_resp.model.status)
        self.verify_cert_returned(order_resp)
Esempio n. 23
0
    def test_create_simple_cmc_order_without_requestor_info(self):
        self.simple_cmc_data.pop("requestor_name", None)
        self.simple_cmc_data.pop("requestor_email", None)
        self.simple_cmc_data.pop("requestor_phone", None)

        test_model = order_models.OrderModel(**self.simple_cmc_data)
        test_model.meta['request_data'] = base64.b64encode(
            certutil.create_good_csr())

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(202, create_resp.status_code)
        self.assertIsNotNone(order_ref)

        order_resp = self.behaviors.get_order(order_ref)
        self.verify_pending_waiting_for_ca(order_resp)
Esempio n. 24
0
    def send_test_order(self, ca_ref=None, user_name=None,
                        expected_return=202):
        test_model = order_models.OrderModel(**self.simple_cmc_data)
        test_model.meta['request_data'] = base64.b64encode(
            certutil.create_good_csr())
        if ca_ref is not None:
            ca_id = hrefs.get_ca_id_from_ref(ca_ref)
            test_model.meta['ca_id'] = ca_id

        create_resp, order_ref = self.order_behaviors.create_order(
            test_model, user_name=user_name)
        self.assertEqual(expected_return, create_resp.status_code)
        if expected_return == 202:
            self.assertIsNotNone(order_ref)
        return order_ref
Esempio n. 25
0
    def test_create_simple_cmc_order_with_invalid_dogtag_profile(self):
        test_model = order_models.OrderModel(**self.simple_cmc_data)
        test_model.meta['request_data'] = base64.b64encode(
            certutil.create_good_csr())
        test_model.meta['profile'] = 'invalidProfileID'
        test_model.meta['ca_id'] = self.get_dogtag_ca_id()

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(202, create_resp.status_code)
        self.assertIsNotNone(order_ref)

        order_resp = self.wait_for_order(order_ref)
        self.assertEqual('ERROR', order_resp.model.status)
        self.assertEqual('400', order_resp.model.error_status_code)
        self.assertIn('Problem with data in certificate request',
                      order_resp.model.error_reason)
        self.assertIn('Profile not found', order_resp.model.error_reason)
Esempio n. 26
0
    def test_create_simple_cmc_order_with_invalid_dogtag_profile(self):
        test_model = order_models.OrderModel(**self.simple_cmc_data)
        test_model.meta['request_data'] = certutil.create_good_csr()
        test_model.meta['profile'] = 'invalidProfileID'
        test_model.meta['ca_id'] = self.get_dogtag_ca_id()

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(202, create_resp.status_code)
        self.assertIsNotNone(order_ref)

        order_resp = self.wait_for_order(order_ref)
        self.assertEqual('ERROR', order_resp.model.status)
        self.assertEqual('400', order_resp.model.error_status_code)
        self.assertIn('Problem with data in certificate request',
                      order_resp.model.error_reason)
        self.assertIn('Profile not found',
                      order_resp.model.error_reason)
Esempio n. 27
0
    def test_create_simple_cmc_order(self):
        test_model = order_models.OrderModel(**self.simple_cmc_data)
        test_model.meta['request_data'] = base64.b64encode(
            certutil.create_good_csr())

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(202, create_resp.status_code)
        self.assertIsNotNone(order_ref)

        order_resp = self.behaviors.get_order(order_ref)
        self.verify_pending_waiting_for_ca(order_resp)

        # Wait for retry processing to handle checking for status with the
        # default certificate plugin (which takes about 10 seconds +- 20%).
        order_resp = self.wait_for_order(
            order_ref, delay_before_check_seconds=20, max_wait_seconds=25)

        self.assertEqual('ACTIVE', order_resp.model.status)
Esempio n. 28
0
    def test_create_simple_cmc_order(self):
        test_model = order_models.OrderModel(**self.simple_cmc_data)
        test_model.meta['request_data'] = base64.b64encode(
            certutil.create_good_csr())

        create_resp, order_ref = self.behaviors.create_order(test_model)
        self.assertEqual(202, create_resp.status_code)
        self.assertIsNotNone(order_ref)

        order_resp = self.behaviors.get_order(order_ref)
        self.verify_pending_waiting_for_ca(order_resp)

        # Wait for retry processing to handle checking for status with the
        # default certificate plugin (which takes about 10 seconds +- 20%).
        order_resp = self.wait_for_order(
            order_ref, delay_before_check_seconds=20, max_wait_seconds=25)

        self.assertEqual('ACTIVE', order_resp.model.status)