ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 1 | # Copyright 2012 OpenStack Foundation |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 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. |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 15 | |
Matthew Treinish | b0c65f2 | 2015-04-23 09:09:41 -0400 | [diff] [blame] | 16 | import six |
Adam Gandelman | 85f5bed | 2014-06-19 16:48:17 -0700 | [diff] [blame] | 17 | |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 18 | from oslo_log import log as logging |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 19 | from tempest_lib import exceptions as lib_exc |
| 20 | |
Sean Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 21 | from tempest.api.compute import base |
Fei Long Wang | d39431f | 2015-05-14 11:30:48 +1200 | [diff] [blame] | 22 | from tempest.common.utils import data_utils |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 23 | from tempest import config |
Yuiko Takada | e9999d6 | 2014-03-06 09:22:54 +0000 | [diff] [blame] | 24 | from tempest import test |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 25 | |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 26 | CONF = config.CONF |
| 27 | |
Giulio Fidente | 92f7719 | 2013-08-26 17:13:28 +0200 | [diff] [blame] | 28 | LOG = logging.getLogger(__name__) |
| 29 | |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 30 | |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 31 | class AuthorizationTestJSON(base.BaseV2ComputeTest): |
Emily Hugenbruch | e7991d9 | 2014-12-12 16:53:36 +0000 | [diff] [blame] | 32 | |
Andrea Frittoli | b21de6c | 2015-02-06 20:12:38 +0000 | [diff] [blame] | 33 | credentials = ['primary', 'alt'] |
| 34 | |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 35 | @classmethod |
Emily Hugenbruch | e7991d9 | 2014-12-12 16:53:36 +0000 | [diff] [blame] | 36 | def skip_checks(cls): |
| 37 | super(AuthorizationTestJSON, cls).skip_checks() |
Adam Gandelman | 85f5bed | 2014-06-19 16:48:17 -0700 | [diff] [blame] | 38 | if not CONF.service_available.glance: |
| 39 | raise cls.skipException('Glance is not available.') |
Emily Hugenbruch | e7991d9 | 2014-12-12 16:53:36 +0000 | [diff] [blame] | 40 | |
| 41 | @classmethod |
| 42 | def setup_credentials(cls): |
Salvatore Orlando | 5a33724 | 2014-01-15 22:49:22 +0000 | [diff] [blame] | 43 | # No network resources required for this test |
| 44 | cls.set_network_resources() |
Emily Hugenbruch | e7991d9 | 2014-12-12 16:53:36 +0000 | [diff] [blame] | 45 | super(AuthorizationTestJSON, cls).setup_credentials() |
Emily Hugenbruch | e7991d9 | 2014-12-12 16:53:36 +0000 | [diff] [blame] | 46 | |
| 47 | @classmethod |
| 48 | def setup_clients(cls): |
| 49 | super(AuthorizationTestJSON, cls).setup_clients() |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 50 | cls.client = cls.os.servers_client |
| 51 | cls.images_client = cls.os.images_client |
Adam Gandelman | 85f5bed | 2014-06-19 16:48:17 -0700 | [diff] [blame] | 52 | cls.glance_client = cls.os.image_client |
rajalakshmi-ganesan | b74a11a | 2012-05-16 10:37:58 +0530 | [diff] [blame] | 53 | cls.keypairs_client = cls.os.keypairs_client |
John Warren | f234551 | 2015-12-10 13:39:30 -0500 | [diff] [blame] | 54 | cls.security_client = cls.os.compute_security_groups_client |
Ken'ichi Ohmichi | 685cd17 | 2015-07-13 01:29:57 +0000 | [diff] [blame] | 55 | cls.rule_client = cls.os.security_group_rules_client |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 56 | |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 57 | cls.alt_client = cls.alt_manager.servers_client |
| 58 | cls.alt_images_client = cls.alt_manager.images_client |
| 59 | cls.alt_keypairs_client = cls.alt_manager.keypairs_client |
John Warren | f234551 | 2015-12-10 13:39:30 -0500 | [diff] [blame] | 60 | cls.alt_security_client = ( |
| 61 | cls.alt_manager.compute_security_groups_client) |
Ken'ichi Ohmichi | 685cd17 | 2015-07-13 01:29:57 +0000 | [diff] [blame] | 62 | cls.alt_rule_client = cls.alt_manager.security_group_rules_client |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 63 | |
Emily Hugenbruch | e7991d9 | 2014-12-12 16:53:36 +0000 | [diff] [blame] | 64 | @classmethod |
| 65 | def resource_setup(cls): |
| 66 | super(AuthorizationTestJSON, cls).resource_setup() |
David Kranz | 0fb1429 | 2015-02-11 15:55:20 -0500 | [diff] [blame] | 67 | server = cls.create_test_server(wait_until='ACTIVE') |
ghanshyam | 0f82525 | 2015-08-25 16:02:50 +0900 | [diff] [blame] | 68 | cls.server = cls.client.show_server(server['id'])['server'] |
Jay Pipes | 3f981df | 2012-03-27 18:59:44 -0400 | [diff] [blame] | 69 | |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 70 | name = data_utils.rand_name('image') |
David Kranz | 34f1878 | 2015-01-06 13:43:55 -0500 | [diff] [blame] | 71 | body = cls.glance_client.create_image(name=name, |
| 72 | container_format='bare', |
| 73 | disk_format='raw', |
John Warren | 6620725 | 2015-07-31 15:51:02 -0400 | [diff] [blame] | 74 | is_public=False)['image'] |
Adam Gandelman | 85f5bed | 2014-06-19 16:48:17 -0700 | [diff] [blame] | 75 | image_id = body['id'] |
Matthew Treinish | b0c65f2 | 2015-04-23 09:09:41 -0400 | [diff] [blame] | 76 | image_file = six.StringIO(('*' * 1024)) |
John Warren | 6620725 | 2015-07-31 15:51:02 -0400 | [diff] [blame] | 77 | body = cls.glance_client.update_image(image_id, |
| 78 | data=image_file)['image'] |
Adam Gandelman | 85f5bed | 2014-06-19 16:48:17 -0700 | [diff] [blame] | 79 | cls.glance_client.wait_for_image_status(image_id, 'active') |
ghanshyam | 1756e0b | 2015-08-18 19:19:05 +0900 | [diff] [blame] | 80 | cls.image = cls.images_client.show_image(image_id)['image'] |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 81 | |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 82 | cls.keypairname = data_utils.rand_name('keypair') |
Ken'ichi Ohmichi | e364bce | 2015-07-17 10:27:59 +0000 | [diff] [blame] | 83 | cls.keypairs_client.create_keypair(name=cls.keypairname) |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 84 | |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 85 | name = data_utils.rand_name('security') |
| 86 | description = data_utils.rand_name('description') |
David Kranz | 9964b4e | 2015-02-06 15:45:29 -0500 | [diff] [blame] | 87 | cls.security_group = cls.security_client.create_security_group( |
ghanshyam | b610b77 | 2015-08-24 17:29:38 +0900 | [diff] [blame] | 88 | name=name, description=description)['security_group'] |
rajalakshmi-ganesan | b74a11a | 2012-05-16 10:37:58 +0530 | [diff] [blame] | 89 | |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 90 | parent_group_id = cls.security_group['id'] |
| 91 | ip_protocol = 'tcp' |
| 92 | from_port = 22 |
| 93 | to_port = 22 |
Ken'ichi Ohmichi | 685cd17 | 2015-07-13 01:29:57 +0000 | [diff] [blame] | 94 | cls.rule = cls.rule_client.create_security_group_rule( |
Ken'ichi Ohmichi | eb7eeec | 2015-07-21 01:00:06 +0000 | [diff] [blame] | 95 | parent_group_id=parent_group_id, ip_protocol=ip_protocol, |
ghanshyam | 0a5e123 | 2015-08-24 16:59:59 +0900 | [diff] [blame] | 96 | from_port=from_port, to_port=to_port)['security_group_rule'] |
rajalakshmi-ganesan | 184daad | 2012-05-18 14:47:38 +0530 | [diff] [blame] | 97 | |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 98 | @classmethod |
Andrea Frittoli | 50bb80d | 2014-09-15 12:34:27 +0100 | [diff] [blame] | 99 | def resource_cleanup(cls): |
Andrea Frittoli (andreaf) | 1f34241 | 2015-05-12 16:37:19 +0100 | [diff] [blame] | 100 | if hasattr(cls, 'image'): |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 101 | cls.images_client.delete_image(cls.image['id']) |
Andrea Frittoli (andreaf) | 1f34241 | 2015-05-12 16:37:19 +0100 | [diff] [blame] | 102 | if hasattr(cls, 'keypairname'): |
rajalakshmi-ganesan | b74a11a | 2012-05-16 10:37:58 +0530 | [diff] [blame] | 103 | cls.keypairs_client.delete_keypair(cls.keypairname) |
Andrea Frittoli (andreaf) | 1f34241 | 2015-05-12 16:37:19 +0100 | [diff] [blame] | 104 | if hasattr(cls, 'security_group'): |
rajalakshmi-ganesan | 184daad | 2012-05-18 14:47:38 +0530 | [diff] [blame] | 105 | cls.security_client.delete_security_group(cls.security_group['id']) |
Andrea Frittoli | 50bb80d | 2014-09-15 12:34:27 +0100 | [diff] [blame] | 106 | super(AuthorizationTestJSON, cls).resource_cleanup() |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 107 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 108 | @test.idempotent_id('56816e4a-bd34-47b5-aee9-268c3efeb5d4') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 109 | def test_get_server_for_alt_account_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 110 | # A GET request for a server on another user's account should fail |
Ken'ichi Ohmichi | 7680024 | 2015-07-03 05:12:31 +0000 | [diff] [blame] | 111 | self.assertRaises(lib_exc.NotFound, self.alt_client.show_server, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 112 | self.server['id']) |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 113 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 114 | @test.idempotent_id('fb8a4870-6d9d-44ad-8375-95d52e98d9f6') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 115 | def test_delete_server_for_alt_account_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 116 | # A DELETE request for another user's server should fail |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 117 | self.assertRaises(lib_exc.NotFound, self.alt_client.delete_server, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 118 | self.server['id']) |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 119 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 120 | @test.idempotent_id('d792f91f-1d49-4eb5-b1ff-b229c4b9dc64') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 121 | def test_update_server_for_alt_account_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 122 | # An update server request for another user's server should fail |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 123 | self.assertRaises(lib_exc.NotFound, self.alt_client.update_server, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 124 | self.server['id'], name='test') |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 125 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 126 | @test.idempotent_id('488f24df-d7f7-4207-949a-f17fcb8e8769') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 127 | def test_list_server_addresses_for_alt_account_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 128 | # A list addresses request for another user's server should fail |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 129 | self.assertRaises(lib_exc.NotFound, self.alt_client.list_addresses, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 130 | self.server['id']) |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 131 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 132 | @test.idempotent_id('00b442d0-2e72-40e7-9b1f-31772e36da01') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 133 | def test_list_server_addresses_by_network_for_alt_account_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 134 | # A list address/network request for another user's server should fail |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 135 | server_id = self.server['id'] |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 136 | self.assertRaises(lib_exc.NotFound, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 137 | self.alt_client.list_addresses_by_network, server_id, |
| 138 | 'public') |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 139 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 140 | @test.idempotent_id('cc90b35a-19f0-45d2-b680-2aabf934aa22') |
sapan-kona | 3793976 | 2012-06-28 20:22:43 +0530 | [diff] [blame] | 141 | def test_list_servers_with_alternate_tenant(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 142 | # A list on servers from one tenant should not |
| 143 | # show on alternate tenant |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 144 | # Listing servers from alternate tenant |
sapan-kona | 3793976 | 2012-06-28 20:22:43 +0530 | [diff] [blame] | 145 | alt_server_ids = [] |
David Kranz | ae99b9a | 2015-02-16 13:37:01 -0500 | [diff] [blame] | 146 | body = self.alt_client.list_servers() |
sapan-kona | 3793976 | 2012-06-28 20:22:43 +0530 | [diff] [blame] | 147 | alt_server_ids = [s['id'] for s in body['servers']] |
| 148 | self.assertNotIn(self.server['id'], alt_server_ids) |
| 149 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 150 | @test.idempotent_id('376dbc16-0779-4384-a723-752774799641') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 151 | def test_change_password_for_alt_account_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 152 | # A change password request for another user's server should fail |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 153 | self.assertRaises(lib_exc.NotFound, self.alt_client.change_password, |
Ken'ichi Ohmichi | e6349f3 | 2015-12-09 06:47:54 +0000 | [diff] [blame] | 154 | self.server['id'], adminPass='newpass') |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 155 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 156 | @test.idempotent_id('14cb5ff5-f646-45ca-8f51-09081d6c0c24') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 157 | def test_reboot_server_for_alt_account_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 158 | # A reboot request for another user's server should fail |
Ken'ichi Ohmichi | 5271b0f | 2015-08-10 07:53:27 +0000 | [diff] [blame] | 159 | self.assertRaises(lib_exc.NotFound, self.alt_client.reboot_server, |
Ken'ichi Ohmichi | 36b714c | 2015-12-09 08:12:47 +0000 | [diff] [blame] | 160 | self.server['id'], type='HARD') |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 161 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 162 | @test.idempotent_id('8a0bce51-cd00-480b-88ba-dbc7d8408a37') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 163 | def test_rebuild_server_for_alt_account_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 164 | # A rebuild request for another user's server should fail |
Ken'ichi Ohmichi | 5271b0f | 2015-08-10 07:53:27 +0000 | [diff] [blame] | 165 | self.assertRaises(lib_exc.NotFound, self.alt_client.rebuild_server, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 166 | self.server['id'], self.image_ref_alt) |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 167 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 168 | @test.idempotent_id('e4da647e-f982-4e61-9dad-1d1abebfb933') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 169 | def test_resize_server_for_alt_account_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 170 | # A resize request for another user's server should fail |
Ken'ichi Ohmichi | 5271b0f | 2015-08-10 07:53:27 +0000 | [diff] [blame] | 171 | self.assertRaises(lib_exc.NotFound, self.alt_client.resize_server, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 172 | self.server['id'], self.flavor_ref_alt) |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 173 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 174 | @test.idempotent_id('a9fe8112-0ffa-4902-b061-f892bd5fe0d3') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 175 | def test_create_image_for_alt_account_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 176 | # A create image request for another user's server should fail |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 177 | self.assertRaises(lib_exc.NotFound, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 178 | self.alt_images_client.create_image, |
Ken'ichi Ohmichi | 28f1867 | 2015-07-17 10:00:38 +0000 | [diff] [blame] | 179 | self.server['id'], name='testImage') |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 180 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 181 | @test.idempotent_id('95d445f6-babc-4f2e-aea3-aa24ec5e7f0d') |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 182 | def test_create_server_with_unauthorized_image(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 183 | # Server creation with another user's image should fail |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 184 | self.assertRaises(lib_exc.BadRequest, self.alt_client.create_server, |
Ken'ichi Ohmichi | f2d436e | 2015-09-03 01:13:16 +0000 | [diff] [blame] | 185 | name='test', imageRef=self.image['id'], |
| 186 | flavorRef=self.flavor_ref) |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 187 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 188 | @test.idempotent_id('acf8724b-142b-4044-82c3-78d31a533f24') |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 189 | def test_create_server_fails_when_tenant_incorrect(self): |
Sean Dague | f749cd7 | 2015-10-14 08:21:59 -0400 | [diff] [blame] | 190 | # BUG(sdague): this test should fail because of bad auth url, |
| 191 | # which means that when we run with a service catalog without |
| 192 | # project_id in the urls, it should fail to fail, and thus |
| 193 | # fail the test. It does not. |
| 194 | # |
| 195 | # The 400 BadRequest is clearly ambiguous, and something else |
| 196 | # is wrong about this request. This should be fixed. |
| 197 | # |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 198 | # A create server request should fail if the tenant id does not match |
| 199 | # the current user |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 200 | # Change the base URL to impersonate another user |
| 201 | self.alt_client.auth_provider.set_alt_auth_data( |
| 202 | request_part='url', |
| 203 | auth_data=self.client.auth_provider.auth_data |
| 204 | ) |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 205 | self.assertRaises(lib_exc.BadRequest, |
Ken'ichi Ohmichi | f2d436e | 2015-09-03 01:13:16 +0000 | [diff] [blame] | 206 | self.alt_client.create_server, name='test', |
| 207 | imageRef=self.image['id'], flavorRef=self.flavor_ref) |
rajalakshmi-ganesan | b74a11a | 2012-05-16 10:37:58 +0530 | [diff] [blame] | 208 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 209 | @test.idempotent_id('f03d1ded-7fd4-4d29-bc13-e2391f29c625') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 210 | def test_create_keypair_in_analt_user_tenant(self): |
Sean Dague | f749cd7 | 2015-10-14 08:21:59 -0400 | [diff] [blame] | 211 | """create keypair should not function for alternate tenant |
| 212 | |
| 213 | POST {alt_service_url}/os-keypairs |
| 214 | |
| 215 | Attempt to create a keypair against an alternate tenant by |
| 216 | changing using a different tenant's service url. This should |
| 217 | return a BadRequest. This tests basic tenant isolation protections. |
| 218 | |
| 219 | NOTE(sdague): if the environment does not use project_id in |
| 220 | the service urls, this test is not valid. Skip under these |
| 221 | conditions. |
| 222 | |
| 223 | """ |
| 224 | if self.alt_keypairs_client.base_url == self.keypairs_client.base_url: |
| 225 | raise self.skipException("Service urls don't include project_id") |
| 226 | |
Ken'ichi Ohmichi | 4937f56 | 2015-03-23 00:15:01 +0000 | [diff] [blame] | 227 | k_name = data_utils.rand_name('keypair') |
rajalakshmi-ganesan | b74a11a | 2012-05-16 10:37:58 +0530 | [diff] [blame] | 228 | try: |
| 229 | # Change the base URL to impersonate another user |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 230 | self.alt_keypairs_client.auth_provider.set_alt_auth_data( |
| 231 | request_part='url', |
| 232 | auth_data=self.keypairs_client.auth_provider.auth_data |
| 233 | ) |
rajalakshmi-ganesan | b74a11a | 2012-05-16 10:37:58 +0530 | [diff] [blame] | 234 | resp = {} |
| 235 | resp['status'] = None |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 236 | self.assertRaises(lib_exc.BadRequest, |
Ken'ichi Ohmichi | e364bce | 2015-07-17 10:27:59 +0000 | [diff] [blame] | 237 | self.alt_keypairs_client.create_keypair, |
| 238 | name=k_name) |
rajalakshmi-ganesan | b74a11a | 2012-05-16 10:37:58 +0530 | [diff] [blame] | 239 | finally: |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 240 | # Next request the base_url is back to normal |
Zhongyue Luo | e471d6e | 2012-09-17 17:02:43 +0800 | [diff] [blame] | 241 | if (resp['status'] is not None): |
David Kranz | 173f0e0 | 2015-02-06 13:47:57 -0500 | [diff] [blame] | 242 | self.alt_keypairs_client.delete_keypair(k_name) |
Giulio Fidente | 92f7719 | 2013-08-26 17:13:28 +0200 | [diff] [blame] | 243 | LOG.error("Create keypair request should not happen " |
Zhongyue Luo | 79d8d36 | 2012-09-25 13:49:27 +0800 | [diff] [blame] | 244 | "if the tenant id does not match the current user") |
rajalakshmi-ganesan | b74a11a | 2012-05-16 10:37:58 +0530 | [diff] [blame] | 245 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 246 | @test.idempotent_id('85bcdd8f-56b4-4868-ae56-63fbf6f7e405') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 247 | def test_get_keypair_of_alt_account_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 248 | # A GET request for another user's keypair should fail |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 249 | self.assertRaises(lib_exc.NotFound, |
Ken'ichi Ohmichi | 0943d9b | 2015-06-17 02:27:05 +0000 | [diff] [blame] | 250 | self.alt_keypairs_client.show_keypair, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 251 | self.keypairname) |
rajalakshmi-ganesan | b74a11a | 2012-05-16 10:37:58 +0530 | [diff] [blame] | 252 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 253 | @test.idempotent_id('6d841683-a8e0-43da-a1b8-b339f7692b61') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 254 | def test_delete_keypair_of_alt_account_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 255 | # A DELETE request for another user's keypair should fail |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 256 | self.assertRaises(lib_exc.NotFound, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 257 | self.alt_keypairs_client.delete_keypair, |
| 258 | self.keypairname) |
rajalakshmi-ganesan | 32f8db6 | 2012-05-18 19:13:40 +0530 | [diff] [blame] | 259 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 260 | @test.idempotent_id('fcb2e144-36e3-4dfb-9f9f-e72fcdec5656') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 261 | def test_get_image_for_alt_account_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 262 | # A GET request for an image on another user's account should fail |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 263 | self.assertRaises(lib_exc.NotFound, |
Ken'ichi Ohmichi | 5d41076 | 2015-05-22 01:10:03 +0000 | [diff] [blame] | 264 | self.alt_images_client.show_image, self.image['id']) |
rajalakshmi-ganesan | 32f8db6 | 2012-05-18 19:13:40 +0530 | [diff] [blame] | 265 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 266 | @test.idempotent_id('9facb962-f043-4a9d-b9ee-166a32dea098') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 267 | def test_delete_image_for_alt_account_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 268 | # A DELETE request for another user's image should fail |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 269 | self.assertRaises(lib_exc.NotFound, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 270 | self.alt_images_client.delete_image, |
| 271 | self.image['id']) |
rajalakshmi-ganesan | 184daad | 2012-05-18 14:47:38 +0530 | [diff] [blame] | 272 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 273 | @test.idempotent_id('752c917e-83be-499d-a422-3559127f7d3c') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 274 | def test_create_security_group_in_analt_user_tenant(self): |
Sean Dague | f749cd7 | 2015-10-14 08:21:59 -0400 | [diff] [blame] | 275 | """create security group should not function for alternate tenant |
| 276 | |
| 277 | POST {alt_service_url}/os-security-groups |
| 278 | |
| 279 | Attempt to create a security group against an alternate tenant |
| 280 | by changing using a different tenant's service url. This |
| 281 | should return a BadRequest. This tests basic tenant isolation |
| 282 | protections. |
| 283 | |
| 284 | NOTE(sdague): if the environment does not use project_id in |
| 285 | the service urls, this test is not valid. Skip under these |
| 286 | conditions. |
| 287 | |
| 288 | """ |
| 289 | if self.alt_security_client.base_url == self.security_client.base_url: |
| 290 | raise self.skipException("Service urls don't include project_id") |
| 291 | |
Ken'ichi Ohmichi | 4937f56 | 2015-03-23 00:15:01 +0000 | [diff] [blame] | 292 | s_name = data_utils.rand_name('security') |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 293 | s_description = data_utils.rand_name('security') |
rajalakshmi-ganesan | 184daad | 2012-05-18 14:47:38 +0530 | [diff] [blame] | 294 | try: |
| 295 | # Change the base URL to impersonate another user |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 296 | self.alt_security_client.auth_provider.set_alt_auth_data( |
| 297 | request_part='url', |
| 298 | auth_data=self.security_client.auth_provider.auth_data |
| 299 | ) |
rajalakshmi-ganesan | 184daad | 2012-05-18 14:47:38 +0530 | [diff] [blame] | 300 | resp = {} |
| 301 | resp['status'] = None |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 302 | self.assertRaises(lib_exc.BadRequest, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 303 | self.alt_security_client.create_security_group, |
Ken'ichi Ohmichi | 34563cc | 2015-07-21 00:53:17 +0000 | [diff] [blame] | 304 | name=s_name, description=s_description) |
rajalakshmi-ganesan | 184daad | 2012-05-18 14:47:38 +0530 | [diff] [blame] | 305 | finally: |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 306 | # Next request the base_url is back to normal |
Zhongyue Luo | e471d6e | 2012-09-17 17:02:43 +0800 | [diff] [blame] | 307 | if resp['status'] is not None: |
Monty Taylor | b2ca5ca | 2013-04-28 18:00:21 -0700 | [diff] [blame] | 308 | self.alt_security_client.delete_security_group(resp['id']) |
Giulio Fidente | 92f7719 | 2013-08-26 17:13:28 +0200 | [diff] [blame] | 309 | LOG.error("Create Security Group request should not happen if" |
rajalakshmi-ganesan | 184daad | 2012-05-18 14:47:38 +0530 | [diff] [blame] | 310 | "the tenant id does not match the current user") |
| 311 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 312 | @test.idempotent_id('9db3590f-4d15-4e5f-985e-b28514919a6f') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 313 | def test_get_security_group_of_alt_account_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 314 | # A GET request for another user's security group should fail |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 315 | self.assertRaises(lib_exc.NotFound, |
Ken'ichi Ohmichi | 217f2f3 | 2015-06-17 02:52:44 +0000 | [diff] [blame] | 316 | self.alt_security_client.show_security_group, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 317 | self.security_group['id']) |
rajalakshmi-ganesan | 184daad | 2012-05-18 14:47:38 +0530 | [diff] [blame] | 318 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 319 | @test.idempotent_id('155387a5-2bbc-4acf-ab06-698dae537ea5') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 320 | def test_delete_security_group_of_alt_account_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 321 | # A DELETE request for another user's security group should fail |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 322 | self.assertRaises(lib_exc.NotFound, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 323 | self.alt_security_client.delete_security_group, |
| 324 | self.security_group['id']) |
rajalakshmi-ganesan | 184daad | 2012-05-18 14:47:38 +0530 | [diff] [blame] | 325 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 326 | @test.idempotent_id('b2b76de0-210a-4089-b921-591c9ec552f6') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 327 | def test_create_security_group_rule_in_analt_user_tenant(self): |
Sean Dague | f749cd7 | 2015-10-14 08:21:59 -0400 | [diff] [blame] | 328 | """create security group rule should not function for alternate tenant |
| 329 | |
| 330 | POST {alt_service_url}/os-security-group-rules |
| 331 | |
| 332 | Attempt to create a security group rule against an alternate |
| 333 | tenant by changing using a different tenant's service |
| 334 | url. This should return a BadRequest. This tests basic tenant |
| 335 | isolation protections. |
| 336 | |
| 337 | NOTE(sdague): if the environment does not use project_id in |
| 338 | the service urls, this test is not valid. Skip under these |
| 339 | conditions. |
| 340 | |
| 341 | """ |
| 342 | if self.alt_security_client.base_url == self.security_client.base_url: |
| 343 | raise self.skipException("Service urls don't include project_id") |
| 344 | |
rajalakshmi-ganesan | 184daad | 2012-05-18 14:47:38 +0530 | [diff] [blame] | 345 | parent_group_id = self.security_group['id'] |
| 346 | ip_protocol = 'icmp' |
| 347 | from_port = -1 |
| 348 | to_port = -1 |
rajalakshmi-ganesan | 184daad | 2012-05-18 14:47:38 +0530 | [diff] [blame] | 349 | try: |
| 350 | # Change the base URL to impersonate another user |
Ken'ichi Ohmichi | 685cd17 | 2015-07-13 01:29:57 +0000 | [diff] [blame] | 351 | self.alt_rule_client.auth_provider.set_alt_auth_data( |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 352 | request_part='url', |
Ken'ichi Ohmichi | 685cd17 | 2015-07-13 01:29:57 +0000 | [diff] [blame] | 353 | auth_data=self.rule_client.auth_provider.auth_data |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 354 | ) |
rajalakshmi-ganesan | 184daad | 2012-05-18 14:47:38 +0530 | [diff] [blame] | 355 | resp = {} |
| 356 | resp['status'] = None |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 357 | self.assertRaises(lib_exc.BadRequest, |
Ken'ichi Ohmichi | 685cd17 | 2015-07-13 01:29:57 +0000 | [diff] [blame] | 358 | self.alt_rule_client. |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 359 | create_security_group_rule, |
Ken'ichi Ohmichi | eb7eeec | 2015-07-21 01:00:06 +0000 | [diff] [blame] | 360 | parent_group_id=parent_group_id, |
| 361 | ip_protocol=ip_protocol, |
| 362 | from_port=from_port, to_port=to_port) |
rajalakshmi-ganesan | 184daad | 2012-05-18 14:47:38 +0530 | [diff] [blame] | 363 | finally: |
Andrea Frittoli | 8bbdb16 | 2014-01-06 11:06:13 +0000 | [diff] [blame] | 364 | # Next request the base_url is back to normal |
Zhongyue Luo | e471d6e | 2012-09-17 17:02:43 +0800 | [diff] [blame] | 365 | if resp['status'] is not None: |
Ken'ichi Ohmichi | 685cd17 | 2015-07-13 01:29:57 +0000 | [diff] [blame] | 366 | self.alt_rule_client.delete_security_group_rule(resp['id']) |
Giulio Fidente | 92f7719 | 2013-08-26 17:13:28 +0200 | [diff] [blame] | 367 | LOG.error("Create security group rule request should not " |
rajalakshmi-ganesan | 184daad | 2012-05-18 14:47:38 +0530 | [diff] [blame] | 368 | "happen if the tenant id does not match the" |
| 369 | " current user") |
| 370 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 371 | @test.idempotent_id('c6044177-37ef-4ce4-b12c-270ddf26d7da') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 372 | def test_delete_security_group_rule_of_alt_account_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 373 | # A DELETE request for another user's security group rule |
| 374 | # should fail |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 375 | self.assertRaises(lib_exc.NotFound, |
Ken'ichi Ohmichi | 685cd17 | 2015-07-13 01:29:57 +0000 | [diff] [blame] | 376 | self.alt_rule_client.delete_security_group_rule, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 377 | self.rule['id']) |
rajalakshmi-ganesan | 929a32a | 2012-05-29 18:00:25 +0530 | [diff] [blame] | 378 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 379 | @test.idempotent_id('c5f52351-53d9-4fc9-83e5-917f7f5e3d71') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 380 | def test_set_metadata_of_alt_account_server_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 381 | # A set metadata for another user's server should fail |
rajalakshmi-ganesan | 929a32a | 2012-05-29 18:00:25 +0530 | [diff] [blame] | 382 | req_metadata = {'meta1': 'data1', 'meta2': 'data2'} |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 383 | self.assertRaises(lib_exc.NotFound, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 384 | self.alt_client.set_server_metadata, |
| 385 | self.server['id'], |
| 386 | req_metadata) |
rajalakshmi-ganesan | 929a32a | 2012-05-29 18:00:25 +0530 | [diff] [blame] | 387 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 388 | @test.idempotent_id('fb6f51e9-df15-4939-898d-1aca38c258f0') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 389 | def test_set_metadata_of_alt_account_image_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 390 | # A set metadata for another user's image should fail |
rajalakshmi-ganesan | 929a32a | 2012-05-29 18:00:25 +0530 | [diff] [blame] | 391 | req_metadata = {'meta1': 'value1', 'meta2': 'value2'} |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 392 | self.assertRaises(lib_exc.NotFound, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 393 | self.alt_images_client.set_image_metadata, |
| 394 | self.image['id'], req_metadata) |
rajalakshmi-ganesan | 929a32a | 2012-05-29 18:00:25 +0530 | [diff] [blame] | 395 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 396 | @test.idempotent_id('dea1936a-473d-49f2-92ad-97bb7aded22e') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 397 | def test_get_metadata_of_alt_account_server_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 398 | # A get metadata for another user's server should fail |
rajalakshmi-ganesan | 929a32a | 2012-05-29 18:00:25 +0530 | [diff] [blame] | 399 | req_metadata = {'meta1': 'data1'} |
Zhongyue Luo | e0884a3 | 2012-09-25 17:24:17 +0800 | [diff] [blame] | 400 | self.client.set_server_metadata(self.server['id'], req_metadata) |
hi2suresh | 31bb7cb | 2013-03-14 04:53:49 +0000 | [diff] [blame] | 401 | self.addCleanup(self.client.delete_server_metadata_item, |
| 402 | self.server['id'], 'meta1') |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 403 | self.assertRaises(lib_exc.NotFound, |
Ken'ichi Ohmichi | 277d188 | 2015-11-20 00:44:06 +0000 | [diff] [blame] | 404 | self.alt_client.show_server_metadata_item, |
hi2suresh | 31bb7cb | 2013-03-14 04:53:49 +0000 | [diff] [blame] | 405 | self.server['id'], 'meta1') |
rajalakshmi-ganesan | 929a32a | 2012-05-29 18:00:25 +0530 | [diff] [blame] | 406 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 407 | @test.idempotent_id('16b2d724-0d3b-4216-a9fa-97bd4d9cf670') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 408 | def test_get_metadata_of_alt_account_image_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 409 | # A get metadata for another user's image should fail |
rajalakshmi-ganesan | 929a32a | 2012-05-29 18:00:25 +0530 | [diff] [blame] | 410 | req_metadata = {'meta1': 'value1'} |
hi2suresh | d0e2412 | 2013-03-15 03:06:53 +0000 | [diff] [blame] | 411 | self.addCleanup(self.images_client.delete_image_metadata_item, |
| 412 | self.image['id'], 'meta1') |
rajalakshmi-ganesan | 929a32a | 2012-05-29 18:00:25 +0530 | [diff] [blame] | 413 | self.images_client.set_image_metadata(self.image['id'], |
Zhongyue Luo | 79d8d36 | 2012-09-25 13:49:27 +0800 | [diff] [blame] | 414 | req_metadata) |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 415 | self.assertRaises(lib_exc.NotFound, |
Ken'ichi Ohmichi | 0943d9b | 2015-06-17 02:27:05 +0000 | [diff] [blame] | 416 | self.alt_images_client.show_image_metadata_item, |
hi2suresh | d0e2412 | 2013-03-15 03:06:53 +0000 | [diff] [blame] | 417 | self.image['id'], 'meta1') |
rajalakshmi-ganesan | 929a32a | 2012-05-29 18:00:25 +0530 | [diff] [blame] | 418 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 419 | @test.idempotent_id('79531e2e-e721-493c-8b30-a35db36fdaa6') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 420 | def test_delete_metadata_of_alt_account_server_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 421 | # A delete metadata for another user's server should fail |
rajalakshmi-ganesan | 929a32a | 2012-05-29 18:00:25 +0530 | [diff] [blame] | 422 | req_metadata = {'meta1': 'data1'} |
hi2suresh | d0e2412 | 2013-03-15 03:06:53 +0000 | [diff] [blame] | 423 | self.addCleanup(self.client.delete_server_metadata_item, |
| 424 | self.server['id'], 'meta1') |
Zhongyue Luo | e0884a3 | 2012-09-25 17:24:17 +0800 | [diff] [blame] | 425 | self.client.set_server_metadata(self.server['id'], req_metadata) |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 426 | self.assertRaises(lib_exc.NotFound, |
hi2suresh | d0e2412 | 2013-03-15 03:06:53 +0000 | [diff] [blame] | 427 | self.alt_client.delete_server_metadata_item, |
| 428 | self.server['id'], 'meta1') |
rajalakshmi-ganesan | 929a32a | 2012-05-29 18:00:25 +0530 | [diff] [blame] | 429 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 430 | @test.idempotent_id('a5175dcf-cef8-43d6-9b77-3cb707d62e94') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 431 | def test_delete_metadata_of_alt_account_image_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 432 | # A delete metadata for another user's image should fail |
rajalakshmi-ganesan | 929a32a | 2012-05-29 18:00:25 +0530 | [diff] [blame] | 433 | req_metadata = {'meta1': 'data1'} |
hi2suresh | d0e2412 | 2013-03-15 03:06:53 +0000 | [diff] [blame] | 434 | self.addCleanup(self.images_client.delete_image_metadata_item, |
| 435 | self.image['id'], 'meta1') |
rajalakshmi-ganesan | 929a32a | 2012-05-29 18:00:25 +0530 | [diff] [blame] | 436 | self.images_client.set_image_metadata(self.image['id'], |
| 437 | req_metadata) |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 438 | self.assertRaises(lib_exc.NotFound, |
hi2suresh | d0e2412 | 2013-03-15 03:06:53 +0000 | [diff] [blame] | 439 | self.alt_images_client.delete_image_metadata_item, |
| 440 | self.image['id'], 'meta1') |
rajalakshmi-ganesan | 72ea31a | 2012-05-25 11:59:10 +0530 | [diff] [blame] | 441 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 442 | @test.idempotent_id('b0c1e7a0-8853-40fd-8384-01f93d116cae') |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 443 | def test_get_console_output_of_alt_account_server_fails(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 444 | # A Get Console Output for another user's server should fail |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 445 | self.assertRaises(lib_exc.NotFound, |
Chris Yeoh | 8b4eaa5 | 2013-02-06 18:03:10 +1030 | [diff] [blame] | 446 | self.alt_client.get_console_output, |
Ken'ichi Ohmichi | bf4766a | 2015-12-09 07:48:43 +0000 | [diff] [blame] | 447 | self.server['id'], length=10) |