-
-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
192b813
commit 8e04922
Showing
1 changed file
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,3 +149,80 @@ def test_unknown_backend(): | |
def test_empty_url_is_mapped_to_empty_config(): | ||
assert Env.cache_url_config('') == {} | ||
assert Env.cache_url_config(None) == {} | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'chars', | ||
['!', '$', '&', "'", '(', ')', '*', '+', ';', '=', '-', '.', '-v1.2'] | ||
) | ||
def test_cache_url_password_using_sub_delims(monkeypatch, chars): | ||
"""Ensure CACHE_URL passwords may contains some unsafe characters. | ||
See: https://github.com/joke2k/django-environ/issues/200 for details.""" | ||
url = 'rediss://enigma:secret{}@ondigitalocean.com:25061/2'.format(chars) | ||
monkeypatch.setenv('CACHE_URL', url) | ||
env = Env() | ||
|
||
result = env.cache() | ||
assert result['BACKEND'] == 'django_redis.cache.RedisCache' | ||
assert result['LOCATION'] == url | ||
|
||
result = env.cache_url_config(url) | ||
assert result['BACKEND'] == 'django_redis.cache.RedisCache' | ||
assert result['LOCATION'] == url | ||
|
||
url = 'rediss://enigma:sec{}[email protected]:25061/2'.format(chars) | ||
monkeypatch.setenv('CACHE_URL', url) | ||
env = Env() | ||
|
||
result = env.cache() | ||
assert result['BACKEND'] == 'django_redis.cache.RedisCache' | ||
assert result['LOCATION'] == url | ||
|
||
result = env.cache_url_config(url) | ||
assert result['BACKEND'] == 'django_redis.cache.RedisCache' | ||
assert result['LOCATION'] == url | ||
|
||
url = 'rediss://enigma:{}[email protected]:25061/2'.format(chars) | ||
monkeypatch.setenv('CACHE_URL', url) | ||
env = Env() | ||
|
||
result = env.cache() | ||
assert result['BACKEND'] == 'django_redis.cache.RedisCache' | ||
assert result['LOCATION'] == url | ||
|
||
result = env.cache_url_config(url) | ||
assert result['BACKEND'] == 'django_redis.cache.RedisCache' | ||
assert result['LOCATION'] == url | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'chars', ['%3A', '%2F', '%3F', '%23', '%5B', '%5D', '%40', '%2C'] | ||
) | ||
def test_cache_url_password_using_gen_delims(monkeypatch, chars): | ||
"""Ensure CACHE_URL passwords may contains %-encoded characters. | ||
See: https://github.com/joke2k/django-environ/issues/200 for details.""" | ||
url = 'rediss://enigma:secret{}@ondigitalocean.com:25061/2'.format(chars) | ||
monkeypatch.setenv('CACHE_URL', url) | ||
env = Env() | ||
|
||
result = env.cache() | ||
assert result['BACKEND'] == 'django_redis.cache.RedisCache' | ||
assert result['LOCATION'] == url | ||
|
||
url = 'rediss://enigma:sec{}[email protected]:25061/2'.format(chars) | ||
monkeypatch.setenv('CACHE_URL', url) | ||
env = Env() | ||
|
||
result = env.cache() | ||
assert result['BACKEND'] == 'django_redis.cache.RedisCache' | ||
assert result['LOCATION'] == url | ||
|
||
url = 'rediss://enigma:{}[email protected]:25061/2'.format(chars) | ||
monkeypatch.setenv('CACHE_URL', url) | ||
env = Env() | ||
|
||
result = env.cache() | ||
assert result['BACKEND'] == 'django_redis.cache.RedisCache' | ||
assert result['LOCATION'] == url |