Ejemplo n.º 1
0
    def setUp(self):
        super(DeviceProfilePolicyTest, self).setUp()

        self.flags(enforce_scope=False, group="oslo_policy")
        self.controller = device_profiles.DeviceProfilesController()
        self.fake_dp_objs = fake_device_profile.get_obj_devprofs()
        self.fake_dps = fake_device_profile.get_api_devprofs()
        # check both legacy and new policies for create APIs
        self.create_authorized_contexts = [
            self.legacy_admin_context,  # legacy: admin
            self.system_admin_context,  # new policy: system_admin
            self.project_admin_context
        ]
        self.create_unauthorized_contexts = list(
            set(self.all_contexts) - set(self.create_authorized_contexts))

        # check both legacy and new policies for delete APIs
        self.delete_authorized_contexts = [
            # legacy: admin_or_owner
            self.legacy_admin_context,
            # NOTE(yumeng) although the legacy rule is admin_or_owner,
            # cyborg does not "actually" support owner check for
            # device profile, so we just uncomment legacy_owner_context here.
            # If later we need support owner policy, we should recheck here.
            # self.legacy_owner_context,
            self.system_admin_context,  # new policy: system_admin
            self.project_admin_context
        ]
        self.delete_unauthorized_contexts = list(
            set(self.all_contexts) - set(self.delete_authorized_contexts))
Ejemplo n.º 2
0
 def test_create(self):
     api_devprofs = fake_device_profile.get_api_devprofs()
     api_devprof = api_devprofs[0]
     db_devprofs = fake_device_profile.get_db_devprofs()
     db_devprof = db_devprofs[0]
     with mock.patch.object(self.dbapi,
                            'device_profile_create',
                            autospec=True) as mock_db_devprof_create:
         mock_db_devprof_create.return_value = self.fake_device_profile
         obj_devprof = objects.DeviceProfile(**api_devprof)
         obj_devprof.create(self.context)
         mock_db_devprof_create.assert_called_once_with(
             self.context, db_devprof)
Ejemplo n.º 3
0
 def setUp(self):
     super(TestDeviceProfileController, self).setUp()
     self.headers = self.gen_headers(self.context)
     self.fake_dp_objs = fake_device_profile.get_obj_devprofs()
     self.fake_dps = fake_device_profile.get_api_devprofs()