Permalink
Browse files

Parse password from Redis transport URL (#710)

1 parent 7152705 commit da047e9c3b1b5aa013c769433c91a4a497f6dde5 @georgepsarakis georgepsarakis committed with thedrow Apr 27, 2017
Showing with 16 additions and 1 deletion.
  1. +2 −1 kombu/transport/redis.py
  2. +14 −0 t/unit/transport/test_redis.py
View
@@ -894,7 +894,7 @@ def _connparams(self, async=False):
pass
host = connparams['host']
if '://' in host:
- scheme, _, _, _, _, path, query = _parse_url(host)
+ scheme, _, _, _, password, path, query = _parse_url(host)
if scheme == 'socket':
connparams = self._filter_tcp_connparams(**connparams)
connparams.update({
@@ -904,6 +904,7 @@ def _connparams(self, async=False):
connparams.pop('socket_connect_timeout', None)
connparams.pop('socket_keepalive', None)
connparams.pop('socket_keepalive_options', None)
+ connparams['password'] = password
connparams.pop('host', None)
connparams.pop('port', None)
@@ -663,6 +663,20 @@ def test_connparams_regular_hostname(self):
self.channel.connection.client.hostname = 'george.vandelay.com'
assert self.channel._connparams()['host'] == 'george.vandelay.com'
+ def test_connparams_password_for_unix_socket(self):
+ self.channel.connection.client.hostname = \
+ 'socket://:foo@/var/run/redis.sock'
+ connection_parameters = self.channel._connparams()
+ password = connection_parameters['password']
+ path = connection_parameters['path']
+ assert (password, path) == ('foo', '/var/run/redis.sock')
+ self.channel.connection.client.hostname = \
+ 'socket://@/var/run/redis.sock'
+ connection_parameters = self.channel._connparams()
+ password = connection_parameters['password']
+ path = connection_parameters['path']
+ assert (password, path) == (None, '/var/run/redis.sock')
+
def test_rotate_cycle_ValueError(self):
cycle = self.channel._queue_cycle
cycle.update(['kramer', 'jerry'])

0 comments on commit da047e9

Please sign in to comment.