Fixes wrong hrefs when getting set of messages

Based on current implement, an additional path /messages will be
added, see http://git.openstack.org/cgit/openstack/marconi/queues
/transport/wsgi/messages.py#L208
However, the /messages path has been already included in the URL.
So this fix just remove it and use req.path directly.

Fixes bug 1240897

Change-Id: Ie4bf6d3df62a5b861a8fe8c6392eb8bd6bf57c2c
This commit is contained in:
Fei Long Wang 2013-11-23 17:59:01 +08:00
parent dc689e6529
commit 14b02b7685
2 changed files with 18 additions and 2 deletions

View File

@ -205,8 +205,7 @@ class CollectionResource(object):
if ids is None:
response = self._get(req, project_id, queue_name)
else:
base_path = req.path + '/messages'
response = self._get_by_id(base_path, project_id, queue_name, ids)
response = self._get_by_id(req.path, project_id, queue_name, ids)
if response is None:
resp.status = falcon.HTTP_204

View File

@ -420,6 +420,23 @@ class MessagesBaseTest(base.TestBase):
self.simulate_get(location, self.project_id)
self.assertEqual(self.srmock.status, falcon.HTTP_200)
def test_no_duplicated_messages_path_in_href(self):
"""Fixes bug 1240897
"""
path = self.queue_path + '/messages'
self._post_messages(path, repeat=1)
msg_id = self._get_msg_id(self.srmock.headers_dict)
query_string = 'ids=%s' % msg_id
body = self.simulate_get(path, self.project_id,
query_string=query_string,
headers=self.headers)
messages = json.loads(body[0])
self.assertNotIn(self.queue_path + '/messages/messages',
messages[0]['href'])
def _post_messages(self, target, repeat=1):
doc = json.dumps([{'body': 239, 'ttl': 300}] * repeat)
return self.simulate_post(target, self.project_id, body=doc,