blob: cb47066810497da4a1e0d4774c70e41ba825cd7e [file] [log] [blame]
Liu, Zhi Kunb0ac0b82013-06-20 16:20:21 +08001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
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
17from tempest.api.compute import base
18from tempest.common.utils.data_utils import rand_name
19from tempest.test import attr
20
21
22class ServersAdminTestJSON(base.BaseComputeAdminTest):
23
24 """
25 Tests Servers API using admin privileges
26 """
27
28 _interface = 'json'
29
30 @classmethod
31 def setUpClass(cls):
32 super(ServersAdminTestJSON, cls).setUpClass()
33 cls.client = cls.os_adm.servers_client
34
35 cls.s1_name = rand_name('server')
36 resp, server = cls.create_server(name=cls.s1_name,
37 wait_until='ACTIVE')
38 cls.s2_name = rand_name('server')
39 resp, server = cls.create_server(name=cls.s2_name,
40 wait_until='ACTIVE')
41
42 @attr(type='gate')
43 def test_list_servers_by_admin(self):
44 # Listing servers by admin user returns empty list by default
45 resp, body = self.client.list_servers_with_detail()
46 servers = body['servers']
47 self.assertEqual('200', resp['status'])
48 self.assertEqual([], servers)
49
50 @attr(type='gate')
51 def test_list_servers_by_admin_with_all_tenants(self):
52 # Listing servers by admin user with all tenants parameter
53 # Here should be listed all servers
54 params = {'all_tenants': ''}
55 resp, body = self.client.list_servers_with_detail(params)
56 servers = body['servers']
57 servers_name = map(lambda x: x['name'], servers)
58
59 self.assertIn(self.s1_name, servers_name)
60 self.assertIn(self.s2_name, servers_name)
61
62
63class ServersAdminTestXML(ServersAdminTestJSON):
64 _interface = 'xml'