~ubuntu-branches/ubuntu/vivid/manila/vivid-proposed

« back to all changes in this revision

Viewing changes to contrib/tempest/tempest/api/share/admin/test_volume_types_extra_specs_negative.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-01-15 11:55:33 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20150115115533-yshssd76s2uj3ybx
Tags: 2015.1~b1-0ubuntu1
* New upstream release:
  - d/control: Add new dependencies.
  - Install any new binaries and configuration to common package.
* d/watch: Update to use tarballs.openstack.org.
* d/control,compat: Bump debhelper compat level to 9.
* d/control: Bumped Standards-Version to 3.9.6, no changes.
* Systemd enablement:
  - d/rules,control: Enable use of dh-systemd and openstack-pkg-tools.
  - d/*.init.in: Write templates for generation of init, service and
    upstart configurations.
  - d/*.upstart: Drop in preference to above.
* d/*.logrotate: Move to single logrotate configuration in common package.
* d/rules: Ensure unit test suite failure fails package build.
* d/p/pep-0476.patch: Deal with SSL certification chain verification unit
  test failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2014 OpenStack Foundation
 
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
 
 
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
 
21
 
 
22
 
 
23
class ExtraSpecsAdminNegativeTest(base.BaseSharesAdminTest):
 
24
 
 
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)
 
29
        return vt
 
30
 
 
31
    @classmethod
 
32
    def setUpClass(cls):
 
33
        super(ExtraSpecsAdminNegativeTest, cls).setUpClass()
 
34
        cls.member_shares_client = clients.Manager().shares_client
 
35
 
 
36
    @test.attr(type=["gate", "smoke", ])
 
37
    def test_try_create_extra_specs_with_user(self):
 
38
        vt = self._create_volume_type()
 
39
        self.assertRaises(
 
40
            exceptions.Unauthorized,
 
41
            self.member_shares_client.create_volume_type_extra_specs,
 
42
            vt["id"], {"key": "new_value"})
 
43
 
 
44
    @test.attr(type=["gate", "smoke", ])
 
45
    def test_try_list_extra_specs_with_user(self):
 
46
        vt = self._create_volume_type()
 
47
        self.assertRaises(
 
48
            exceptions.Unauthorized,
 
49
            self.member_shares_client.list_volume_types_extra_specs, vt["id"])
 
50
 
 
51
    @test.attr(type=["gate", "smoke", ])
 
52
    def test_try_get_extra_spec_with_user(self):
 
53
        vt = self._create_volume_type()
 
54
        self.assertRaises(
 
55
            exceptions.Unauthorized,
 
56
            self.member_shares_client.get_volume_type_extra_spec,
 
57
            vt["id"], "key")
 
58
 
 
59
    @test.attr(type=["gate", "smoke", ])
 
60
    def test_try_get_extra_specs_with_user(self):
 
61
        vt = self._create_volume_type()
 
62
        self.assertRaises(
 
63
            exceptions.Unauthorized,
 
64
            self.member_shares_client.get_volume_type_extra_specs, vt["id"])
 
65
 
 
66
    @test.attr(type=["gate", "smoke", ])
 
67
    def test_try_update_extra_spec_with_user(self):
 
68
        vt = self._create_volume_type()
 
69
        self.assertRaises(
 
70
            exceptions.Unauthorized,
 
71
            self.member_shares_client.update_volume_type_extra_spec,
 
72
            vt["id"], "key", "new_value")
 
73
 
 
74
    @test.attr(type=["gate", "smoke", ])
 
75
    def test_try_update_extra_specs_with_user(self):
 
76
        vt = self._create_volume_type()
 
77
        self.assertRaises(
 
78
            exceptions.Unauthorized,
 
79
            self.member_shares_client.update_volume_type_extra_specs,
 
80
            vt["id"], {"key": "new_value"})
 
81
 
 
82
    @test.attr(type=["gate", "smoke", ])
 
83
    def test_try_delete_extra_specs_with_user(self):
 
84
        vt = self._create_volume_type()
 
85
        self.assertRaises(
 
86
            exceptions.Unauthorized,
 
87
            self.member_shares_client.delete_volume_type_extra_spec,
 
88
            vt["id"], "key")
 
89
 
 
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"})
 
97
 
 
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})
 
105
 
 
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})
 
116
 
 
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)
 
127
 
 
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, "")
 
132
 
 
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"))
 
138
 
 
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", })
 
144
 
 
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", })
 
150
 
 
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,
 
156
                          vt["id"], "")
 
157
 
 
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"})
 
164
 
 
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,
 
170
                          vt["id"], "")
 
171
 
 
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"))
 
178
 
 
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,
 
183
                          "")
 
184
 
 
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"))
 
190
 
 
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,
 
195
                          "", "key", )
 
196
 
 
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", )
 
202
 
 
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"))
 
209
 
 
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")
 
215
 
 
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")
 
221
 
 
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")
 
228
 
 
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"})
 
234
 
 
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"})