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 | |
| 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 Aikawa | 9012f46 | 2014-03-05 16:43:32 +0900 | [diff] [blame] | 39 | @test.attr(type=['negative', 'gate']) |
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()) |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 43 | self.assertRaises(lib_exc.NotFound, self.client.get_image, |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 44 | non_existent_id) |
| 45 | |
Eiichi Aikawa | 9012f46 | 2014-03-05 16:43:32 +0900 | [diff] [blame] | 46 | @test.attr(type=['negative', 'gate']) |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 47 | def test_get_image_null_id(self): |
| 48 | # get image with image_id = NULL |
| 49 | image_id = "" |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 50 | self.assertRaises(lib_exc.NotFound, self.client.get_image, image_id) |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 51 | |
Eiichi Aikawa | 9012f46 | 2014-03-05 16:43:32 +0900 | [diff] [blame] | 52 | @test.attr(type=['negative', 'gate']) |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 53 | def test_get_delete_deleted_image(self): |
| 54 | # get and delete the deleted image |
| 55 | # create and delete image |
David Kranz | 34f1878 | 2015-01-06 13:43:55 -0500 | [diff] [blame] | 56 | body = self.client.create_image(name='test', |
| 57 | container_format='bare', |
| 58 | disk_format='raw') |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 59 | image_id = body['id'] |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 60 | self.client.delete_image(image_id) |
| 61 | self.client.wait_for_resource_deletion(image_id) |
| 62 | |
| 63 | # get the deleted image |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 64 | self.assertRaises(lib_exc.NotFound, self.client.get_image, image_id) |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 65 | |
| 66 | # delete the deleted image |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 67 | self.assertRaises(lib_exc.NotFound, self.client.delete_image, |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 68 | image_id) |
| 69 | |
Eiichi Aikawa | 9012f46 | 2014-03-05 16:43:32 +0900 | [diff] [blame] | 70 | @test.attr(type=['negative', 'gate']) |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 71 | def test_delete_non_existing_image(self): |
| 72 | # delete non-existent image |
| 73 | non_existent_image_id = str(uuid.uuid4()) |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 74 | self.assertRaises(lib_exc.NotFound, self.client.delete_image, |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 75 | non_existent_image_id) |
| 76 | |
Eiichi Aikawa | 9012f46 | 2014-03-05 16:43:32 +0900 | [diff] [blame] | 77 | @test.attr(type=['negative', 'gate']) |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 78 | def test_delete_image_null_id(self): |
| 79 | # delete image with image_id=NULL |
| 80 | image_id = "" |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 81 | self.assertRaises(lib_exc.NotFound, self.client.delete_image, |
Hoisaleshwara Madan V S | e4476cd | 2013-11-08 12:49:48 +0530 | [diff] [blame] | 82 | image_id) |
Hoisaleshwara Madan V S | 7cba108 | 2013-11-26 12:43:04 +0530 | [diff] [blame] | 83 | |
Eiichi Aikawa | 9012f46 | 2014-03-05 16:43:32 +0900 | [diff] [blame] | 84 | @test.attr(type=['negative', 'gate']) |
Hoisaleshwara Madan V S | 7cba108 | 2013-11-26 12:43:04 +0530 | [diff] [blame] | 85 | def test_register_with_invalid_container_format(self): |
| 86 | # Negative tests for invalid data supplied to POST /images |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 87 | self.assertRaises(lib_exc.BadRequest, self.client.create_image, |
Hoisaleshwara Madan V S | 7cba108 | 2013-11-26 12:43:04 +0530 | [diff] [blame] | 88 | 'test', 'wrong', 'vhd') |
| 89 | |
Eiichi Aikawa | 9012f46 | 2014-03-05 16:43:32 +0900 | [diff] [blame] | 90 | @test.attr(type=['negative', 'gate']) |
Hoisaleshwara Madan V S | 7cba108 | 2013-11-26 12:43:04 +0530 | [diff] [blame] | 91 | def test_register_with_invalid_disk_format(self): |
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', 'bare', 'wrong') |