Patrole should only test glance v2 api.

This is with regards to
[0] https://docs.openstack.org/releasenotes/tempest/v16.0.0.html
Deprecating glance v1 in patrole and only testing glance v2.

Change-Id: I5b2e47542b8e6a7a9c0ce7f5c9d4c76291fac8c1
Closes-Bug: #1685938
This commit is contained in:
maniksidana 2017-06-08 09:45:39 -05:00
parent 7308f78c43
commit f98d8b8148
14 changed files with 5 additions and 242 deletions

View File

@ -1,79 +0,0 @@
# Copyright 2017 AT&T Corporation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tempest import config
from tempest.lib import decorators
from patrole_tempest_plugin import rbac_rule_validation
from patrole_tempest_plugin.tests.api.image import rbac_base as base
CONF = config.CONF
class ImagesMemberRbacTest(base.BaseV1ImageRbacTest):
credentials = ['primary', 'alt', 'admin']
@classmethod
def setup_clients(cls):
super(ImagesMemberRbacTest, cls).setup_clients()
cls.image_member_client = cls.os_primary.image_member_client
@classmethod
def resource_setup(cls):
super(ImagesMemberRbacTest, cls).resource_setup()
cls.alt_tenant_id = cls.os_alt.image_member_client.tenant_id
@rbac_rule_validation.action(service="glance", rule="add_member")
@decorators.idempotent_id('bda2bb78-e6ec-4b87-ba6d-1eaf1b28fa8b')
def test_add_image_member(self):
"""Add image member
RBAC test for the glance add_member policy
"""
image = self.create_image()
# Toggle role and add image member
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.image_member_client.create_image_member(image['id'],
self.alt_tenant_id)
@rbac_rule_validation.action(service="glance", rule="delete_member")
@decorators.idempotent_id('9beaf28c-62b7-4c30-bbe5-4283aed1201c')
def test_delete_image_member(self):
"""Delete image member
RBAC test for the glance delete_member policy
"""
image = self.create_image()
self.image_member_client.create_image_member(image['id'],
self.alt_tenant_id)
# Toggle role and delete image member
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.image_member_client.delete_image_member(image['id'],
self.alt_tenant_id)
@rbac_rule_validation.action(service="glance", rule="get_members")
@decorators.idempotent_id('a0fcd855-31ef-458c-97e0-14a448cdd6da')
def test_list_image_members(self):
"""List image members
RBAC test for the glance get_members policy
"""
image = self.create_image()
self.image_member_client.create_image_member(image['id'],
self.alt_tenant_id)
# Toggle role and delete image member
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.image_member_client.list_image_members(image['id'])

View File

@ -1,151 +0,0 @@
# Copyright 2017 AT&T Corporation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import six
from tempest import config
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from patrole_tempest_plugin import rbac_rule_validation
from patrole_tempest_plugin.tests.api.image import rbac_base
CONF = config.CONF
class BasicOperationsImagesRbacTest(rbac_base.BaseV1ImageRbacTest):
@rbac_rule_validation.action(service="glance", rule="add_image")
@decorators.idempotent_id('33248a04-6527-11e6-be0f-080027d0d606')
def test_create_image(self):
"""Create Image Test
RBAC test for the glance add_image policy.
"""
properties = {'prop1': 'val1'}
image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.create_image(name=image_name,
container_format='bare',
disk_format='raw',
is_public=False,
properties=properties)
@rbac_rule_validation.action(service="glance", rule="delete_image")
@decorators.idempotent_id('731c8c81-6c63-413b-a61a-050ce9ca16ad')
def test_delete_image(self):
"""Delete Image Test
RBAC test for the glance delete_image policy.
"""
image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
properties = {'prop1': 'val1'}
body = self.create_image(name=image_name,
container_format='bare',
disk_format='raw',
is_public=False,
properties=properties)
image_id = body['id']
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.client.delete_image(image_id)
@rbac_rule_validation.action(service="glance", rule="download_image")
@decorators.idempotent_id('a22bf112-5a3a-419e-9cd6-9562d1a3a458')
def test_download_image(self):
"""Download Image Test
RBAC test for the glance download_image policy.
"""
image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
properties = {'prop1': 'val1'}
body = self.create_image(name=image_name,
container_format='bare',
disk_format='raw',
is_public=False,
properties=properties)
image_id = body['id']
# Now try uploading an image file
image_file = six.BytesIO(data_utils.random_bytes())
self.client.update_image(image_id, data=image_file)
# Toggle role and get created image
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.client.show_image(image_id)
@rbac_rule_validation.action(service="glance", rule="get_image")
@decorators.idempotent_id('110257aa-6fa3-4cc0-b8dd-d93d43acd45c')
def test_get_image(self):
"""Get Image Test
RBAC test for the glance get_image policy.
"""
image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
properties = {'prop1': 'val1'}
body = self.create_image(name=image_name,
container_format='bare',
disk_format='raw',
is_public=False,
properties=properties)
image_id = body['id']
# Now try uploading an image file
image_file = six.BytesIO(data_utils.random_bytes())
self.client.update_image(image_id, data=image_file)
# Toggle role and get created image
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.client.check_image(image_id)
@rbac_rule_validation.action(service="glance", rule="get_images")
@decorators.idempotent_id('37662238-0fe9-4dff-8d90-e02f31e7e3fb')
def test_list_images(self):
"""Get Image Test
RBAC test for the glance get_images policy.
"""
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.client.list_images()
@rbac_rule_validation.action(service="glance", rule="modify_image")
@decorators.idempotent_id('3a391a19-d756-4c96-a346-72cc02f6106e')
def test_update_image(self):
"""Update Image Test
RBAC test for the glance modify_image policy.
"""
image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
properties = {'prop1': 'val1'}
body = self.create_image(name=image_name,
container_format='bare',
disk_format='raw',
is_public=False,
properties=properties)
image_id = body.get('id')
properties = {'prop1': 'val2'}
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.client.update_image(image_id, headers=properties)
@rbac_rule_validation.action(service="glance", rule="publicize_image")
@decorators.idempotent_id('d5b1d09f-ba47-4d56-913e-4f38733a9a5c')
def test_publicize_image(self):
"""Publicize Image Test
RBAC test for the glance publicize_image policy.
"""
image_name = data_utils.rand_name(self.__class__.__name__ + '-Image')
properties = {'prop1': 'val1'}
self.rbac_utils.switch_role(self, toggle_rbac_role=True)
self.create_image(name=image_name,
container_format='bare',
disk_format='raw',
is_public=True,
properties=properties)

View File

@ -35,10 +35,7 @@ class VolumesActionsRbacTest(rbac_base.BaseVolumeRbacTest):
@classmethod
def setup_clients(cls):
super(VolumesActionsRbacTest, cls).setup_clients()
if CONF.image_feature_enabled.api_v1:
cls.image_client = cls.os_primary.image_client
elif CONF.image_feature_enabled.api_v2:
cls.image_client = cls.os_primary.image_client_v2
cls.image_client = cls.os_primary.image_client_v2
@classmethod
def resource_setup(cls):

View File

@ -24,14 +24,6 @@ CONF = config.CONF
class VolumeMetadataRbacTest(rbac_base.BaseVolumeRbacTest):
@classmethod
def setup_clients(cls):
super(VolumeMetadataRbacTest, cls).setup_clients()
if CONF.image_feature_enabled.api_v1:
cls.image_client = cls.os_primary.image_client
elif CONF.image_feature_enabled.api_v2:
cls.image_client = cls.os_primary.image_client_v2
@classmethod
def resource_setup(cls):
super(VolumeMetadataRbacTest, cls).resource_setup()

View File

@ -0,0 +1,4 @@
---
deprecations:
- Glance v1 APIs are deprecated and v2 APIs are current. Glance v1 APIs are
removed from volume tests and Glance v1 RBAC tests are removed.