Leo Toyoda | 3ae31e1 | 2013-04-19 11:19:57 +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 | |
| 18 | from tempest import exceptions |
| 19 | from tempest.test import attr |
| 20 | from tempest.tests.compute import base |
| 21 | |
| 22 | |
| 23 | class ServicesAdminTestJSON(base.BaseComputeAdminTest): |
| 24 | |
| 25 | """ |
| 26 | Tests Services API. List and Enable/Disable require admin privileges. |
| 27 | """ |
| 28 | |
| 29 | _interface = 'json' |
| 30 | |
| 31 | @classmethod |
| 32 | def setUpClass(cls): |
| 33 | super(ServicesAdminTestJSON, cls).setUpClass() |
| 34 | cls.client = cls.os_adm.services_client |
| 35 | cls.non_admin_client = cls.services_client |
| 36 | |
| 37 | @attr(type='positive') |
| 38 | def test_list_services(self): |
| 39 | # List Compute services |
| 40 | resp, services = self.client.list_services() |
| 41 | self.assertEqual(200, resp.status) |
| 42 | self.assertTrue(len(services) >= 2) |
| 43 | |
| 44 | @attr(type='negative') |
| 45 | def test_list_services_with_non_admin_user(self): |
| 46 | # List Compute service with non admin user |
| 47 | self.assertRaises(exceptions.Unauthorized, |
| 48 | self.non_admin_client.list_services) |
| 49 | |
| 50 | |
| 51 | class ServicesAdminTestXML(ServicesAdminTestJSON): |
| 52 | _interface = 'xml' |