diff options
author | Paul Keene <paulkeene4@gmail.com> | 2015-02-09 14:21:39 -0800 |
---|---|---|
committer | Paul Keene <paulkeene4@gmail.com> | 2015-02-09 16:22:53 -0800 |
commit | 904dd00e901473cd15f7e645a1cecdd45de0ffc6 (patch) | |
tree | f1f0677b5a4d76c87a799170aae1dec8e76f550a /tests/test_connection_pool.py | |
parent | c4e2f56dbf6e04a23e6a346ac54278cfbf4035e1 (diff) | |
download | redis-py-904dd00e901473cd15f7e645a1cecdd45de0ffc6.tar.gz |
Handle percent-encoded URLs in parsing code
Diffstat (limited to 'tests/test_connection_pool.py')
-rw-r--r-- | tests/test_connection_pool.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/test_connection_pool.py b/tests/test_connection_pool.py index 55ccce1..6b2478a 100644 --- a/tests/test_connection_pool.py +++ b/tests/test_connection_pool.py @@ -163,6 +163,17 @@ class TestConnectionPoolURLParsing(object): 'password': None, } + def test_quoted_hostname(self): + pool = redis.ConnectionPool.from_url('redis://my %2F host %2B%3D+', + decode_components=True) + assert pool.connection_class == redis.Connection + assert pool.connection_kwargs == { + 'host': 'my / host +=+', + 'port': 6379, + 'db': 0, + 'password': None, + } + def test_port(self): pool = redis.ConnectionPool.from_url('redis://localhost:6380') assert pool.connection_class == redis.Connection @@ -183,6 +194,18 @@ class TestConnectionPoolURLParsing(object): 'password': 'mypassword', } + def test_quoted_password(self): + pool = redis.ConnectionPool.from_url( + 'redis://:%2Fmypass%2F%2B word%3D%24+@localhost', + decode_components=True) + assert pool.connection_class == redis.Connection + assert pool.connection_kwargs == { + 'host': 'localhost', + 'port': 6379, + 'db': 0, + 'password': '/mypass/+ word=$+', + } + def test_db_as_argument(self): pool = redis.ConnectionPool.from_url('redis://localhost', db='1') assert pool.connection_class == redis.Connection @@ -260,6 +283,28 @@ class TestConnectionPoolUnixSocketURLParsing(object): 'password': 'mypassword', } + def test_quoted_password(self): + pool = redis.ConnectionPool.from_url( + 'unix://:%2Fmypass%2F%2B word%3D%24+@/socket', + decode_components=True) + assert pool.connection_class == redis.UnixDomainSocketConnection + assert pool.connection_kwargs == { + 'path': '/socket', + 'db': 0, + 'password': '/mypass/+ word=$+', + } + + def test_quoted_path(self): + pool = redis.ConnectionPool.from_url( + 'unix://:mypassword@/my%2Fpath%2Fto%2F..%2F+_%2B%3D%24ocket', + decode_components=True) + assert pool.connection_class == redis.UnixDomainSocketConnection + assert pool.connection_kwargs == { + 'path': '/my/path/to/../+_+=$ocket', + 'db': 0, + 'password': 'mypassword', + } + def test_db_as_argument(self): pool = redis.ConnectionPool.from_url('unix:///socket', db=1) assert pool.connection_class == redis.UnixDomainSocketConnection |