blob: 1bcf1207d24d60ae80c0577041cdcc1deb0ce649 [file] [log] [blame]
ivan-zhu3867a1c2013-10-11 14:16:58 +08001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2013 IBM Corp.
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
18from tempest.api.image import base
19from tempest import exceptions
20from tempest.test import attr
21
22
23class CreateDeleteImagesNegativeTest(base.BaseV1ImageTest):
24 """Here are negative tests for the deletion and creation of images."""
25
26 @attr(type=['negative', 'gate'])
27 def test_register_with_invalid_container_format(self):
28 # Negative tests for invalid data supplied to POST /images
29 self.assertRaises(exceptions.BadRequest, self.client.create_image,
30 'test', 'wrong', 'vhd')
31
32 @attr(type=['negative', 'gate'])
33 def test_register_with_invalid_disk_format(self):
34 self.assertRaises(exceptions.BadRequest, self.client.create_image,
35 'test', 'bare', 'wrong')
36
37 @attr(type=['negative', 'gate'])
38 def test_delete_image_with_invalid_image_id(self):
39 # An image should not be deleted with invalid image id
40 self.assertRaises(exceptions.NotFound, self.client.delete_image,
41 '!@$%^&*()')
42
43 @attr(type=['negative', 'gate'])
44 def test_delete_non_existent_image(self):
45 # Return an error while trying to delete a non-existent image
46
47 non_existent_image_id = '11a22b9-12a9-5555-cc11-00ab112223fa'
48 self.assertRaises(exceptions.NotFound, self.client.delete_image,
49 non_existent_image_id)
50
51 @attr(type=['negative', 'gate'])
52 def test_delete_image_blank_id(self):
53 # Return an error while trying to delete an image with blank Id
54 self.assertRaises(exceptions.NotFound, self.client.delete_image, '')
55
56 @attr(type=['negative', 'gate'])
57 def test_delete_image_non_hex_string_id(self):
58 # Return an error while trying to delete an image with non hex id
59 image_id = '11a22b9-120q-5555-cc11-00ab112223gj'
60 self.assertRaises(exceptions.NotFound, self.client.delete_image,
61 image_id)
62
63 @attr(type=['negative', 'gate'])
64 def test_delete_image_negative_image_id(self):
65 # Return an error while trying to delete an image with negative id
66 self.assertRaises(exceptions.NotFound, self.client.delete_image, -1)
67
68 @attr(type=['negative', 'gate'])
69 def test_delete_image_id_is_over_35_character_limit(self):
70 # Return an error while trying to delete image with id over limit
71 self.assertRaises(exceptions.NotFound, self.client.delete_image,
72 '11a22b9-12a9-5555-cc11-00ab112223fa-3fac')