Merge "Add the missing Client-ID check in wsgi v2"

This commit is contained in:
Jenkins 2016-02-10 14:38:10 +00:00 committed by Gerrit Code Review
commit d57d810818
4 changed files with 38 additions and 1 deletions

View File

@ -116,7 +116,7 @@ def require_client_id(req, resp, params):
:rtype: None :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 # NOTE(flaper87): `get_client_uuid` already raises 400
# it the header is missing. # it the header is missing.
get_client_uuid(req) get_client_uuid(req)

View File

@ -89,3 +89,23 @@ class TestValidation(base.V1Base):
headers=self.headers) headers=self.headers)
self.assertEqual(falcon.HTTP_400, self.srmock.status) 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)

View File

@ -89,3 +89,11 @@ class TestValidation(base.V1_1Base):
headers=self.headers) headers=self.headers)
self.assertEqual(falcon.HTTP_400, self.srmock.status) 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)

View File

@ -89,3 +89,12 @@ class TestValidation(base.V2Base):
headers=self.headers) headers=self.headers)
self.assertEqual(falcon.HTTP_400, self.srmock.status) 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)