blob: 60a10a28b5a66fe8494eaeca0a8c48c9d4a4b433 [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
Sean Dague639f2fa2015-04-27 09:00:33 -040039 @test.attr(type=['negative'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080040 @test.idempotent_id('668743d5-08ad-4480-b2b8-15da34f81d9f')
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053041 def test_get_non_existent_image(self):
42 # get the non-existent image
43 non_existent_id = str(uuid.uuid4())
Masayuki Igawabfa07602015-01-20 18:47:17 +090044 self.assertRaises(lib_exc.NotFound, self.client.get_image,
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053045 non_existent_id)
46
Sean Dague639f2fa2015-04-27 09:00:33 -040047 @test.attr(type=['negative'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080048 @test.idempotent_id('ef45000d-0a72-4781-866d-4cb7bf2562ad')
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053049 def test_get_image_null_id(self):
50 # get image with image_id = NULL
51 image_id = ""
Masayuki Igawabfa07602015-01-20 18:47:17 +090052 self.assertRaises(lib_exc.NotFound, self.client.get_image, image_id)
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053053
Sean Dague639f2fa2015-04-27 09:00:33 -040054 @test.attr(type=['negative'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080055 @test.idempotent_id('e57fc127-7ba0-4693-92d7-1d8a05ebcba9')
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053056 def test_get_delete_deleted_image(self):
57 # get and delete the deleted image
58 # create and delete image
David Kranz34f18782015-01-06 13:43:55 -050059 body = self.client.create_image(name='test',
60 container_format='bare',
61 disk_format='raw')
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053062 image_id = body['id']
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053063 self.client.delete_image(image_id)
64 self.client.wait_for_resource_deletion(image_id)
65
66 # get the deleted image
Masayuki Igawabfa07602015-01-20 18:47:17 +090067 self.assertRaises(lib_exc.NotFound, self.client.get_image, image_id)
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053068
69 # delete the deleted image
Masayuki Igawabfa07602015-01-20 18:47:17 +090070 self.assertRaises(lib_exc.NotFound, self.client.delete_image,
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053071 image_id)
72
Sean Dague639f2fa2015-04-27 09:00:33 -040073 @test.attr(type=['negative'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080074 @test.idempotent_id('6fe40f1c-57bd-4918-89cc-8500f850f3de')
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053075 def test_delete_non_existing_image(self):
76 # delete non-existent image
77 non_existent_image_id = str(uuid.uuid4())
Masayuki Igawabfa07602015-01-20 18:47:17 +090078 self.assertRaises(lib_exc.NotFound, self.client.delete_image,
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053079 non_existent_image_id)
80
Sean Dague639f2fa2015-04-27 09:00:33 -040081 @test.attr(type=['negative'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080082 @test.idempotent_id('32248db1-ab88-4821-9604-c7c369f1f88c')
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053083 def test_delete_image_null_id(self):
84 # delete image with image_id=NULL
85 image_id = ""
Masayuki Igawabfa07602015-01-20 18:47:17 +090086 self.assertRaises(lib_exc.NotFound, self.client.delete_image,
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053087 image_id)
Hoisaleshwara Madan V S7cba1082013-11-26 12:43:04 +053088
Sean Dague639f2fa2015-04-27 09:00:33 -040089 @test.attr(type=['negative'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080090 @test.idempotent_id('292bd310-369b-41c7-a7a3-10276ef76753')
Hoisaleshwara Madan V S7cba1082013-11-26 12:43:04 +053091 def test_register_with_invalid_container_format(self):
92 # Negative tests for invalid data supplied to POST /images
Masayuki Igawa4b29e472015-02-16 10:41:54 +090093 self.assertRaises(lib_exc.BadRequest, self.client.create_image,
Hoisaleshwara Madan V S7cba1082013-11-26 12:43:04 +053094 'test', 'wrong', 'vhd')
95
Sean Dague639f2fa2015-04-27 09:00:33 -040096 @test.attr(type=['negative'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080097 @test.idempotent_id('70c6040c-5a97-4111-9e13-e73665264ce1')
Hoisaleshwara Madan V S7cba1082013-11-26 12:43:04 +053098 def test_register_with_invalid_disk_format(self):
Masayuki Igawa4b29e472015-02-16 10:41:54 +090099 self.assertRaises(lib_exc.BadRequest, self.client.create_image,
Hoisaleshwara Madan V S7cba1082013-11-26 12:43:04 +0530100 'test', 'bare', 'wrong')