Leo Toyoda | a527891 | 2013-04-16 15:40:12 +0900 | [diff] [blame] | 1 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
| 2 | |
| 3 | # Copyright 2013 NEC Corporation |
| 4 | # All Rights Reserved. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 | # not use this file except in compliance with the License. You may obtain |
| 8 | # a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 15 | # License for the specific language governing permissions and limitations |
| 16 | # under the License. |
| 17 | |
Sean Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 18 | from tempest.api.compute import base |
Leo Toyoda | a527891 | 2013-04-16 15:40:12 +0900 | [diff] [blame] | 19 | from tempest import exceptions |
| 20 | from tempest.test import attr |
Leo Toyoda | a527891 | 2013-04-16 15:40:12 +0900 | [diff] [blame] | 21 | |
| 22 | |
| 23 | class AvailabilityZoneAdminTestJSON(base.BaseComputeAdminTest): |
| 24 | |
| 25 | """ |
| 26 | Tests Availability Zone API List that require admin privileges |
| 27 | """ |
| 28 | |
| 29 | _interface = 'json' |
| 30 | |
| 31 | @classmethod |
| 32 | def setUpClass(cls): |
| 33 | super(AvailabilityZoneAdminTestJSON, cls).setUpClass() |
| 34 | cls.client = cls.os_adm.availability_zone_client |
| 35 | cls.non_adm_client = cls.availability_zone_client |
| 36 | |
| 37 | @attr('positive') |
| 38 | def test_get_availability_zone_list(self): |
| 39 | # List of availability zone |
| 40 | resp, availability_zone = self.client.get_availability_zone_list() |
| 41 | self.assertEqual(200, resp.status) |
| 42 | self.assertTrue(len(availability_zone) > 0) |
| 43 | |
| 44 | @attr('positive') |
| 45 | def test_get_availability_zone_list_detail(self): |
| 46 | # List of availability zones and available services |
| 47 | resp, availability_zone = \ |
| 48 | self.client.get_availability_zone_list_detail() |
| 49 | self.assertEqual(200, resp.status) |
| 50 | self.assertTrue(len(availability_zone) > 0) |
| 51 | |
| 52 | @attr('positive') |
| 53 | def test_get_availability_zone_list_with_non_admin_user(self): |
| 54 | # List of availability zone with non admin user |
| 55 | resp, availability_zone = \ |
| 56 | self.non_adm_client.get_availability_zone_list() |
| 57 | self.assertEqual(200, resp.status) |
| 58 | self.assertTrue(len(availability_zone) > 0) |
| 59 | |
| 60 | @attr('negative') |
| 61 | def test_get_availability_zone_list_detail_with_non_admin_user(self): |
| 62 | # List of availability zones and available services with non admin user |
| 63 | self.assertRaises( |
| 64 | exceptions.Unauthorized, |
| 65 | self.non_adm_client.get_availability_zone_list_detail) |
| 66 | |
| 67 | |
| 68 | class AvailabilityZoneAdminTestXML(AvailabilityZoneAdminTestJSON): |
| 69 | _interface = 'xml' |