blob: 9f0ad2d831ce9ef5511feefc1305b4b521da945d [file] [log] [blame]
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +05301# Copyright 2013 OpenStack Foundation
2# All Rights Reserved.
3# Copyright 2013 IBM Corp.
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License. You may obtain
7# a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations
15# under the License.
16
17import uuid
18
Masayuki Igawabfa07602015-01-20 18:47:17 +090019from tempest_lib import exceptions as lib_exc
20
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053021from tempest.api.image import base
Eiichi Aikawa9012f462014-03-05 16:43:32 +090022from tempest import test
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053023
24
25class ImagesNegativeTest(base.BaseV2ImageTest):
26
27 """
28 here we have -ve tests for get_image and delete_image api
29
30 Tests
31 ** get non-existent image
32 ** get image with image_id=NULL
33 ** get the deleted image
34 ** delete non-existent image
35 ** delete rimage with image_id=NULL
36 ** delete the deleted image
37 """
38
Eiichi Aikawa9012f462014-03-05 16:43:32 +090039 @test.attr(type=['negative', 'gate'])
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053040 def test_get_non_existent_image(self):
41 # get the non-existent image
42 non_existent_id = str(uuid.uuid4())
Masayuki Igawabfa07602015-01-20 18:47:17 +090043 self.assertRaises(lib_exc.NotFound, self.client.get_image,
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053044 non_existent_id)
45
Eiichi Aikawa9012f462014-03-05 16:43:32 +090046 @test.attr(type=['negative', 'gate'])
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053047 def test_get_image_null_id(self):
48 # get image with image_id = NULL
49 image_id = ""
Masayuki Igawabfa07602015-01-20 18:47:17 +090050 self.assertRaises(lib_exc.NotFound, self.client.get_image, image_id)
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053051
Eiichi Aikawa9012f462014-03-05 16:43:32 +090052 @test.attr(type=['negative', 'gate'])
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053053 def test_get_delete_deleted_image(self):
54 # get and delete the deleted image
55 # create and delete image
David Kranz34f18782015-01-06 13:43:55 -050056 body = self.client.create_image(name='test',
57 container_format='bare',
58 disk_format='raw')
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053059 image_id = body['id']
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053060 self.client.delete_image(image_id)
61 self.client.wait_for_resource_deletion(image_id)
62
63 # get the deleted image
Masayuki Igawabfa07602015-01-20 18:47:17 +090064 self.assertRaises(lib_exc.NotFound, self.client.get_image, image_id)
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053065
66 # delete the deleted image
Masayuki Igawabfa07602015-01-20 18:47:17 +090067 self.assertRaises(lib_exc.NotFound, self.client.delete_image,
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053068 image_id)
69
Eiichi Aikawa9012f462014-03-05 16:43:32 +090070 @test.attr(type=['negative', 'gate'])
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053071 def test_delete_non_existing_image(self):
72 # delete non-existent image
73 non_existent_image_id = str(uuid.uuid4())
Masayuki Igawabfa07602015-01-20 18:47:17 +090074 self.assertRaises(lib_exc.NotFound, self.client.delete_image,
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053075 non_existent_image_id)
76
Eiichi Aikawa9012f462014-03-05 16:43:32 +090077 @test.attr(type=['negative', 'gate'])
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053078 def test_delete_image_null_id(self):
79 # delete image with image_id=NULL
80 image_id = ""
Masayuki Igawabfa07602015-01-20 18:47:17 +090081 self.assertRaises(lib_exc.NotFound, self.client.delete_image,
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053082 image_id)
Hoisaleshwara Madan V S7cba1082013-11-26 12:43:04 +053083
Eiichi Aikawa9012f462014-03-05 16:43:32 +090084 @test.attr(type=['negative', 'gate'])
Hoisaleshwara Madan V S7cba1082013-11-26 12:43:04 +053085 def test_register_with_invalid_container_format(self):
86 # Negative tests for invalid data supplied to POST /images
Masayuki Igawa4b29e472015-02-16 10:41:54 +090087 self.assertRaises(lib_exc.BadRequest, self.client.create_image,
Hoisaleshwara Madan V S7cba1082013-11-26 12:43:04 +053088 'test', 'wrong', 'vhd')
89
Eiichi Aikawa9012f462014-03-05 16:43:32 +090090 @test.attr(type=['negative', 'gate'])
Hoisaleshwara Madan V S7cba1082013-11-26 12:43:04 +053091 def test_register_with_invalid_disk_format(self):
Masayuki Igawa4b29e472015-02-16 10:41:54 +090092 self.assertRaises(lib_exc.BadRequest, self.client.create_image,
Hoisaleshwara Madan V S7cba1082013-11-26 12:43:04 +053093 'test', 'bare', 'wrong')