From a13e6ca363b4a3741a3d757977f82c0b5f5ccfce Mon Sep 17 00:00:00 2001 From: pengdake <19921207pq@gmail.com> Date: Fri, 2 Feb 2018 23:49:10 +0800 Subject: [PATCH] Fix error about request validate for image_search We should use parameter rather than body. If not, The request of image_search will not be validated. Closes-Bug: #1748584 Change-Id: Iff1607f8e40aedad9fd1048de88b5d3b4c7acc31 --- zunclient/common/base.py | 4 ++-- zunclient/tests/unit/v1/test_images.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/zunclient/common/base.py b/zunclient/common/base.py index 042628f3..c62060c2 100644 --- a/zunclient/common/base.py +++ b/zunclient/common/base.py @@ -144,8 +144,8 @@ class Manager(object): url = "%s?%s" % (url, urlparse.urlencode(qparams)) self.api.raw_request('DELETE', url) - def _search(self, url, body=None, response_key=None, obj_class=None, - qparams=None): + def _search(self, url, qparams=None, response_key=None, obj_class=None, + body=None): if qparams: url = "%s?%s" % (url, urlparse.urlencode(qparams)) diff --git a/zunclient/tests/unit/v1/test_images.py b/zunclient/tests/unit/v1/test_images.py index 554f0e63..286c7f15 100644 --- a/zunclient/tests/unit/v1/test_images.py +++ b/zunclient/tests/unit/v1/test_images.py @@ -91,7 +91,8 @@ fake_responses = { {'images': [IMAGE2, IMAGE1]}, ), }, - '/v1/images/%s/search' % IMAGE3['image']: + '/v1/images/%s/search?image_driver=%s' % (IMAGE3['image'], + IMAGE3['image_driver']): { 'GET': ( {}, @@ -182,9 +183,10 @@ class ImageManagerTest(testtools.TestCase): def test_image_search(self): images = self.mgr.search_image(**SEARCH_IMAGE) + url = '/v1/images/%s/search?image_driver=%s' \ + % (IMAGE3['image'], IMAGE3['image_driver']) expect = [ - ('GET', '/v1/images/%s/search' % IMAGE3['image'], {}, - {'image_driver': IMAGE3['image_driver']}), + ('GET', url, {}, None), ] self.assertEqual(expect, self.api.calls) self.assertThat(images, matchers.HasLength(1))