Skip to content

Commit

Permalink
base: remove the snippet specific to Redis < 6.0
Browse files Browse the repository at this point in the history
`NO_AUTH_SET_ERROR` used to be different for Redis < 6.0 and
Redis >= 6.0. It's not applicable for Valkey, hence the obsolete snippet
has been removed.

Additionally, `test_connection_pool` for both sync and async versions
have been fixed since they expected an obsolete string in the logs.

Signed-off-by: Mikhail Koviazin <mikhail.koviazin@aiven.io>
  • Loading branch information
mkmkme committed May 28, 2024
1 parent 495cdfb commit a0e20ea
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
6 changes: 5 additions & 1 deletion tests/test_asyncio/test_connection_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,11 @@ async def test_connect_no_auth_supplied_when_required(self, r):
"""
with pytest.raises(valkey.AuthenticationError):
await r.execute_command(
"DEBUG", "ERROR", "ERR Client sent AUTH, but no password is set"
"DEBUG",
"ERROR",
"ERR AUTH <password> called without any password "
"configured for the default user. Are you sure "
"your configuration is correct?",
)

async def test_connect_invalid_password_supplied(self, r):
Expand Down
7 changes: 0 additions & 7 deletions tests/test_connection_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,13 +583,6 @@ def test_connect_no_auth_configured(self, r):
AuthenticationError should be raised when the server is not configured with auth
but credentials are supplied by the user.
"""
# Redis < 6
with pytest.raises(valkey.AuthenticationError):
r.execute_command(
"DEBUG", "ERROR", "ERR Client sent AUTH, but no password is set"
)

# Redis >= 6
with pytest.raises(valkey.AuthenticationError):
r.execute_command(
"DEBUG",
Expand Down
11 changes: 4 additions & 7 deletions valkey/_parsers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,11 @@
"types, can't unload"
)
# user send an AUTH cmd to a server without authorization configured
NO_AUTH_SET_ERROR = {
# Redis >= 6.0
NO_AUTH_SET_ERROR = (
"AUTH <password> called without any password "
"configured for the default user. Are you sure "
"your configuration is correct?": AuthenticationError,
# Redis < 6.0
"Client sent AUTH, but no password is set": AuthenticationError,
}
"your configuration is correct?"
)


class BaseParser(ABC):
Expand All @@ -62,7 +59,7 @@ class BaseParser(ABC):
MODULE_EXPORTS_DATA_TYPES_ERROR: ModuleError,
NO_SUCH_MODULE_ERROR: ModuleError,
MODULE_UNLOAD_NOT_POSSIBLE_ERROR: ModuleError,
**NO_AUTH_SET_ERROR,
NO_AUTH_SET_ERROR: AuthenticationError,
},
"OOM": OutOfMemoryError,
"WRONGPASS": AuthenticationError,
Expand Down

0 comments on commit a0e20ea

Please sign in to comment.