Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 1 | # 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 | |
| 17 | import uuid |
| 18 | |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 19 | from tempest_lib import exceptions as lib_exc |
| 20 | |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 21 | from tempest.api.image import base |
Eiichi Aikawa | 9012f46 | 2014-03-05 16:43:32 +0900 | [diff] [blame] | 22 | from tempest import test |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 23 | |
| 24 | |
| 25 | class ImagesNegativeTest(base.BaseV2ImageTest): |
| 26 | |
Ken'ichi Ohmichi | 9e3dac0 | 2015-11-19 07:01:07 +0000 | [diff] [blame] | 27 | """here we have -ve tests for show_image and delete_image api |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 28 | |
| 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 Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 38 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 39 | @test.idempotent_id('668743d5-08ad-4480-b2b8-15da34f81d9f') |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 40 | def test_get_non_existent_image(self): |
| 41 | # get the non-existent image |
| 42 | non_existent_id = str(uuid.uuid4()) |
Ken'ichi Ohmichi | 5d41076 | 2015-05-22 01:10:03 +0000 | [diff] [blame] | 43 | self.assertRaises(lib_exc.NotFound, self.client.show_image, |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 44 | non_existent_id) |
| 45 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 46 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 47 | @test.idempotent_id('ef45000d-0a72-4781-866d-4cb7bf2562ad') |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 48 | def test_get_image_null_id(self): |
| 49 | # get image with image_id = NULL |
| 50 | image_id = "" |
Ken'ichi Ohmichi | 5d41076 | 2015-05-22 01:10:03 +0000 | [diff] [blame] | 51 | self.assertRaises(lib_exc.NotFound, self.client.show_image, image_id) |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 52 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 53 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 54 | @test.idempotent_id('e57fc127-7ba0-4693-92d7-1d8a05ebcba9') |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 55 | def test_get_delete_deleted_image(self): |
| 56 | # get and delete the deleted image |
| 57 | # create and delete image |
David Kranz | 34f1878 | 2015-01-06 13:43:55 -0500 | [diff] [blame] | 58 | body = self.client.create_image(name='test', |
| 59 | container_format='bare', |
| 60 | disk_format='raw') |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 61 | image_id = body['id'] |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 62 | self.client.delete_image(image_id) |
| 63 | self.client.wait_for_resource_deletion(image_id) |
| 64 | |
| 65 | # get the deleted image |
Ken'ichi Ohmichi | 5d41076 | 2015-05-22 01:10:03 +0000 | [diff] [blame] | 66 | self.assertRaises(lib_exc.NotFound, self.client.show_image, image_id) |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 67 | |
| 68 | # delete the deleted image |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 69 | self.assertRaises(lib_exc.NotFound, self.client.delete_image, |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 70 | image_id) |
| 71 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 72 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 73 | @test.idempotent_id('6fe40f1c-57bd-4918-89cc-8500f850f3de') |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 74 | def test_delete_non_existing_image(self): |
| 75 | # delete non-existent image |
| 76 | non_existent_image_id = str(uuid.uuid4()) |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 77 | self.assertRaises(lib_exc.NotFound, self.client.delete_image, |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 78 | non_existent_image_id) |
| 79 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 80 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 81 | @test.idempotent_id('32248db1-ab88-4821-9604-c7c369f1f88c') |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 82 | def test_delete_image_null_id(self): |
| 83 | # delete image with image_id=NULL |
| 84 | image_id = "" |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 85 | self.assertRaises(lib_exc.NotFound, self.client.delete_image, |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 86 | image_id) |
Hoisaleshwara Madan V S | 7cba108 | 2013-11-26 12:43:04 +0530 | [diff] [blame] | 87 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 88 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 89 | @test.idempotent_id('292bd310-369b-41c7-a7a3-10276ef76753') |
Hoisaleshwara Madan V S | 7cba108 | 2013-11-26 12:43:04 +0530 | [diff] [blame] | 90 | def test_register_with_invalid_container_format(self): |
| 91 | # Negative tests for invalid data supplied to POST /images |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 92 | self.assertRaises(lib_exc.BadRequest, self.client.create_image, |
Hoisaleshwara Madan V S | 7cba108 | 2013-11-26 12:43:04 +0530 | [diff] [blame] | 93 | 'test', 'wrong', 'vhd') |
| 94 | |
Sean Dague | 639f2fa | 2015-04-27 09:00:33 -0400 | [diff] [blame] | 95 | @test.attr(type=['negative']) |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 96 | @test.idempotent_id('70c6040c-5a97-4111-9e13-e73665264ce1') |
Hoisaleshwara Madan V S | 7cba108 | 2013-11-26 12:43:04 +0530 | [diff] [blame] | 97 | def test_register_with_invalid_disk_format(self): |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 98 | self.assertRaises(lib_exc.BadRequest, self.client.create_image, |
Hoisaleshwara Madan V S | 7cba108 | 2013-11-26 12:43:04 +0530 | [diff] [blame] | 99 | 'test', 'bare', 'wrong') |