[rabbitmq_binding] Fix the quoting of vhost and other names (#45109)

* [rabbitmq_binding] Fix the quoting of vhost and other names, which was broken in PR #35651
* Merge missing urllib_parse.quote from PR #42422
* Missed one line, where  also needs to be escaped, i.e., the destination

(cherry picked from commit d5f8738bf2)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Tobias Wolf 2018-09-25 07:34:41 +02:00 committed by Toshio Kuratomi
parent 93b75558bb
commit ee523beb8e
2 changed files with 9 additions and 7 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- Fix the quoting of vhost and other names in rabbitmq_binding

View file

@ -125,11 +125,11 @@ class RabbitMqBinding(object):
self.base_url = 'http://{0}:{1}/api/bindings'.format(self.login_host, self.base_url = 'http://{0}:{1}/api/bindings'.format(self.login_host,
self.login_port) self.login_port)
self.url = '{0}/{1}/e/{2}/{3}/{4}/{5}'.format(self.base_url, self.url = '{0}/{1}/e/{2}/{3}/{4}/{5}'.format(self.base_url,
urllib_parse.quote(self.vhost), urllib_parse.quote(self.vhost, safe=''),
urllib_parse.quote(self.name), urllib_parse.quote(self.name, safe=''),
self.destination_type, self.destination_type,
self.destination, urllib_parse.quote(self.destination, safe=''),
self.routing_key) urllib_parse.quote(self.routing_key))
self.result = { self.result = {
'changed': False, 'changed': False,
'name': self.module.params['name'], 'name': self.module.params['name'],
@ -247,10 +247,10 @@ class RabbitMqBinding(object):
:return: :return:
""" """
self.url = '{0}/{1}/e/{2}/{3}/{4}'.format(self.base_url, self.url = '{0}/{1}/e/{2}/{3}/{4}'.format(self.base_url,
urllib_parse.quote(self.vhost), urllib_parse.quote(self.vhost, safe=''),
urllib_parse.quote(self.name), urllib_parse.quote(self.name, safe=''),
self.destination_type, self.destination_type,
urllib_parse.quote(self.destination)) urllib_parse.quote(self.destination, safe=''))
self.api_result = self.request.post(self.url, self.api_result = self.request.post(self.url,
auth=self.authentication, auth=self.authentication,
headers={"content-type": "application/json"}, headers={"content-type": "application/json"},