Add the missing Client-ID check in wsgi v2
From wsgi v1.1 every request needs Client-ID. But the check is missing in v2. This patch fixes it. APIimpact Closes-bug: #1540699 Co-Authored-By: wangxiyuan <wangxiyuan@huawei.com> Co-Authored-By: Eva Balycheva <ubershy@gmail.com> Change-Id: I78fa2e5edb102adf4fd5aea02a5f74e78af6f0f8
This commit is contained in:
parent
7e3931afb2
commit
7e2e16cd76
@ -116,7 +116,7 @@ def require_client_id(req, resp, params):
|
||||
:rtype: None
|
||||
"""
|
||||
|
||||
if 'v1.1' in req.path:
|
||||
if req.path.startswith('/v1.1/') or req.path.startswith('/v2/'):
|
||||
# NOTE(flaper87): `get_client_uuid` already raises 400
|
||||
# it the header is missing.
|
||||
get_client_uuid(req)
|
||||
|
@ -89,3 +89,23 @@ class TestValidation(base.V1Base):
|
||||
headers=self.headers)
|
||||
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
def test_request_without_client_id(self):
|
||||
# Unlike newer APIs (v1.1 and v2), there will be no error 400, because
|
||||
# of missing Client-ID in headers.
|
||||
empty_headers = {}
|
||||
self.simulate_put(self.queue_path,
|
||||
self.project_id,
|
||||
headers=empty_headers)
|
||||
# Queue was already created by setUp, expecting 204 response code.
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
def test_request_without_client_id_if_resource_name_contains_v2_text(self):
|
||||
empty_headers = {}
|
||||
queue_path_with_v2 = self.url_prefix + '/queues/my_name_is_v2'
|
||||
self.simulate_put(queue_path_with_v2,
|
||||
self.project_id,
|
||||
headers=empty_headers)
|
||||
self.addCleanup(self.simulate_delete, queue_path_with_v2,
|
||||
self.project_id)
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
@ -89,3 +89,11 @@ class TestValidation(base.V1_1Base):
|
||||
headers=self.headers)
|
||||
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
def test_request_without_client_id(self):
|
||||
# No Client-ID in headers, it will raise 400 error.
|
||||
empty_headers = {}
|
||||
self.simulate_put(self.queue_path,
|
||||
self.project_id,
|
||||
headers=empty_headers)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
@ -89,3 +89,12 @@ class TestValidation(base.V2Base):
|
||||
headers=self.headers)
|
||||
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
def test_request_without_client_id(self):
|
||||
# No Client-ID in headers, it will raise 400 error.
|
||||
empty_headers = {}
|
||||
self.simulate_put(self.queue_path,
|
||||
self.project_id,
|
||||
body='{"timespace": "Shangri-la"}',
|
||||
headers=empty_headers)
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
Loading…
Reference in New Issue
Block a user