Beispiel #1
0
    def test_resource_show_with_not_admin_and_resource_in_other_project(self):
        # Setup
        graph = self._create_graph()
        apis = ResourceApis(graph, None, self.api_lock)
        ctx = {'tenant': 'project_2', 'is_admin': False}

        # Action
        resource = apis.show_resource(ctx, 'instance_2')

        # Test assertions
        self.assertIsNone(resource)
Beispiel #2
0
    def test_resource_show_with_not_admin_and_no_project_resource(self):
        # Setup
        graph = self._create_graph()
        apis = ResourceApis(graph, None)
        ctx = {'tenant': 'project_1', 'is_admin': False}

        # Action
        resource = apis.show_resource(ctx, 'zone_1')

        # Test assertions
        self.assertIsNone(resource)
Beispiel #3
0
    def test_resource_show_with_admin_and_no_project_resource(self):
        # Setup
        graph = self._create_graph()
        apis = ResourceApis(graph, None, self.api_lock)
        ctx = {'tenant': 'project_1', 'is_admin': True}

        # Action
        resource = apis.show_resource(ctx, 'zone_1')
        resource = json.loads(resource)

        # Test assertions
        self.assertIsNotNone(resource)
        self._check_resource_properties(resource, 'zone_1',
                                        NOVA_ZONE_DATASOURCE)
Beispiel #4
0
    def test_resource_show_with_admin_and_resource_in_other_project(self):
        # Setup
        graph = self._create_graph()
        apis = ResourceApis(graph, None)
        ctx = {'tenant': 'project_2', 'is_admin': True}

        # Action
        resource = apis.show_resource(ctx, 'instance_2')
        resource = json.loads(resource)

        # Test assertions
        self.assertIsNotNone(resource)
        self._check_resource_properties(resource, 'instance_2',
                                        NOVA_INSTANCE_DATASOURCE,
                                        project_id='project_1')