From a0b6a79a3cf065efb38c0a29575ca16825971df5 Mon Sep 17 00:00:00 2001 From: zengjianfang Date: Thu, 2 Mar 2017 17:25:03 +0800 Subject: [PATCH] Fix The header X-PROJECT-ID missing bug This patch fixex X-PROJECT-ID missing bug. Change-Id: I8c13160f24f51a3f6588aefadae9ef8ff2519e1a Co-Authored-By: XueFeng Liu Closes-Bug: #1668830 --- examples/keystone_auth.py | 2 +- examples/signed_url_auth.py | 2 +- tests/unit/transport/test_request.py | 2 +- tests/unit/transport/test_ws.py | 2 +- zaqarclient/tests/base.py | 4 ++-- zaqarclient/tests/queues/queues.py | 2 +- zaqarclient/transport/request.py | 2 +- zaqarclient/transport/ws.py | 4 ++-- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/keystone_auth.py b/examples/keystone_auth.py index 16a5b8cd..c5f90fb8 100644 --- a/examples/keystone_auth.py +++ b/examples/keystone_auth.py @@ -33,7 +33,7 @@ def create_post_delete(queue_name, messages): {'backend': 'keystone', 'options': {'os_username': 'zaqar', 'os_password': 'zaqar', - 'os_project_id': 'ccad479c402f43a2994f6e372ab3f8fe', + 'project_id': 'ccad479c402f43a2994f6e372ab3f8fe', 'os_project_name': '', 'os_auth_url': 'http://127.0.0.1:5000/v2.0/', 'insecure': ''} diff --git a/examples/signed_url_auth.py b/examples/signed_url_auth.py index 0239f526..5d028c35 100644 --- a/examples/signed_url_auth.py +++ b/examples/signed_url_auth.py @@ -34,7 +34,7 @@ def create_post_delete(queue_name, messages): 'expires': '', 'methods': ['GET', 'PATCH', 'POST', 'PUT'], 'paths': ['/v2/queues/beijing/claims'], - 'os_project_id': '2887aabf368046a3bb0070f1c0413470'} + 'project_id': '2887aabf368046a3bb0070f1c0413470'} } } cli = client.Client(URL, conf=conf) diff --git a/tests/unit/transport/test_request.py b/tests/unit/transport/test_request.py index 53f11470..23318041 100644 --- a/tests/unit/transport/test_request.py +++ b/tests/unit/transport/test_request.py @@ -27,7 +27,7 @@ class TestRequest(base.TestBase): def test_request_project_id(self): auth_opts = { 'options': { - 'os_project_id': 'my-project' + 'project_id': 'my-project' } } auth_opts.update({'backend': 'noauth'}) diff --git a/tests/unit/transport/test_ws.py b/tests/unit/transport/test_ws.py index aad30de5..6e036649 100644 --- a/tests/unit/transport/test_ws.py +++ b/tests/unit/transport/test_ws.py @@ -25,7 +25,7 @@ class TestWsTransport(base.TestBase): os_opts = { 'os_auth_token': 'FAKE_TOKEN', 'os_auth_url': 'http://127.0.0.0:5000/v3', - 'os_project_id': 'admin', + 'project_id': 'admin', 'os_service_type': 'messaging-websocket', } auth_opts = {'backend': 'keystone', diff --git a/zaqarclient/tests/base.py b/zaqarclient/tests/base.py index 173b22e8..c23affb2 100644 --- a/zaqarclient/tests/base.py +++ b/zaqarclient/tests/base.py @@ -37,7 +37,7 @@ class TestBase(testtools.TestCase): 'auth_opts': { 'backend': 'noauth', 'options': { - 'os_project_id': 'my-project' + 'project_id': 'my-project' } } } @@ -90,7 +90,7 @@ class TestBase(testtools.TestCase): options = {'os_username': self.creds['username'], 'os_password': self.creds['password'], 'os_project_name': self.creds['project_name'], - 'os_project_id': '', + 'project_id': '', 'os_auth_url': auth_url} self.conf['auth_opts'].setdefault('options', {}).update(options) diff --git a/zaqarclient/tests/queues/queues.py b/zaqarclient/tests/queues/queues.py index 88ca1d29..fb351f7e 100644 --- a/zaqarclient/tests/queues/queues.py +++ b/zaqarclient/tests/queues/queues.py @@ -600,7 +600,7 @@ class QueuesV2QueueFunctionalTest(QueuesV1_1QueueFunctionalTest): 'expires': signature['expires'], 'methods': signature['methods'], 'signature': signature['signature'], - 'os_project_id': signature['project'], + 'project_id': signature['project'], } auth_opts = {'backend': 'signed-url', 'options': opts} diff --git a/zaqarclient/transport/request.py b/zaqarclient/transport/request.py index 8a9821a2..cb698cd5 100644 --- a/zaqarclient/transport/request.py +++ b/zaqarclient/transport/request.py @@ -45,7 +45,7 @@ def prepare_request(auth_opts=None, data=None, **kwargs): auth_backend = auth.get_backend(**(auth_opts or {})) req = auth_backend.authenticate(kwargs.get('api'), req) - project_id = auth_opts.get('options', {}).get('os_project_id', {}) + project_id = auth_opts.get('options', {}).get('project_id', None) # Let's add project id header, only if it will have non-empty value. if project_id: diff --git a/zaqarclient/transport/ws.py b/zaqarclient/transport/ws.py index ab22d1ef..b55355a5 100644 --- a/zaqarclient/transport/ws.py +++ b/zaqarclient/transport/ws.py @@ -42,7 +42,7 @@ class WebsocketTransport(base.Transport): 'backend': 'keystone', 'options': { 'os_auth_token': ks.auth_token, - 'os_project_id': CONF.zaqar.project_id + 'project_id': CONF.zaqar.project_id } } } @@ -57,7 +57,7 @@ class WebsocketTransport(base.Transport): """ def __init__(self, options): super(WebsocketTransport, self).__init__(options) - self._project_id = options['auth_opts']['options']['os_project_id'] + self._project_id = options['auth_opts']['options']['project_id'] self._token = options['auth_opts']['options']['os_auth_token'] self._websocket_client_id = None self._ws = None