Example #1
0
 def test_list(self):
     domain_id = 'domain1'
     with mock.patch.object(self.policy_api, "list") as api_call:
         self.resourceApi.list(domain_id=domain_id, tenant=TEST_TENANT)
         expected_def = policy_defs.DeploymentMapDef(domain_id=domain_id,
                                                     tenant=TEST_TENANT)
         self.assert_called_with_def(api_call, expected_def)
Example #2
0
 def test_get(self):
     id = '111'
     domain_id = 'domain1'
     with mock.patch.object(self.policy_api, "get") as api_call:
         self.resourceApi.get(id, domain_id=domain_id, tenant=TEST_TENANT)
         expected_def = policy_defs.DeploymentMapDef(map_id=id,
                                                     domain_id=domain_id,
                                                     tenant=TEST_TENANT)
         self.assert_called_with_def(api_call, expected_def)
 def list(self, domain_id=None,
          tenant=policy_constants.POLICY_INFRA_TENANT):
     if not domain_id:
         # domain_id must be provided
         err_msg = (_("Cannot list deployment maps without a domain"))
         raise exceptions.ManagerError(details=err_msg)
     map_def = policy_defs.DeploymentMapDef(domain_id=domain_id,
                                            tenant=tenant)
     return self.policy_api.list(map_def)['results']
    def delete(self, map_id, domain_id=None,
               tenant=policy_constants.POLICY_INFRA_TENANT):
        if not domain_id:
            # domain_id must be provided
            err_msg = (_("Cannot delete deployment maps without a domain"))
            raise exceptions.ManagerError(details=err_msg)

        map_def = policy_defs.DeploymentMapDef(
            map_id=map_id, domain_id=domain_id, tenant=tenant)
        self.policy_api.delete(map_def)
 def update(self, map_id, name=None, description=None,
            ep_id=None, domain_id=None,
            tenant=policy_constants.POLICY_INFRA_TENANT):
     map_def = policy_defs.DeploymentMapDef(
         map_id=map_id, domain_id=domain_id, tenant=tenant)
     map_def.update_attributes_in_body(name=name,
                                       description=description,
                                       ep_id=ep_id,
                                       domain_id=domain_id)
     # update the backend
     return self.policy_api.create_or_update(map_def)
 def create_or_overwrite(self, name, map_id=None, description=None,
                         ep_id=None, domain_id=None,
                         tenant=policy_constants.POLICY_INFRA_TENANT):
     map_id = self._init_obj_uuid(map_id)
     map_def = policy_defs.DeploymentMapDef(
         map_id=map_id,
         name=name,
         description=description,
         ep_id=ep_id,
         domain_id=domain_id,
         tenant=tenant)
     return self.policy_api.create_or_update(map_def)
Example #7
0
    def test_create(self):
        map_def = policy.DeploymentMapDef('dm1', domain_id='d1', ep_id='ep1')

        self.policy_api.create_or_update(map_def)
        ep_path = policy.EnforcementPointDef('ep1').get_resource_full_path()
        expected_data = {
            'id': 'dm1',
            'display_name': None,
            'description': None,
            'enforcement_point_path': ep_path
        }

        self.assert_json_call('PATCH',
                              self.client,
                              'infra/domains/d1/domain-deployment-maps/dm1',
                              data=expected_data)
Example #8
0
 def test_get_by_name(self):
     name = 'ep1'
     domain_id = 'domain1'
     with mock.patch.object(
             self.policy_api,
             "list",
             return_value={'results': [{
                 'display_name': name
             }]}) as api_call:
         obj = self.resourceApi.get_by_name(name,
                                            domain_id=domain_id,
                                            tenant=TEST_TENANT)
         self.assertIsNotNone(obj)
         expected_def = policy_defs.DeploymentMapDef(domain_id=domain_id,
                                                     tenant=TEST_TENANT)
         self.assert_called_with_def(api_call, expected_def)
Example #9
0
 def test_create(self):
     name = 'map1'
     description = 'desc'
     domain_id = 'domain1'
     ep_id = 'ep1'
     with mock.patch.object(self.policy_api,
                            "create_or_update") as api_call:
         self.resourceApi.create_or_overwrite(name,
                                              description=description,
                                              ep_id=ep_id,
                                              domain_id=domain_id,
                                              tenant=TEST_TENANT)
         expected_def = policy_defs.DeploymentMapDef(
             map_id=mock.ANY,
             name=name,
             description=description,
             ep_id=ep_id,
             domain_id=domain_id,
             tenant=TEST_TENANT)
         self.assert_called_with_def(api_call, expected_def)
Example #10
0
 def test_update(self):
     id = '111'
     name = 'new name'
     domain_id = 'domain2'
     ep_id = 'ep2'
     with mock.patch.object(self.policy_api,
                            "create_or_update") as update_call:
         self.resourceApi.update(id,
                                 name=name,
                                 ep_id=ep_id,
                                 domain_id=domain_id,
                                 tenant=TEST_TENANT)
         expected_def = policy_defs.DeploymentMapDef(map_id=id,
                                                     tenant=TEST_TENANT)
         domain_path = "/%s/domains/%s" % (TEST_TENANT, domain_id)
         ep_path = ("/%s/deployment-zones/default/"
                    "enforcement-points/%s" % (TEST_TENANT, ep_id))
         expected_dict = {
             'display_name': name,
             'enforcement_point_path': ep_path,
             'parent_path': domain_path
         }
         self.assert_called_with_def_and_dict(update_call, expected_def,
                                              expected_dict)