diff --git a/marconi/queues/transport/wsgi/messages.py b/marconi/queues/transport/wsgi/messages.py index f7919cc29..77732136d 100644 --- a/marconi/queues/transport/wsgi/messages.py +++ b/marconi/queues/transport/wsgi/messages.py @@ -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 diff --git a/tests/unit/queues/transport/wsgi/test_messages.py b/tests/unit/queues/transport/wsgi/test_messages.py index 5e977cb86..f958bb120 100644 --- a/tests/unit/queues/transport/wsgi/test_messages.py +++ b/tests/unit/queues/transport/wsgi/test_messages.py @@ -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,