ivan-zhu | 3867a1c | 2013-10-11 14:16:58 +0800 | [diff] [blame] | 1 | # Copyright 2013 IBM Corp. |
| 2 | # All Rights Reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | # not use this file except in compliance with the License. You may obtain |
| 6 | # a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | # License for the specific language governing permissions and limitations |
| 14 | # under the License. |
| 15 | |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 16 | from tempest_lib import exceptions as lib_exc |
| 17 | |
ivan-zhu | 3867a1c | 2013-10-11 14:16:58 +0800 | [diff] [blame] | 18 | from tempest.api.image import base |
Eiichi Aikawa | 9012f46 | 2014-03-05 16:43:32 +0900 | [diff] [blame] | 19 | from tempest import test |
ivan-zhu | 3867a1c | 2013-10-11 14:16:58 +0800 | [diff] [blame] | 20 | |
| 21 | |
| 22 | class CreateDeleteImagesNegativeTest(base.BaseV1ImageTest): |
| 23 | """Here are negative tests for the deletion and creation of images.""" |
| 24 | |
Eiichi Aikawa | 9012f46 | 2014-03-05 16:43:32 +0900 | [diff] [blame] | 25 | @test.attr(type=['negative', 'gate']) |
ivan-zhu | 3867a1c | 2013-10-11 14:16:58 +0800 | [diff] [blame] | 26 | def test_register_with_invalid_container_format(self): |
| 27 | # Negative tests for invalid data supplied to POST /images |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame^] | 28 | self.assertRaises(lib_exc.BadRequest, self.client.create_image, |
ivan-zhu | 3867a1c | 2013-10-11 14:16:58 +0800 | [diff] [blame] | 29 | 'test', 'wrong', 'vhd') |
| 30 | |
Eiichi Aikawa | 9012f46 | 2014-03-05 16:43:32 +0900 | [diff] [blame] | 31 | @test.attr(type=['negative', 'gate']) |
ivan-zhu | 3867a1c | 2013-10-11 14:16:58 +0800 | [diff] [blame] | 32 | def test_register_with_invalid_disk_format(self): |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame^] | 33 | self.assertRaises(lib_exc.BadRequest, self.client.create_image, |
ivan-zhu | 3867a1c | 2013-10-11 14:16:58 +0800 | [diff] [blame] | 34 | 'test', 'bare', 'wrong') |
| 35 | |
Eiichi Aikawa | 9012f46 | 2014-03-05 16:43:32 +0900 | [diff] [blame] | 36 | @test.attr(type=['negative', 'gate']) |
ivan-zhu | 3867a1c | 2013-10-11 14:16:58 +0800 | [diff] [blame] | 37 | def test_delete_image_with_invalid_image_id(self): |
| 38 | # An image should not be deleted with invalid image id |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 39 | self.assertRaises(lib_exc.NotFound, self.client.delete_image, |
ivan-zhu | 3867a1c | 2013-10-11 14:16:58 +0800 | [diff] [blame] | 40 | '!@$%^&*()') |
| 41 | |
Eiichi Aikawa | 9012f46 | 2014-03-05 16:43:32 +0900 | [diff] [blame] | 42 | @test.attr(type=['negative', 'gate']) |
ivan-zhu | 3867a1c | 2013-10-11 14:16:58 +0800 | [diff] [blame] | 43 | def test_delete_non_existent_image(self): |
| 44 | # Return an error while trying to delete a non-existent image |
| 45 | |
| 46 | non_existent_image_id = '11a22b9-12a9-5555-cc11-00ab112223fa' |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 47 | self.assertRaises(lib_exc.NotFound, self.client.delete_image, |
ivan-zhu | 3867a1c | 2013-10-11 14:16:58 +0800 | [diff] [blame] | 48 | non_existent_image_id) |
| 49 | |
Eiichi Aikawa | 9012f46 | 2014-03-05 16:43:32 +0900 | [diff] [blame] | 50 | @test.attr(type=['negative', 'gate']) |
ivan-zhu | 3867a1c | 2013-10-11 14:16:58 +0800 | [diff] [blame] | 51 | def test_delete_image_blank_id(self): |
| 52 | # Return an error while trying to delete an image with blank Id |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 53 | self.assertRaises(lib_exc.NotFound, self.client.delete_image, '') |
ivan-zhu | 3867a1c | 2013-10-11 14:16:58 +0800 | [diff] [blame] | 54 | |
Eiichi Aikawa | 9012f46 | 2014-03-05 16:43:32 +0900 | [diff] [blame] | 55 | @test.attr(type=['negative', 'gate']) |
ivan-zhu | 3867a1c | 2013-10-11 14:16:58 +0800 | [diff] [blame] | 56 | def test_delete_image_non_hex_string_id(self): |
| 57 | # Return an error while trying to delete an image with non hex id |
| 58 | image_id = '11a22b9-120q-5555-cc11-00ab112223gj' |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 59 | self.assertRaises(lib_exc.NotFound, self.client.delete_image, |
ivan-zhu | 3867a1c | 2013-10-11 14:16:58 +0800 | [diff] [blame] | 60 | image_id) |
| 61 | |
Eiichi Aikawa | 9012f46 | 2014-03-05 16:43:32 +0900 | [diff] [blame] | 62 | @test.attr(type=['negative', 'gate']) |
ivan-zhu | 3867a1c | 2013-10-11 14:16:58 +0800 | [diff] [blame] | 63 | def test_delete_image_negative_image_id(self): |
| 64 | # Return an error while trying to delete an image with negative id |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 65 | self.assertRaises(lib_exc.NotFound, self.client.delete_image, -1) |
ivan-zhu | 3867a1c | 2013-10-11 14:16:58 +0800 | [diff] [blame] | 66 | |
Eiichi Aikawa | 9012f46 | 2014-03-05 16:43:32 +0900 | [diff] [blame] | 67 | @test.attr(type=['negative', 'gate']) |
ivan-zhu | 3867a1c | 2013-10-11 14:16:58 +0800 | [diff] [blame] | 68 | def test_delete_image_id_is_over_35_character_limit(self): |
| 69 | # Return an error while trying to delete image with id over limit |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 70 | self.assertRaises(lib_exc.NotFound, self.client.delete_image, |
ivan-zhu | 3867a1c | 2013-10-11 14:16:58 +0800 | [diff] [blame] | 71 | '11a22b9-12a9-5555-cc11-00ab112223fa-3fac') |