blob: 698bac0b72cb532189ed477618d29ed9d4e474b6 [file] [log] [blame]
ivan-zhu3867a1c2013-10-11 14:16:58 +08001# Copyright 2013 IBM Corp.
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
Masayuki Igawabfa07602015-01-20 18:47:17 +090016from tempest_lib import exceptions as lib_exc
17
ivan-zhu3867a1c2013-10-11 14:16:58 +080018from tempest.api.image import base
Eiichi Aikawa9012f462014-03-05 16:43:32 +090019from tempest import test
ivan-zhu3867a1c2013-10-11 14:16:58 +080020
21
22class CreateDeleteImagesNegativeTest(base.BaseV1ImageTest):
23 """Here are negative tests for the deletion and creation of images."""
24
Eiichi Aikawa9012f462014-03-05 16:43:32 +090025 @test.attr(type=['negative', 'gate'])
ivan-zhu3867a1c2013-10-11 14:16:58 +080026 def test_register_with_invalid_container_format(self):
27 # Negative tests for invalid data supplied to POST /images
Masayuki Igawa4b29e472015-02-16 10:41:54 +090028 self.assertRaises(lib_exc.BadRequest, self.client.create_image,
ivan-zhu3867a1c2013-10-11 14:16:58 +080029 'test', 'wrong', 'vhd')
30
Eiichi Aikawa9012f462014-03-05 16:43:32 +090031 @test.attr(type=['negative', 'gate'])
ivan-zhu3867a1c2013-10-11 14:16:58 +080032 def test_register_with_invalid_disk_format(self):
Masayuki Igawa4b29e472015-02-16 10:41:54 +090033 self.assertRaises(lib_exc.BadRequest, self.client.create_image,
ivan-zhu3867a1c2013-10-11 14:16:58 +080034 'test', 'bare', 'wrong')
35
Eiichi Aikawa9012f462014-03-05 16:43:32 +090036 @test.attr(type=['negative', 'gate'])
ivan-zhu3867a1c2013-10-11 14:16:58 +080037 def test_delete_image_with_invalid_image_id(self):
38 # An image should not be deleted with invalid image id
Masayuki Igawabfa07602015-01-20 18:47:17 +090039 self.assertRaises(lib_exc.NotFound, self.client.delete_image,
ivan-zhu3867a1c2013-10-11 14:16:58 +080040 '!@$%^&*()')
41
Eiichi Aikawa9012f462014-03-05 16:43:32 +090042 @test.attr(type=['negative', 'gate'])
ivan-zhu3867a1c2013-10-11 14:16:58 +080043 def test_delete_non_existent_image(self):
44 # Return an error while trying to delete a non-existent image
45
46 non_existent_image_id = '11a22b9-12a9-5555-cc11-00ab112223fa'
Masayuki Igawabfa07602015-01-20 18:47:17 +090047 self.assertRaises(lib_exc.NotFound, self.client.delete_image,
ivan-zhu3867a1c2013-10-11 14:16:58 +080048 non_existent_image_id)
49
Eiichi Aikawa9012f462014-03-05 16:43:32 +090050 @test.attr(type=['negative', 'gate'])
ivan-zhu3867a1c2013-10-11 14:16:58 +080051 def test_delete_image_blank_id(self):
52 # Return an error while trying to delete an image with blank Id
Masayuki Igawabfa07602015-01-20 18:47:17 +090053 self.assertRaises(lib_exc.NotFound, self.client.delete_image, '')
ivan-zhu3867a1c2013-10-11 14:16:58 +080054
Eiichi Aikawa9012f462014-03-05 16:43:32 +090055 @test.attr(type=['negative', 'gate'])
ivan-zhu3867a1c2013-10-11 14:16:58 +080056 def test_delete_image_non_hex_string_id(self):
57 # Return an error while trying to delete an image with non hex id
58 image_id = '11a22b9-120q-5555-cc11-00ab112223gj'
Masayuki Igawabfa07602015-01-20 18:47:17 +090059 self.assertRaises(lib_exc.NotFound, self.client.delete_image,
ivan-zhu3867a1c2013-10-11 14:16:58 +080060 image_id)
61
Eiichi Aikawa9012f462014-03-05 16:43:32 +090062 @test.attr(type=['negative', 'gate'])
ivan-zhu3867a1c2013-10-11 14:16:58 +080063 def test_delete_image_negative_image_id(self):
64 # Return an error while trying to delete an image with negative id
Masayuki Igawabfa07602015-01-20 18:47:17 +090065 self.assertRaises(lib_exc.NotFound, self.client.delete_image, -1)
ivan-zhu3867a1c2013-10-11 14:16:58 +080066
Eiichi Aikawa9012f462014-03-05 16:43:32 +090067 @test.attr(type=['negative', 'gate'])
ivan-zhu3867a1c2013-10-11 14:16:58 +080068 def test_delete_image_id_is_over_35_character_limit(self):
69 # Return an error while trying to delete image with id over limit
Masayuki Igawabfa07602015-01-20 18:47:17 +090070 self.assertRaises(lib_exc.NotFound, self.client.delete_image,
ivan-zhu3867a1c2013-10-11 14:16:58 +080071 '11a22b9-12a9-5555-cc11-00ab112223fa-3fac')