blob: 71c8c7ac5e202779e9ae3d95110c2136edecc45a [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
Ken'ichi Ohmichi9e3dac02015-11-19 07:01:07 +000027 """here we have -ve tests for show_image and delete_image api
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053028
29 Tests
30 ** get non-existent image
31 ** get image with image_id=NULL
32 ** get the deleted image
33 ** delete non-existent image
34 ** delete rimage with image_id=NULL
35 ** delete the deleted image
36 """
37
Sean Dague639f2fa2015-04-27 09:00:33 -040038 @test.attr(type=['negative'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080039 @test.idempotent_id('668743d5-08ad-4480-b2b8-15da34f81d9f')
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())
Ken'ichi Ohmichi5d410762015-05-22 01:10:03 +000043 self.assertRaises(lib_exc.NotFound, self.client.show_image,
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053044 non_existent_id)
45
Sean Dague639f2fa2015-04-27 09:00:33 -040046 @test.attr(type=['negative'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080047 @test.idempotent_id('ef45000d-0a72-4781-866d-4cb7bf2562ad')
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053048 def test_get_image_null_id(self):
49 # get image with image_id = NULL
50 image_id = ""
Ken'ichi Ohmichi5d410762015-05-22 01:10:03 +000051 self.assertRaises(lib_exc.NotFound, self.client.show_image, image_id)
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053052
Sean Dague639f2fa2015-04-27 09:00:33 -040053 @test.attr(type=['negative'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080054 @test.idempotent_id('e57fc127-7ba0-4693-92d7-1d8a05ebcba9')
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053055 def test_get_delete_deleted_image(self):
56 # get and delete the deleted image
57 # create and delete image
David Kranz34f18782015-01-06 13:43:55 -050058 body = self.client.create_image(name='test',
59 container_format='bare',
60 disk_format='raw')
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053061 image_id = body['id']
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053062 self.client.delete_image(image_id)
63 self.client.wait_for_resource_deletion(image_id)
64
65 # get the deleted image
Ken'ichi Ohmichi5d410762015-05-22 01:10:03 +000066 self.assertRaises(lib_exc.NotFound, self.client.show_image, image_id)
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053067
68 # delete the deleted image
Masayuki Igawabfa07602015-01-20 18:47:17 +090069 self.assertRaises(lib_exc.NotFound, self.client.delete_image,
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053070 image_id)
71
Sean Dague639f2fa2015-04-27 09:00:33 -040072 @test.attr(type=['negative'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080073 @test.idempotent_id('6fe40f1c-57bd-4918-89cc-8500f850f3de')
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053074 def test_delete_non_existing_image(self):
75 # delete non-existent image
76 non_existent_image_id = str(uuid.uuid4())
Masayuki Igawabfa07602015-01-20 18:47:17 +090077 self.assertRaises(lib_exc.NotFound, self.client.delete_image,
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053078 non_existent_image_id)
79
Sean Dague639f2fa2015-04-27 09:00:33 -040080 @test.attr(type=['negative'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080081 @test.idempotent_id('32248db1-ab88-4821-9604-c7c369f1f88c')
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053082 def test_delete_image_null_id(self):
83 # delete image with image_id=NULL
84 image_id = ""
Masayuki Igawabfa07602015-01-20 18:47:17 +090085 self.assertRaises(lib_exc.NotFound, self.client.delete_image,
Hoisaleshwara Madan V Se4476cd2013-11-08 12:49:48 +053086 image_id)
Hoisaleshwara Madan V S7cba1082013-11-26 12:43:04 +053087
Sean Dague639f2fa2015-04-27 09:00:33 -040088 @test.attr(type=['negative'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080089 @test.idempotent_id('292bd310-369b-41c7-a7a3-10276ef76753')
Hoisaleshwara Madan V S7cba1082013-11-26 12:43:04 +053090 def test_register_with_invalid_container_format(self):
91 # Negative tests for invalid data supplied to POST /images
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', 'wrong', 'vhd')
94
Sean Dague639f2fa2015-04-27 09:00:33 -040095 @test.attr(type=['negative'])
Chris Hoge7579c1a2015-02-26 14:12:15 -080096 @test.idempotent_id('70c6040c-5a97-4111-9e13-e73665264ce1')
Hoisaleshwara Madan V S7cba1082013-11-26 12:43:04 +053097 def test_register_with_invalid_disk_format(self):
Masayuki Igawa4b29e472015-02-16 10:41:54 +090098 self.assertRaises(lib_exc.BadRequest, self.client.create_image,
Hoisaleshwara Madan V S7cba1082013-11-26 12:43:04 +053099 'test', 'bare', 'wrong')