Don't encode path separators
Encoding the path separators results in urls refused by by apache
with 404 unless AllowEncodedSlashes is turned on, which is not
the default.
The existing encoding of path separators seems unnecessary.
MODIFY
heatclient/tests/unit/test_events.py
heatclient/tests/unit/test_events.py
@@ -33,7 +33,7 @@ class EventManagerTest(testtools.TestCase):
manager.list(stack_id, resource_name)
# Make sure url is correct.
manager._list.assert_called_once_with(
- '/stacks/teststack%2Fabcd1234/'
+ '/stacks/teststack/abcd1234/'
'resources/testresource/events',
"events")
mock_re.assert_called_once_with(stack_id)
@@ -50,7 +50,7 @@ class EventManagerTest(testtools.TestCase):
manager.list(stack_id, resource_name)
# Make sure url is correct.
manager._list.assert_called_once_with(
- '/stacks/teststack%2Fabcd1234/'
+ '/stacks/teststack/abcd1234/'
'resources/%E5%B7%A5%E4%BD%9C/'
'events', "events")
mock_re.assert_called_once_with(stack_id)
@@ -88,7 +88,7 @@ class EventManagerTest(testtools.TestCase):
url, param = args[0]
self.assertEqual("events", param)
base_url, query_params = utils.parse_query_url(url)
- expected_base_url = ('/stacks/teststack%2Fabcd1234/'
+ expected_base_url = ('/stacks/teststack/abcd1234/'
'resources/testresource/events')
self.assertEqual(expected_base_url, base_url)
expected_query_dict = {'marker': ['6d6935f4-0ae5'],
@@ -110,7 +110,7 @@ class EventManagerTest(testtools.TestCase):
def json_request(self, *args, **kwargs):
expect = ('GET',
- '/stacks/teststack%2Fabcd1234/resources'
+ '/stacks/teststack/abcd1234/resources'
'/testresource/events/1')
assert args == expect
return {}, {'event': []}
@@ -137,7 +137,7 @@ class EventManagerTest(testtools.TestCase):
def json_request(self, *args, **kwargs):
expect = ('GET',
- '/stacks/teststack%2Fabcd1234/resources'
+ '/stacks/teststack/abcd1234/resources'
'/%E5%B7%A5%E4%BD%9C/events/1')
assert args == expect
return {}, {'event': []}

MODIFY
heatclient/tests/unit/test_resources.py
heatclient/tests/unit/test_resources.py
@@ -73,7 +73,7 @@ class ResourceManagerTest(testtools.TestCase):
fields = {'stack_id': 'teststack',
'resource_name': 'testresource'}
expect = ('GET',
- '/stacks/teststack%2Fabcd1234/resources'
+ '/stacks/teststack/abcd1234/resources'
'/testresource')
key = 'resource'
@@ -86,7 +86,7 @@ class ResourceManagerTest(testtools.TestCase):
'resource_name': 'testresource',
'with_attr': ['attr_a', 'attr_b']}
expect = ('GET',
- '/stacks/teststack%2Fabcd1234/resources'
+ '/stacks/teststack/abcd1234/resources'
'/testresource?with_attr=attr_a&with_attr=attr_b')
key = 'resource'
@@ -98,7 +98,7 @@ class ResourceManagerTest(testtools.TestCase):
fields = {'stack_id': 'teststack',
'resource_name': u'\u5de5\u4f5c'}
expect = ('GET',
- '/stacks/teststack%2Fabcd1234/resources'
+ '/stacks/teststack/abcd1234/resources'
'/%E5%B7%A5%E4%BD%9C')
key = 'resource'
@@ -154,7 +154,7 @@ class ResourceManagerTest(testtools.TestCase):
fields = {'stack_id': 'teststack',
'resource_name': 'testresource'}
expect = ('GET',
- '/stacks/teststack%2Fabcd1234/resources'
+ '/stacks/teststack/abcd1234/resources'
'/testresource/metadata')
key = 'metadata'
@@ -192,7 +192,7 @@ class ResourceManagerTest(testtools.TestCase):
'resource_name': 'testresource',
'data': 'Some content'}
expect = ('POST',
- '/stacks/teststack%2Fabcd1234/resources'
+ '/stacks/teststack/abcd1234/resources'
'/testresource/signal')
key = 'signal'
@@ -206,7 +206,7 @@ class ResourceManagerTest(testtools.TestCase):
'mark_unhealthy': 'True',
'resource_status_reason': 'Anything'}
expect = ('PATCH',
- '/stacks/teststack%2Fabcd1234/resources'
+ '/stacks/teststack/abcd1234/resources'
'/testresource')
key = 'mark_unhealthy'

MODIFY
heatclient/tests/unit/test_shell.py
heatclient/tests/unit/test_shell.py
@@ -563,7 +563,7 @@ class ShellTestNoMox(TestCase):
rsrc_eventid2=eventid2
)
- self.requests.get('http://heat.example.com/stacks/myStack%2F60f83b5e/'
+ self.requests.get('http://heat.example.com/stacks/myStack/60f83b5e/'
'resources/myDeployment/events',
headers={'Content-Type': 'application/json'},
json=resp_dict)
@@ -2622,9 +2622,9 @@ class ShellTestEvents(ShellBase):
resource_name = 'testresource/1'
self.mock_request_get(
'/stacks/%s/resources/%s/events?sort_dir=asc' % (
- parse.quote(stack_id, ''),
+ parse.quote(stack_id),
parse.quote(encodeutils.safe_encode(
- resource_name), '')),
+ resource_name))),
resp_dict)
self.m.ReplayAll()
@@ -2698,10 +2698,10 @@ class ShellTestEvents(ShellBase):
self.mock_request_get(
'/stacks/%s/resources/%s/events/%s' %
(
- parse.quote(stack_id, ''),
+ parse.quote(stack_id),
parse.quote(encodeutils.safe_encode(
- resource_name), ''),
- parse.quote(self.event_id_one, '')
+ resource_name)),
+ parse.quote(self.event_id_one)
),
resp_dict)
@@ -3281,9 +3281,9 @@ class ShellTestResources(ShellBase):
self.mock_request_get(
'/stacks/%s/resources/%s?with_attr=attr_a&with_attr=attr_b' %
(
- parse.quote(stack_id, ''),
+ parse.quote(stack_id),
parse.quote(encodeutils.safe_encode(
- resource_name), '')
+ resource_name))
), resp_dict)
self.m.ReplayAll()
@@ -3323,9 +3323,9 @@ class ShellTestResources(ShellBase):
self.mock_request_post(
'/stacks/%s/resources/%s/signal' %
(
- parse.quote(stack_id, ''),
+ parse.quote(stack_id),
parse.quote(encodeutils.safe_encode(
- resource_name), '')
+ resource_name))
),
'',
data={'message': 'Content'}
@@ -3345,9 +3345,9 @@ class ShellTestResources(ShellBase):
self.mock_request_post(
'/stacks/%s/resources/%s/signal' %
(
- parse.quote(stack_id, ''),
+ parse.quote(stack_id),
parse.quote(encodeutils.safe_encode(
- resource_name), '')
+ resource_name))
),
'',
data=None
@@ -3405,9 +3405,9 @@ class ShellTestResources(ShellBase):
self.mock_request_post(
'/stacks/%s/resources/%s/signal' %
(
- parse.quote(stack_id, ''),
+ parse.quote(stack_id),
parse.quote(encodeutils.safe_encode(
- resource_name), '')
+ resource_name))
),
'',
data={'message': 'Content'}
@@ -3430,9 +3430,9 @@ class ShellTestResources(ShellBase):
self.mock_request_patch(
'/stacks/%s/resources/%s' %
(
- parse.quote(stack_id, ''),
+ parse.quote(stack_id),
parse.quote(encodeutils.safe_encode(
- resource_name), '')
+ resource_name))
),
'',
req_headers=False,
@@ -3453,9 +3453,9 @@ class ShellTestResources(ShellBase):
self.mock_request_patch(
'/stacks/%s/resources/%s' %
(
- parse.quote(stack_id, ''),
+ parse.quote(stack_id),
parse.quote(encodeutils.safe_encode(
- resource_name), '')
+ resource_name))
),
'',
req_headers=False,
@@ -3476,9 +3476,9 @@ class ShellTestResources(ShellBase):
self.mock_request_patch(
'/stacks/%s/resources/%s' %
(
- parse.quote(stack_id, ''),
+ parse.quote(stack_id),
parse.quote(encodeutils.safe_encode(
- resource_name), '')
+ resource_name))
),
'',
req_headers=False,

MODIFY
heatclient/v1/events.py
heatclient/v1/events.py
@@ -63,8 +63,8 @@ class EventManager(stacks.StackChildManager):
else:
stack_id = self._resolve_stack_id(stack_id)
url = '/stacks/%s/resources/%s/events' % (
- parse.quote(stack_id, ''),
- parse.quote(encodeutils.safe_encode(resource_name), ''))
+ parse.quote(stack_id),
+ parse.quote(encodeutils.safe_encode(resource_name)))
if params:
# convert to a sorted dict for python3 predictible order
params = collections.OrderedDict(sorted(params.items()))
@@ -81,8 +81,8 @@ class EventManager(stacks.StackChildManager):
"""
stack_id = self._resolve_stack_id(stack_id)
url_str = '/stacks/%s/resources/%s/events/%s' % (
- parse.quote(stack_id, ''),
- parse.quote(encodeutils.safe_encode(resource_name), ''),
+ parse.quote(stack_id),
+ parse.quote(encodeutils.safe_encode(resource_name)),
parse.quote(event_id, ''))
resp = self.client.get(url_str)
body = utils.get_response_body(resp)

MODIFY
heatclient/v1/resource_types.py
heatclient/v1/resource_types.py
@@ -68,7 +68,7 @@ class ResourceTypeManager(base.BaseManager):
"""
url_str = '/%s/%s' % (
self.KEY,
- parse.quote(encodeutils.safe_encode(resource_type), ''))
+ parse.quote(encodeutils.safe_encode(resource_type)))
resp = self.client.get(url_str,
params={'with_description': with_description})
body = utils.get_response_body(resp)
@@ -77,7 +77,7 @@ class ResourceTypeManager(base.BaseManager):
def generate_template(self, resource_type, template_type='cfn'):
url_str = '/%s/%s/template' % (
self.KEY,
- parse.quote(encodeutils.safe_encode(resource_type), ''))
+ parse.quote(encodeutils.safe_encode(resource_type)))
if template_type:
url_str += '?%s' % parse.urlencode(
{'template_type': template_type}, True)

MODIFY
heatclient/v1/resources.py
heatclient/v1/resources.py
@@ -79,8 +79,8 @@ class ResourceManager(stacks.StackChildManager):
"""
stack_id = self._resolve_stack_id(stack_id)
url_str = '/stacks/%s/resources/%s' % (
- parse.quote(stack_id, ''),
- parse.quote(encodeutils.safe_encode(resource_name), ''))
+ parse.quote(stack_id),
+ parse.quote(encodeutils.safe_encode(resource_name)))
if with_attr:
params = {'with_attr': with_attr}
url_str += '?%s' % parse.urlencode(params, True)
@@ -97,8 +97,8 @@ class ResourceManager(stacks.StackChildManager):
"""
stack_id = self._resolve_stack_id(stack_id)
url_str = '/stacks/%s/resources/%s/metadata' % (
- parse.quote(stack_id, ''),
- parse.quote(encodeutils.safe_encode(resource_name), ''))
+ parse.quote(stack_id),
+ parse.quote(encodeutils.safe_encode(resource_name)))
resp = self.client.get(url_str)
body = utils.get_response_body(resp)
return body.get('metadata')
@@ -111,8 +111,8 @@ class ResourceManager(stacks.StackChildManager):
"""
stack_id = self._resolve_stack_id(stack_id)
url_str = '/stacks/%s/resources/%s/signal' % (
- parse.quote(stack_id, ''),
- parse.quote(encodeutils.safe_encode(resource_name), ''))
+ parse.quote(stack_id),
+ parse.quote(encodeutils.safe_encode(resource_name)))
resp = self.client.post(url_str, data=data)
body = utils.get_response_body(resp)
return body
@@ -128,8 +128,8 @@ class ResourceManager(stacks.StackChildManager):
"""
stack_id = self._resolve_stack_id(stack_id)
url_str = '/stacks/%s/resources/%s' % (
- parse.quote(stack_id, ''),
- parse.quote(encodeutils.safe_encode(resource_name), ''))
+ parse.quote(stack_id),
+ parse.quote(encodeutils.safe_encode(resource_name)))
resp = self.client.patch(
url_str,
data={"mark_unhealthy": mark_unhealthy,
@@ -142,7 +142,7 @@ class ResourceManager(stacks.StackChildManager):
"""Deprecated in favor of generate_template in ResourceTypeManager."""
url_str = '/resource_types/%s/template' % (
- parse.quote(encodeutils.safe_encode(resource_name), ''))
+ parse.quote(encodeutils.safe_encode(resource_name)))
resp = self.client.get(url_str)
body = utils.get_response_body(resp)
return body

MODIFY
heatclient/v1/software_deployments.py
heatclient/v1/software_deployments.py
@@ -44,7 +44,7 @@ class SoftwareDeploymentManager(base.BaseManager):
:rtype: list of :class:`SoftwareDeployment`
"""
url = '/software_deployments/metadata/%s' % parse.quote(
- server_id, '')
+ server_id)
resp = self.client.get(url)
body = utils.get_response_body(resp)
return body.get('metadata')

MODIFY
heatclient/v1/template_versions.py
heatclient/v1/template_versions.py
@@ -41,7 +41,7 @@ class TemplateVersionManager(base.BaseManager):
:param template_version: template version to get the functions for
"""
url_str = '/template_versions/%s/functions' % (
- parse.quote(encodeutils.safe_encode(template_version), ''))
+ parse.quote(encodeutils.safe_encode(template_version)))
params = {}
if 'with_condition_func' in kwargs:

Don't encode path separators

Encoding the path separators results in urls refused by by apache
with 404 unless AllowEncodedSlashes is turned on, which is not
the default.

The existing encoding of path separators seems unnecessary.

Change-Id: I3b77aafc6104119503363e5db36b0379964daba5