From 6567e80b1f4e67ec03826c3849fedd4765e2e382 Mon Sep 17 00:00:00 2001 From: dmaier-redislabs Date: Tue, 25 Jun 2024 10:54:19 +0200 Subject: [PATCH 1/4] Fixes CAE-333, which uncovered that the init method of the base class did override the initialization of the socket_timeout parameter. --- redis/connection.py | 3 ++- tests/test_connect.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/redis/connection.py b/redis/connection.py index f745ecc1d5..e477036f7a 100644 --- a/redis/connection.py +++ b/redis/connection.py @@ -909,9 +909,10 @@ class UnixDomainSocketConnection(AbstractConnection): "Manages UDS communication to and from a Redis server" def __init__(self, path="", socket_timeout=None, **kwargs): + super().__init__(**kwargs) self.path = path self.socket_timeout = socket_timeout - super().__init__(**kwargs) + def repr_pieces(self): pieces = [("path", self.path), ("db", self.db)] diff --git a/tests/test_connect.py b/tests/test_connect.py index 71986dd8f3..ab0f26be65 100644 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -98,6 +98,20 @@ def test_tcp_ssl_tls12_custom_ciphers(tcp_address, ssl_ciphers): _assert_connect(conn, tcp_address, certfile=certfile, keyfile=keyfile) +''' +Addresses bug CAE-333 which uncovered that the init method of the base +class did override the initialization of the socket_timeout parameter. +''' +def test_unix_socket_with_timeout(): + conn = UnixDomainSocketConnection(socket_timeout=1000) + + # Check if the base class defaults were taken over. + assert conn.db == 0 + + # Verify if the timeout and the path is set correctly. + assert conn.socket_timeout == 1000 + assert conn.path == "" + @pytest.mark.ssl @pytest.mark.skipif(not ssl.HAS_TLSv1_3, reason="requires TLSv1.3") def test_tcp_ssl_version_mismatch(tcp_address): From e63bfb8676ed1fba1a3b2a6df7ca1953a2cafc11 Mon Sep 17 00:00:00 2001 From: vladvildanov Date: Tue, 25 Jun 2024 12:58:41 +0300 Subject: [PATCH 2/4] Added missing blank lines --- tests/test_connect.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_connect.py b/tests/test_connect.py index ab0f26be65..caf9144554 100644 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -102,6 +102,8 @@ def test_tcp_ssl_tls12_custom_ciphers(tcp_address, ssl_ciphers): Addresses bug CAE-333 which uncovered that the init method of the base class did override the initialization of the socket_timeout parameter. ''' + + def test_unix_socket_with_timeout(): conn = UnixDomainSocketConnection(socket_timeout=1000) @@ -112,6 +114,7 @@ def test_unix_socket_with_timeout(): assert conn.socket_timeout == 1000 assert conn.path == "" + @pytest.mark.ssl @pytest.mark.skipif(not ssl.HAS_TLSv1_3, reason="requires TLSv1.3") def test_tcp_ssl_version_mismatch(tcp_address): From a8f4225a6e6c97b89dc511f4ffef321bb6ede714 Mon Sep 17 00:00:00 2001 From: vladvildanov Date: Tue, 25 Jun 2024 13:31:51 +0300 Subject: [PATCH 3/4] Removed blank line --- redis/connection.py | 1 - 1 file changed, 1 deletion(-) diff --git a/redis/connection.py b/redis/connection.py index e477036f7a..728c221257 100644 --- a/redis/connection.py +++ b/redis/connection.py @@ -913,7 +913,6 @@ def __init__(self, path="", socket_timeout=None, **kwargs): self.path = path self.socket_timeout = socket_timeout - def repr_pieces(self): pieces = [("path", self.path), ("db", self.db)] if self.client_name: From 07fc10e473cf9f2cc8f563b7225e6860f256951e Mon Sep 17 00:00:00 2001 From: vladvildanov Date: Tue, 25 Jun 2024 13:33:27 +0300 Subject: [PATCH 4/4] Changed to quotes --- tests/test_connect.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_connect.py b/tests/test_connect.py index caf9144554..d7ca04b651 100644 --- a/tests/test_connect.py +++ b/tests/test_connect.py @@ -98,10 +98,10 @@ def test_tcp_ssl_tls12_custom_ciphers(tcp_address, ssl_ciphers): _assert_connect(conn, tcp_address, certfile=certfile, keyfile=keyfile) -''' +""" Addresses bug CAE-333 which uncovered that the init method of the base class did override the initialization of the socket_timeout parameter. -''' +""" def test_unix_socket_with_timeout():