Skip to content

Commit

Permalink
Fixes wrong hrefs when getting set of messages
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Fei Long Wang committed Dec 3, 2013
1 parent dc689e6 commit 14b02b7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 1 addition & 2 deletions marconi/queues/transport/wsgi/messages.py
Expand Up @@ -205,8 +205,7 @@ def on_get(self, req, resp, project_id, queue_name):
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
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/queues/transport/wsgi/test_messages.py
Expand Up @@ -420,6 +420,23 @@ def test_delete_message_with_invalid_claim_doesnt_delete_message(self):
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,
Expand Down

0 comments on commit 14b02b7

Please sign in to comment.