diff --git a/nova/api/openstack/compute/contrib/keypairs.py b/nova/api/openstack/compute/contrib/keypairs.py index ab264f9da2d6..dc0c74b1147c 100644 --- a/nova/api/openstack/compute/contrib/keypairs.py +++ b/nova/api/openstack/compute/contrib/keypairs.py @@ -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) diff --git a/nova/tests/api/openstack/compute/contrib/test_keypairs.py b/nova/tests/api/openstack/compute/contrib/test_keypairs.py index 0019f757bada..a14a64da5144 100644 --- a/nova/tests/api/openstack/compute/contrib/test_keypairs.py +++ b/nova/tests/api/openstack/compute/contrib/test_keypairs.py @@ -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'], '')