summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristi Nikolla <kristi@nikolla.me>2018-06-07 00:27:15 -0400
committerKristi Nikolla <kristi@nikolla.me>2018-06-07 00:27:15 -0400
commit61a8444c27a5c5fbc368ac88331124e8ff219cad (patch)
tree369296bf800f93dcc5d4d1d1b7e12517892778b2
parent955f28d3973b442b93a7249b0de8570aaf7801f1 (diff)
Don't put project_id in path if it wasn't there
This fixes the case that when a request looking like http://example.com/resource/volume and containing a token comes to the proxy, we translate it to http://cinder.local/volume/<project_id> This happens because we populate the project_id information of a request either from the url, or from the token. Change-Id: Ie83fec4910eff750ba15f5485428c23ec3505e3b
Notes
Notes (review): Code-Review+2: Jeremy Freudberg <jeremyfreudberg@gmail.com> Code-Review+2: Kristi Nikolla <kristi@nikolla.me> Workflow+1: Kristi Nikolla <kristi@nikolla.me> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Thu, 07 Jun 2018 14:13:43 +0000 Reviewed-on: https://review.openstack.org/573081 Project: openstack/mixmatch Branch: refs/heads/master
-rw-r--r--mixmatch/proxy.py3
-rw-r--r--mixmatch/tests/unit/test_volumes.py16
2 files changed, 18 insertions, 1 deletions
diff --git a/mixmatch/proxy.py b/mixmatch/proxy.py
index d6592db..2001997 100644
--- a/mixmatch/proxy.py
+++ b/mixmatch/proxy.py
@@ -84,6 +84,7 @@ class RequestDetails(object):
84 self.service = get_service(local_path) 84 self.service = get_service(local_path)
85 self.version = utils.safe_pop(local_path) 85 self.version = utils.safe_pop(local_path)
86 self.project_id = utils.pop_if_uuid(local_path) 86 self.project_id = utils.pop_if_uuid(local_path)
87 self.project_in_path = True if self.project_id else False
87 self.action = local_path[:] # NOTE(knikolla): This includes 88 self.action = local_path[:] # NOTE(knikolla): This includes
88 self.resource_type = utils.safe_pop(local_path) # this 89 self.resource_type = utils.safe_pop(local_path) # this
89 self.resource_id = utils.pop_if_uuid(local_path) # and this 90 self.resource_id = utils.pop_if_uuid(local_path) # and this
@@ -194,7 +195,7 @@ class RequestHandler(object):
194 self.details.service, 195 self.details.service,
195 self.details.version, 196 self.details.version,
196 self.details.action, 197 self.details.action,
197 project_id=project_id 198 project_id=project_id if self.details.project_in_path else None
198 ) 199 )
199 200
200 request_kwargs = { 201 request_kwargs = {
diff --git a/mixmatch/tests/unit/test_volumes.py b/mixmatch/tests/unit/test_volumes.py
index 4fa583a..427e879 100644
--- a/mixmatch/tests/unit/test_volumes.py
+++ b/mixmatch/tests/unit/test_volumes.py
@@ -392,6 +392,22 @@ class TestVolumesV2(base.BaseTest):
392 self.assertEqual(response.get_data(as_text=True), 392 self.assertEqual(response.get_data(as_text=True),
393 fake_response) 393 fake_response)
394 394
395 def test_unversioned_call_no_action_no_aggregation_token(self):
396 self.config_fixture.load_raw_values(aggregation=False)
397 fake_response = uuid.uuid4().hex
398
399 self.requests_fixture.get(
400 self._construct_url(sp='default'),
401 text=fake_response,
402 status_code=200,
403 request_headers=self.auth.get_headers(),
404 headers={'CONTENT-TYPE': 'application/json'})
405
406 response = self.app.get('volume', headers=self.auth.get_headers())
407 self.assertEqual(response.status_code, 200)
408 self.assertEqual(response.get_data(as_text=True),
409 fake_response)
410
395 def test_volume_versioned_calls_no_action(self): 411 def test_volume_versioned_calls_no_action(self):
396 response = self.app.get( 412 response = self.app.get(
397 '/volume/v2', 413 '/volume/v2',