summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorMatus Valo <matusvalo@gmail.com>2021-11-05 23:47:06 +0100
committerAsif Saif Uddin <auvipy@gmail.com>2021-11-06 13:26:44 +0600
commit34500e1e2c1a1897ca38702cd43a777012977081 (patch)
tree635222bfe6c6e0cb3eac35151d6970d105f2458a /t
parent83914031866ea25054f6d6e150580b5b4f598786 (diff)
downloadkombu-34500e1e2c1a1897ca38702cd43a777012977081.tar.gz
Added integration test of failed authentication to redis
Diffstat (limited to 't')
-rw-r--r--t/integration/test_redis.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/t/integration/test_redis.py b/t/integration/test_redis.py
index 0d38efb6..72ba803f 100644
--- a/t/integration/test_redis.py
+++ b/t/integration/test_redis.py
@@ -2,6 +2,7 @@ import os
from time import sleep
import pytest
+import redis
import kombu
@@ -9,9 +10,15 @@ from .common import BaseExchangeTypes, BasePriority, BasicFunctionality
def get_connection(
- hostname, port, vhost, transport_options=None):
+ hostname, port, vhost, user_name=None, password=None,
+ transport_options=None):
+
+ credentials = f'{user_name}:{password}@' if user_name else ''
+
return kombu.Connection(
- f'redis://{hostname}:{port}', transport_options=transport_options)
+ f'redis://{credentials}{hostname}:{port}',
+ transport_options=transport_options
+ )
@pytest.fixture(params=[None, {'global_keyprefix': '_prefixed_'}])
@@ -33,6 +40,19 @@ def invalid_connection():
@pytest.mark.env('redis')
+def test_failed_credentials():
+ """Tests denied connection when wrong credentials were provided"""
+ with pytest.raises(redis.exceptions.ResponseError):
+ get_connection(
+ hostname=os.environ.get('REDIS_HOST', 'localhost'),
+ port=os.environ.get('REDIS_6379_TCP', '6379'),
+ vhost=None,
+ user_name='wrong_redis_user',
+ password='wrong_redis_password'
+ ).connect()
+
+
+@pytest.mark.env('redis')
@pytest.mark.flaky(reruns=5, reruns_delay=2)
class test_RedisBasicFunctionality(BasicFunctionality):
pass