'Test getting servers by admin-only or unknown options when
context is not admin. Make sure the admin and unknown options
are stripped before they get to compute_api.get_all()'

def test_get_servers_admin_filters_as_user(self):

    server_uuid = uuids.fake
    def fake_get_all(compute_self, context, search_opts=None, limit=None, marker=None, expected_attrs=None, sort_keys=None, sort_dirs=None):
        self.assertIsNotNone(search_opts)
        self.assertIn('name', search_opts)
        self.assertIn('ip', search_opts)
        self.assertIn('vm_state', search_opts)
        self.assertNotIn('unknown_option', search_opts)
        return objects.InstanceList(objects=[fakes.stub_instance_obj(100, uuid=server_uuid)])
    self.stubs.Set(compute_api.API, 'get_all', fake_get_all)
    query_str = 'name=foo&ip=10.*&status=active&unknown_option=meow'
    req = fakes.HTTPRequest.blank(('/fake/servers?%s' % query_str))
    res = self.controller.index(req)
    servers = res['servers']
    self.assertEqual(len(servers), 1)
    self.assertEqual(servers[0]['id'], server_uuid)
