diff --git a/zaqar/common/transport/wsgi/helpers.py b/zaqar/common/transport/wsgi/helpers.py index 0069c051e..fc723987f 100644 --- a/zaqar/common/transport/wsgi/helpers.py +++ b/zaqar/common/transport/wsgi/helpers.py @@ -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) diff --git a/zaqar/tests/unit/transport/wsgi/v1/test_validation.py b/zaqar/tests/unit/transport/wsgi/v1/test_validation.py index c288dc8eb..2da061faf 100644 --- a/zaqar/tests/unit/transport/wsgi/v1/test_validation.py +++ b/zaqar/tests/unit/transport/wsgi/v1/test_validation.py @@ -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) diff --git a/zaqar/tests/unit/transport/wsgi/v1_1/test_validation.py b/zaqar/tests/unit/transport/wsgi/v1_1/test_validation.py index e79ce3587..8c3d86c56 100644 --- a/zaqar/tests/unit/transport/wsgi/v1_1/test_validation.py +++ b/zaqar/tests/unit/transport/wsgi/v1_1/test_validation.py @@ -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) diff --git a/zaqar/tests/unit/transport/wsgi/v2_0/test_validation.py b/zaqar/tests/unit/transport/wsgi/v2_0/test_validation.py index 8986d9b0a..e6bbe9b01 100644 --- a/zaqar/tests/unit/transport/wsgi/v2_0/test_validation.py +++ b/zaqar/tests/unit/transport/wsgi/v2_0/test_validation.py @@ -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)