Allow normal response to unactioned calls if aggregation disabled

Also some mild refactoring in proxy.py. Now unversioned/unactioned calls
can go through without authentication. Renamed self.detailed to the more
descriptive strip_details.

Co-Authored-By: Kristi Nikolla <knikolla@bu.edu>

Change-Id: I5c3a0ab7c020fba480319f11cd1637d5c1f07e11
This commit is contained in:
Eric Juma
2017-01-30 15:25:31 -05:00
committed by Kristi Nikolla
parent aba889e244
commit e1fab7c7ce
4 changed files with 89 additions and 60 deletions

View File

@@ -313,9 +313,9 @@ class TestServices(testcase.TestCase):
Url(VOLUME_VERSIONED))
def test_remove_details(self):
"""Test aggregation on volumes with detailed = False"""
"""Test aggregation on volumes with strip_details = True"""
response = json.loads(services.aggregate(
VOLUMES, 'volumes', 'volume', detailed=False
VOLUMES, 'volumes', 'volume', strip_details=True
))
for v in response['volumes']:
self.assertEqual(

View File

@@ -30,15 +30,18 @@ class TestVolumesV2(base.BaseTest):
# migrated to these fixtures.
self.load_auth_fixtures()
def _construct_url(self, auth, volume_id, sp=None):
def _construct_url(self, auth=None, target=None, sp=None):
if not sp:
prefix = '/volume'
url = '/volume'
else:
prefix = self.service_providers[sp]['volume_endpoint']
url = self.service_providers[sp]['volume_endpoint']
return (
'%s/v2/%s/volumes/%s' % (prefix, auth.get_project_id(), volume_id)
)
if auth:
url = '%s/v2/%s/volumes' % (url, auth.get_project_id())
if target:
url = '%s/%s' % (url, target)
return url
def test_get_volume_local_mapping(self):
volume_id = uuid.uuid4().hex
@@ -227,7 +230,7 @@ class TestVolumesV2(base.BaseTest):
headers=self.auth.get_headers())
self.assertEqual(json.loads(response.data.decode("ascii")), local)
def test_volume_unversioned_calls_no_action(self):
def test_volume_unversioned_calls_no_action_aggregation(self):
response = self.app.get(
'/volume',
headers=self.auth.get_headers())
@@ -235,6 +238,18 @@ class TestVolumesV2(base.BaseTest):
actual = json.loads(response.data.decode("ascii"))
self.assertEqual(len(actual['versions']), 3)
def test_unversioned_call_no_action_no_aggregation(self):
self.config_fixture.load_raw_values(aggregation=False)
fake_response = uuid.uuid4().hex
self.requests_fixture.get(self._construct_url(sp='default'),
text=six.u(fake_response),
headers={'CONTENT-TYPE': 'application/json'})
response = self.app.get('/volume')
self.assertEqual(response.status_code, 200)
self.assertEqual(response.data, six.b(fake_response))
def test_volume_versioned_calls_no_action(self):
response = self.app.get(
'/volume/v2',