1
# Copyright 2014 OpenStack Foundation
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
8
# http://www.apache.org/licenses/LICENSE-2.0
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
16
from tempest.api.share import base
17
from tempest import clients_share as clients
18
from tempest.common.utils import data_utils
19
from tempest import exceptions
20
from tempest import test
23
class ExtraSpecsAdminNegativeTest(base.BaseSharesAdminTest):
25
def _create_volume_type(self):
26
name = data_utils.rand_name("unique_vt_name")
27
extra_specs = {"key": "value", }
28
__, vt = self.create_volume_type(name, extra_specs=extra_specs)
33
super(ExtraSpecsAdminNegativeTest, cls).setUpClass()
34
cls.member_shares_client = clients.Manager().shares_client
36
@test.attr(type=["gate", "smoke", ])
37
def test_try_create_extra_specs_with_user(self):
38
vt = self._create_volume_type()
40
exceptions.Unauthorized,
41
self.member_shares_client.create_volume_type_extra_specs,
42
vt["id"], {"key": "new_value"})
44
@test.attr(type=["gate", "smoke", ])
45
def test_try_list_extra_specs_with_user(self):
46
vt = self._create_volume_type()
48
exceptions.Unauthorized,
49
self.member_shares_client.list_volume_types_extra_specs, vt["id"])
51
@test.attr(type=["gate", "smoke", ])
52
def test_try_get_extra_spec_with_user(self):
53
vt = self._create_volume_type()
55
exceptions.Unauthorized,
56
self.member_shares_client.get_volume_type_extra_spec,
59
@test.attr(type=["gate", "smoke", ])
60
def test_try_get_extra_specs_with_user(self):
61
vt = self._create_volume_type()
63
exceptions.Unauthorized,
64
self.member_shares_client.get_volume_type_extra_specs, vt["id"])
66
@test.attr(type=["gate", "smoke", ])
67
def test_try_update_extra_spec_with_user(self):
68
vt = self._create_volume_type()
70
exceptions.Unauthorized,
71
self.member_shares_client.update_volume_type_extra_spec,
72
vt["id"], "key", "new_value")
74
@test.attr(type=["gate", "smoke", ])
75
def test_try_update_extra_specs_with_user(self):
76
vt = self._create_volume_type()
78
exceptions.Unauthorized,
79
self.member_shares_client.update_volume_type_extra_specs,
80
vt["id"], {"key": "new_value"})
82
@test.attr(type=["gate", "smoke", ])
83
def test_try_delete_extra_specs_with_user(self):
84
vt = self._create_volume_type()
86
exceptions.Unauthorized,
87
self.member_shares_client.delete_volume_type_extra_spec,
90
@test.attr(type=["gate", "smoke", ])
91
def test_try_set_too_long_key(self):
92
too_big_key = "k" * 256
93
vt = self._create_volume_type()
94
self.assertRaises(exceptions.BadRequest,
95
self.shares_client.create_volume_type_extra_specs,
96
vt["id"], {too_big_key: "value"})
98
@test.attr(type=["gate", "smoke", ])
99
def test_try_set_too_long_value_with_creation(self):
100
too_big_value = "v" * 256
101
vt = self._create_volume_type()
102
self.assertRaises(exceptions.BadRequest,
103
self.shares_client.create_volume_type_extra_specs,
104
vt["id"], {"key": too_big_value})
106
@test.attr(type=["gate", "smoke", ])
107
def test_try_set_too_long_value_with_update(self):
108
too_big_value = "v" * 256
109
vt = self._create_volume_type()
110
resp, body = self.shares_client.create_volume_type_extra_specs(
111
vt["id"], {"key": "value"})
112
self.assertIn(int(resp["status"]), test.HTTP_SUCCESS)
113
self.assertRaises(exceptions.BadRequest,
114
self.shares_client.update_volume_type_extra_specs,
115
vt["id"], {"key": too_big_value})
117
@test.attr(type=["gate", "smoke", ])
118
def test_try_set_too_long_value_with_update_of_one_key(self):
119
too_big_value = "v" * 256
120
vt = self._create_volume_type()
121
resp, body = self.shares_client.create_volume_type_extra_specs(
122
vt["id"], {"key": "value"})
123
self.assertIn(int(resp["status"]), test.HTTP_SUCCESS)
124
self.assertRaises(exceptions.BadRequest,
125
self.shares_client.update_volume_type_extra_spec,
126
vt["id"], "key", too_big_value)
128
@test.attr(type=["gate", "smoke", ])
129
def test_try_list_es_with_empty_vol_type_id(self):
130
self.assertRaises(exceptions.NotFound,
131
self.shares_client.list_volume_types_extra_specs, "")
133
@test.attr(type=["gate", "smoke", ])
134
def test_try_list_es_with_invalid_vol_type_id(self):
135
self.assertRaises(exceptions.NotFound,
136
self.shares_client.list_volume_types_extra_specs,
137
data_utils.rand_name("fake"))
139
@test.attr(type=["gate", "smoke", ])
140
def test_try_create_es_with_empty_vol_type_id(self):
141
self.assertRaises(exceptions.NotFound,
142
self.shares_client.create_volume_type_extra_specs,
143
"", {"key1": "value1", })
145
@test.attr(type=["gate", "smoke", ])
146
def test_try_create_es_with_invalid_vol_type_id(self):
147
self.assertRaises(exceptions.NotFound,
148
self.shares_client.create_volume_type_extra_specs,
149
data_utils.rand_name("fake"), {"key1": "value1", })
151
@test.attr(type=["gate", "smoke", ])
152
def test_try_create_es_with_empty_specs(self):
153
vt = self._create_volume_type()
154
self.assertRaises(exceptions.BadRequest,
155
self.shares_client.create_volume_type_extra_specs,
158
@test.attr(type=["gate", "smoke", ])
159
def test_try_create_es_with_invalid_specs(self):
160
vt = self._create_volume_type()
161
self.assertRaises(exceptions.BadRequest,
162
self.shares_client.create_volume_type_extra_specs,
163
vt["id"], {"": "value_with_empty_key"})
165
@test.attr(type=["gate", "smoke", ])
166
def test_try_get_extra_spec_with_empty_key(self):
167
vt = self._create_volume_type()
168
self.assertRaises(exceptions.NotFound,
169
self.shares_client.get_volume_type_extra_spec,
172
@test.attr(type=["gate", "smoke", ])
173
def test_try_get_extra_spec_with_invalid_key(self):
174
vt = self._create_volume_type()
175
self.assertRaises(exceptions.NotFound,
176
self.shares_client.get_volume_type_extra_spec,
177
vt["id"], data_utils.rand_name("fake"))
179
@test.attr(type=["gate", "smoke", ])
180
def test_try_get_extra_specs_with_empty_vol_type_id(self):
181
self.assertRaises(exceptions.NotFound,
182
self.shares_client.get_volume_type_extra_specs,
185
@test.attr(type=["gate", "smoke", ])
186
def test_try_get_extra_specs_with_invalid_vol_type_id(self):
187
self.assertRaises(exceptions.NotFound,
188
self.shares_client.get_volume_type_extra_specs,
189
data_utils.rand_name("fake"))
191
@test.attr(type=["gate", "smoke", ])
192
def test_try_delete_es_key_with_empty_vol_type_id(self):
193
self.assertRaises(exceptions.NotFound,
194
self.shares_client.delete_volume_type_extra_spec,
197
@test.attr(type=["gate", "smoke", ])
198
def test_try_delete_es_key_with_invalid_vol_type_id(self):
199
self.assertRaises(exceptions.NotFound,
200
self.shares_client.delete_volume_type_extra_spec,
201
data_utils.rand_name("fake"), "key", )
203
@test.attr(type=["gate", "smoke", ])
204
def test_try_delete_with_invalid_key(self):
205
vt = self._create_volume_type()
206
self.assertRaises(exceptions.NotFound,
207
self.shares_client.delete_volume_type_extra_spec,
208
vt["id"], data_utils.rand_name("fake"))
210
@test.attr(type=["gate", "smoke", ])
211
def test_try_update_spec_with_empty_vol_type_id(self):
212
self.assertRaises(exceptions.NotFound,
213
self.shares_client.update_volume_type_extra_spec,
214
"", "key", "new_value")
216
@test.attr(type=["gate", "smoke", ])
217
def test_try_update_spec_with_invalid_vol_type_id(self):
218
self.assertRaises(exceptions.NotFound,
219
self.shares_client.update_volume_type_extra_spec,
220
data_utils.rand_name("fake"), "key", "new_value")
222
@test.attr(type=["gate", "smoke", ])
223
def test_try_update_spec_with_empty_key(self):
224
vt = self._create_volume_type()
225
self.assertRaises(exceptions.NotFound,
226
self.shares_client.update_volume_type_extra_spec,
227
vt["id"], "", "new_value")
229
@test.attr(type=["gate", "smoke", ])
230
def test_try_update_with_invalid_vol_type_id(self):
231
self.assertRaises(exceptions.NotFound,
232
self.shares_client.update_volume_type_extra_specs,
233
data_utils.rand_name("fake"), {"key": "new_value"})
235
@test.attr(type=["gate", "smoke", ])
236
def test_try_update_with_invalid_specs(self):
237
vt = self._create_volume_type()
238
self.assertRaises(exceptions.BadRequest,
239
self.shares_client.update_volume_type_extra_specs,
240
vt["id"], {"": "new_value"})