blob: 7e13d7fa384c61d6924fb221e9444d65baf2b4c1 [file] [log] [blame]
lkuchlan3bd6e272018-01-25 11:16:10 +02001# Copyright 2018 Red Hat, Inc.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16from tempest.api.image import base
17from tempest.lib.common.utils import data_utils
18from tempest.lib import decorators
19
20
21class BasicOperationsImagesAdminTest(base.BaseV2ImageAdminTest):
zhufle68f4352020-04-21 13:44:55 +080022 """"Test image operations about image owner"""
lkuchlan3bd6e272018-01-25 11:16:10 +020023
24 @decorators.related_bug('1420008')
25 @decorators.idempotent_id('646a6eaa-135f-4493-a0af-12583021224e')
26 def test_create_image_owner_param(self):
zhufle68f4352020-04-21 13:44:55 +080027 """Test creating image with specified owner"""
lkuchlan3bd6e272018-01-25 11:16:10 +020028 # NOTE: Create image with owner different from tenant owner by
29 # using "owner" parameter requires an admin privileges.
30 random_id = data_utils.rand_uuid_hex()
31 image = self.admin_client.create_image(
32 container_format='bare', disk_format='raw', owner=random_id)
33 self.addCleanup(self.admin_client.delete_image, image['id'])
34 image_info = self.admin_client.show_image(image['id'])
35 self.assertEqual(random_id, image_info['owner'])
lkuchlanf8ff1ff2018-02-07 11:29:54 +020036
37 @decorators.related_bug('1420008')
38 @decorators.idempotent_id('525ba546-10ef-4aad-bba1-1858095ce553')
39 def test_update_image_owner_param(self):
zhufle68f4352020-04-21 13:44:55 +080040 """Test updating image owner"""
lkuchlanf8ff1ff2018-02-07 11:29:54 +020041 random_id_1 = data_utils.rand_uuid_hex()
42 image = self.admin_client.create_image(
43 container_format='bare', disk_format='raw', owner=random_id_1)
44 self.addCleanup(self.admin_client.delete_image, image['id'])
45 created_image_info = self.admin_client.show_image(image['id'])
46
47 random_id_2 = data_utils.rand_uuid_hex()
48 self.admin_client.update_image(
49 image['id'], [dict(replace="/owner", value=random_id_2)])
50 updated_image_info = self.admin_client.show_image(image['id'])
51
52 self.assertEqual(random_id_2, updated_image_info['owner'])
53 self.assertNotEqual(created_image_info['owner'],
54 updated_image_info['owner'])