Makes key_name show in details view of servers

The wrong authorizor was being used in the details view and the test
for details was broken. This fixes the test and makes sure that
key_name shows up in details like it is supposed to.

Fixes bug 1043584

Change-Id: I4ff01bbd32759f30e7a31ef2eac9f58922843037
This commit is contained in:
Vishvananda Ishaya 2012-09-12 10:37:29 -07:00
parent 511807ed24
commit e06d8bc8cd
2 changed files with 5 additions and 4 deletions

View File

@ -175,7 +175,7 @@ class Controller(servers.Controller):
@wsgi.extends
def detail(self, req, resp_obj):
context = req.environ['nova.context']
if 'servers' in resp_obj.obj and authorize(context):
if 'servers' in resp_obj.obj and soft_authorize(context):
resp_obj.attach(xml=ServersKeyNameTemplate())
servers = resp_obj.obj['servers']
self._add_key_name(req, servers)

View File

@ -284,14 +284,15 @@ class KeypairsTest(test.TestCase):
self.assertEquals(res_dict['server']['key_name'], '')
def test_detail_servers(self):
self.stubs.Set(db, 'instance_get',
fakes.fake_instance_get())
self.stubs.Set(db, 'instance_get_all_by_filters',
fakes.fake_instance_get_all_by_filters())
req = fakes.HTTPRequest.blank('/v2/fake/servers/detail')
res = req.get_response(fakes.wsgi_app())
server_dicts = jsonutils.loads(res.body)['servers']
self.assertEquals(len(server_dicts), 5)
for server_dict in server_dicts:
self.asserTrue('key_name' in server_dict)
self.assertTrue('key_name' in server_dict)
self.assertEquals(server_dict['key_name'], '')