summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/conftest.py16
-rw-r--r--tests/test_ssl.py17
2 files changed, 33 insertions, 0 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 4b5f6cb..65e5369 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -14,6 +14,7 @@ from redis.retry import Retry
REDIS_INFO = {}
default_redis_url = "redis://localhost:6379/9"
+default_redis_ssl_url = "rediss://localhost:6666"
default_redismod_url = "redis://localhost:36379"
default_cluster_nodes = 6
@@ -35,6 +36,13 @@ def pytest_addoption(parser):
" with loaded modules,"
" defaults to `%(default)s`",
)
+
+ parser.addoption(
+ "--redis-ssl-url",
+ default=default_redis_ssl_url,
+ action="store",
+ help="Redis SSL connection string," " defaults to `%(default)s`",
+ )
parser.addoption(
"--redis-cluster-nodes",
@@ -227,6 +235,14 @@ def modclient(request, **kwargs):
redis.Redis, request, from_url=rmurl, decode_responses=True, **kwargs
) as client:
yield client
+
+# @pytest.fixture()
+# def sslclient(request, **kwargs):
+# ssl_url = request.config.getoption("--redis-ssl-url")
+# with _get_client(
+# redis.Redis, request, from_url=ssl_url, decode_responses=True, **kwargs
+# ) as client:
+# yield client
@pytest.fixture()
diff --git a/tests/test_ssl.py b/tests/test_ssl.py
new file mode 100644
index 0000000..4064ae3
--- /dev/null
+++ b/tests/test_ssl.py
@@ -0,0 +1,17 @@
+import pytest
+import redis
+from redis.exceptions import ConnectionError
+
+
+class TestSSL:
+ """Tests for SSL connections"""
+
+ def test_ssl_with_invalid_cert(self, request):
+ ssl_url = request.config.option.redis_ssl_url
+ sslclient = redis.from_url(ssl_url)
+ with pytest.raises(ConnectionError) as e:
+ sslclient.ping()
+ assert 'SSL: CERTIFICATE_VERIFY_FAILED' in str(e)
+
+ def test_ssl_connection_creation(self, sslclient):
+ assert sslclient.ping() \ No newline at end of file