Exemplo n.º 1
0
    def delete_all_created_orders(self):
        """Delete all orders and other entities created by orders.

        """
        container_client = container_behaviors.ContainerBehaviors(self.client)
        secret_client = secret_behaviors.SecretBehaviors(self.client)

        orders_to_delete = [order for order in self.created_entities]

        for (order_ref, admin) in orders_to_delete:
            order_resp = self.get_order(order_ref, user_name=admin)

            # If order has secrets
            if order_resp.model.secret_ref:
                secret_client.delete_secret(order_resp.model.secret_ref,
                                            user_name=admin)

            # If containers supported
            container_attr_exists = getattr(order_resp.model,
                                            "container_ref",
                                            None)
            if container_attr_exists and order_resp.model.container_ref:
                container_resp = container_client.get_container(
                    order_resp.model.container_ref, user_name=admin)
                # remove secrets in the containers in the orders
                if container_resp.model.secret_refs:
                    for secret in container_resp.model.secret_refs:
                        secret_client.delete_secret(secret.secret_ref,
                                                    user_name=admin)

                container_client.delete_container(
                    order_resp.model.container_ref, user_name=admin)

            self.delete_order(order_ref, user_name=admin)
Exemplo n.º 2
0
    def setUp(self):
        super(OrdersTestCase, self).setUp()
        self.behaviors = order_behaviors.OrderBehaviors(self.client)
        self.secret_behaviors = secret_behaviors.SecretBehaviors(self.client)

        self.create_default_data = get_default_order_create_data()
        self.create_all_none_data = get_default_order_create_all_none_data()
Exemplo n.º 3
0
    def setUp(self):
        super(SecretsPagingTestCase, self).setUp()
        self.behaviors = secret_behaviors.SecretBehaviors(self.client)

        # make a local mutable copy of the default data to prevent
        # possible data contamination
        self.create_default_data = get_default_data()
Exemplo n.º 4
0
    def setUp(self):
        super(ContainersTestCase, self).setUp()
        self.secret_behaviors = secret_behaviors.SecretBehaviors(self.client)
        self.behaviors = container_behaviors.ContainerBehaviors(self.client)

        # Set up three secrets
        secret_ref_1 = self._create_a_secret()
        secret_ref_2 = self._create_a_secret()
        secret_ref_3 = self._create_a_secret()

        create_container_defaults_data['secret_refs'][0][
            'secret_ref'] = secret_ref_1
        create_container_defaults_data['secret_refs'][1][
            'secret_ref'] = secret_ref_2
        create_container_defaults_data['secret_refs'][2][
            'secret_ref'] = secret_ref_3

        create_container_rsa_data['secret_refs'][0][
            'secret_ref'] = secret_ref_1
        create_container_rsa_data['secret_refs'][1][
            'secret_ref'] = secret_ref_2
        create_container_rsa_data['secret_refs'][2][
            'secret_ref'] = secret_ref_3

        self.secret_id_1 = secret_ref_1.split('/')[-1]
        self.secret_id_2 = secret_ref_2.split('/')[-1]
        self.secret_id_3 = secret_ref_3.split('/')[-1]
Exemplo n.º 5
0
    def setUp(self):
        super(SecretMetadataTestCase, self).setUp()
        self.secret_behaviors = secret_behaviors.SecretBehaviors(self.client)
        self.behaviors = secretmeta_behaviors.SecretMetadataBehaviors(
            self.client)

        self.default_secret_create_all_none_data = {
            "name": None,
            "expiration": None,
            "algorithm": None,
            "bit_length": None,
            "mode": None,
            "payload": None,
            "payload_content_type": None,
            "payload_content_encoding": None,
        }

        self.valid_metadata = {
            "metadata": {
                "latitude": "30.393805",
                "longitude": "-97.724077"
            }
        }

        self.invalid_metadata = {
            "metadataaaaaaaa": {
                "latitude": "30.393805",
                "longitude": "-97.724077"
            }
        }

        self.valid_metadatum_key = 'access-limit'
        self.valid_metadatum = {'key': self.valid_metadatum_key, 'value': '2'}
Exemplo n.º 6
0
    def setUp(self):
        super(ConsumersTestCase, self).setUp()
        self.secret_behaviors = secret_behaviors.SecretBehaviors(self.client)
        self.container_behaviors = container_behaviors.ContainerBehaviors(
            self.client)
        self.consumer_behaviors = consumer_behaviors.ConsumerBehaviors(
            self.client)

        self.consumer_data = copy.deepcopy(self.default_data)

        # Set up two secrets
        secret_ref_1 = self._create_a_secret()
        secret_ref_2 = self._create_a_secret()

        # Create a container with our secrets
        create_container_data['secret_refs'][0]['secret_ref'] = secret_ref_1
        create_container_data['secret_refs'][1]['secret_ref'] = secret_ref_2
        container_model = container_models.ContainerModel(
            **create_container_data)

        resp, container_ref = self.container_behaviors.create_container(
            container_model)
        self.assertEqual(resp.status_code, 201)
        self.assertIsNotNone(container_ref)
        self.container_ref = container_ref
Exemplo n.º 7
0
 def setUp(self):
     super(CATestCommon, self).setUp()
     self.order_behaviors = order_behaviors.OrderBehaviors(self.client)
     self.ca_behaviors = ca_behaviors.CABehaviors(self.client)
     self.container_behaviors = container_behaviors.ContainerBehaviors(
         self.client)
     self.secret_behaviors = secret_behaviors.SecretBehaviors(self.client)
     self.simple_cmc_data = copy.deepcopy(order_simple_cmc_request_data)
Exemplo n.º 8
0
 def setUp(self):
     super(AclTestCase, self).setUp()
     self.secret_behaviors = secret_behaviors.SecretBehaviors(self.client)
     self.container_behaviors = container_behaviors.ContainerBehaviors(
         self.client)
     self.acl_behaviors = acl_behaviors.AclBehaviors(self.client)
     self.consumer_behaviors = consumer_behaviors.ConsumerBehaviors(
         self.client)
Exemplo n.º 9
0
    def setUp(self):
        super(OrdersUnauthedTestCase, self).setUp()
        self.behaviors = order_behaviors.OrderBehaviors(self.client)
        self.container_behaviors = container_behaviors.ContainerBehaviors(
            self.client)
        self.secret_behaviors = secret_behaviors.SecretBehaviors(self.client)

        self.create_default_data = get_default_order_create_data()
        self.dummy_order_ref = 'orders/dummy-7b86-4071-935d-ef6b83729200'
        self.dummy_project_id = 'dummy'
Exemplo n.º 10
0
    def setUp(self):
        super(DBManageTestCase, self).setUp()
        self.sbehaviors = secret_behaviors.SecretBehaviors(self.client)
        self.cbehaviors = container_behaviors.ContainerBehaviors(self.client)

        db_url = BCONF.sql_connection

        time.sleep(5)
        # Setup session for tests to query DB
        engine = session.create_engine(db_url)
        self.conn = engine.connect()
Exemplo n.º 11
0
    def setUp(self):
        super(ConsumersBaseTestCase, self).setUp()
        self.secret_behaviors = secret_behaviors.SecretBehaviors(self.client)
        self.container_behaviors = container_behaviors.ContainerBehaviors(
            self.client)
        self.consumer_behaviors = consumer_behaviors.ConsumerBehaviors(
            self.client)

        self.consumer_data = copy.deepcopy(default_consumer_data)

        self.generic_container_ref = self._create_populated_generic_container()
Exemplo n.º 12
0
 def setUp(self):
     super(CertificatesTestCase, self).setUp()
     self.behaviors = order_behaviors.OrderBehaviors(self.client)
     self.ca_behaviors = ca_behaviors.CABehaviors(self.client)
     self.container_behaviors = container_behaviors.ContainerBehaviors(
         self.client)
     self.secret_behaviors = secret_behaviors.SecretBehaviors(self.client)
     self.simple_cmc_data = copy.deepcopy(order_simple_cmc_request_data)
     self.full_cmc_data = copy.deepcopy(order_full_cmc_request_data)
     self.stored_key_data = copy.deepcopy(order_stored_key_request_data)
     self.dogtag_custom_data = copy.deepcopy(
         order_dogtag_custom_request_data)
Exemplo n.º 13
0
    def setUp(self):
        super(SecretsTestCase, self).setUp()
        self.behaviors = secret_behaviors.SecretBehaviors(self.client)

        # make a local mutable copies of the default data to prevent
        # possible data contamination if (when?) the data contains
        # any nested dicts.
        self.create_default_data = copy.deepcopy(default_secret_create_data)
        self.create_all_none_data = copy.deepcopy(
            default_secret_create_all_none_data)
        self.create_emptystrings = copy.deepcopy(
            default_secret_create_emptystrings_data)
        self.create_two_phase_data = copy.deepcopy(
            default_secret_create_two_phase_data)
Exemplo n.º 14
0
    def setUp(self):
        super(SecretsUnauthedTestCase, self).setUp()
        self.behaviors = secret_behaviors.SecretBehaviors(self.client)
        self.default_secret_create_data = get_default_data()
        self.dummy_secret_ref = 'orders/dummy-7b86-4071-935d-ef6b83729200'
        self.dummy_project_id = 'dummy'

        resp, self.real_secret_ref = self.behaviors.create_secret(
            secret_models.SecretModel(**self.default_secret_create_data))

        stored_auth = self.client._auth[
            self.client._default_user_name].stored_auth
        project_id = stored_auth.values()[0]['project_id']
        self.project_id_header = {'X-Project-Id': project_id}
        self.dummy_project_id_header = {'X-Project-Id': self.dummy_project_id}
Exemplo n.º 15
0
    def setUp(self):
        super(BaseContainerTestCase, self).setUp()
        self.secret_behaviors = secret_behaviors.SecretBehaviors(self.client)
        self.behaviors = container_behaviors.ContainerBehaviors(self.client)

        # Setting up three secrets for building containers
        self.secret_ref_1 = self._create_a_secret()
        self.secret_ref_2 = self._create_a_secret()
        self.secret_ref_3 = self._create_a_secret()

        self.default_data = copy.deepcopy(self.default_data_template)

        default_secret_refs = self.default_data['secret_refs']
        default_secret_refs[0]['secret_ref'] = self.secret_ref_1
        default_secret_refs[1]['secret_ref'] = self.secret_ref_2
        default_secret_refs[2]['secret_ref'] = self.secret_ref_3
Exemplo n.º 16
0
    def setUp(self):
        super(QuotaEnforcementTestCase, self).setUp()
        self.quota_behaviors = quota_behaviors.QuotaBehaviors(self.client)
        self.secret_behaviors = secret_behaviors.SecretBehaviors(self.client)
        self.container_behaviors = container_behaviors.ContainerBehaviors(
            self.client)
        self.order_behaviors = order_behaviors.OrderBehaviors(self.client)
        self.consumer_behaviors = consumer_behaviors.ConsumerBehaviors(
            self.client)

        self.secret_data = self.get_default_secret_data()
        self.quota_data = self.get_default_quota_data()
        self.project_id = self.quota_behaviors.get_project_id_from_name(
            admin_b)
        self.order_secrets = []
        self.root_ca_ref = None
        self.test_order_sent = False
Exemplo n.º 17
0
    def setUp(self):
        super(SecretsTestCase, self).setUp()
        self.behaviors = secret_behaviors.SecretBehaviors(self.client)

        # make a local mutable copies of the default data to prevent
        # possible data contamination if (when?) the data contains
        # any nested dicts.
        # TODO(tdink) Move to a config file
        self.default_secret_create_data = get_default_data()

        self.default_secret_create_all_none_data = {
            "name": None,
            "expiration": None,
            "algorithm": None,
            "bit_length": None,
            "mode": None,
            "payload": None,
            "payload_content_type": None,
            "payload_content_encoding": None,
        }

        self.default_secret_create_emptystrings_data = {
            "name": '',
            "expiration": '',
            "algorithm": '',
            "bit_length": '',
            "mode": '',
            "payload": '',
            "payload_content_type": '',
            "payload_content_encoding": '',
        }

        self.default_secret_create_two_phase_data = {
            "name": "AES key",
            "expiration": "2018-02-28T19:14:44.180394",
            "algorithm": "aes",
            "bit_length": 256,
            "mode": "cbc",
        }
Exemplo n.º 18
0
 def setUp(self):
     super(RSATestCase, self).setUp()
     self.secret_behaviors = secret_behaviors.SecretBehaviors(self.client)
     self.container_behaviors = container_behaviors.ContainerBehaviors(
         self.client)
     self.order_behaviors = order_behaviors.OrderBehaviors(self.client)
Exemplo n.º 19
0
 def setUp(self):
     super(RBACSecretsTestCase, self).setUp()
     self.secret_behaviors = secret_behaviors.SecretBehaviors(self.client)
Exemplo n.º 20
0
 def setUp(self):
     super(OrdersTestCase, self).setUp()
     self.behaviors = order_behaviors.OrderBehaviors(self.client)
     self.secret_behaviors = secret_behaviors.SecretBehaviors(self.client)
     self.default_data = copy.deepcopy(order_create_defaults_data)
     self.nones_data = copy.deepcopy(order_create_nones_data)
Exemplo n.º 21
0
 def setUp(self):
     super(SecretStoresTestCase, self).setUp()
     self.secret_behaviors = secret_behaviors.SecretBehaviors(self.client)
     self.ss_behaviors = secretstores_behaviors.SecretStoresBehaviors(
         self.client)