Skip to content

Commit bd5c8ac

Browse files
committed
Added tests
1 parent d416b3e commit bd5c8ac

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

tests/test_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def teardown():
9595

9696
assert r.auth(username=username, password="strong_password") is True
9797

98-
with pytest.raises(exceptions.ResponseError):
98+
with pytest.raises(exceptions.AuthenticationError):
9999
r.auth(username=username, password="wrong_password")
100100

101101
def test_command_on_invalid_key_type(self, r):

tests/test_connection_pool.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -545,22 +545,38 @@ def test_connect_from_url_unix(self):
545545
)
546546

547547
@skip_if_redis_enterprise()
548-
def test_connect_no_auth_supplied_when_required(self, r):
548+
def test_connect_no_auth_configured(self, r):
549549
"""
550-
AuthenticationError should be raised when the server requires a
551-
password but one isn't supplied.
550+
AuthenticationError should be raised when the server is not configured with auth
551+
but credentials are supplied by the user.
552552
"""
553+
# Redis < 6
553554
with pytest.raises(redis.AuthenticationError):
554555
r.execute_command(
555556
"DEBUG", "ERROR", "ERR Client sent AUTH, but no password is set"
556557
)
557558

559+
# Redis >= 6
560+
with pytest.raises(redis.AuthenticationError):
561+
r.execute_command(
562+
"DEBUG", "ERROR", "ERR AUTH <password> called without any password "
563+
"configured for the default user. Are you sure "
564+
"your configuration is correct?"
565+
)
566+
558567
@skip_if_redis_enterprise()
559-
def test_connect_invalid_password_supplied(self, r):
560-
"AuthenticationError should be raised when sending the wrong password"
568+
def test_connect_invalid_auth_credentials_supplied(self, r):
569+
"""
570+
AuthenticationError should be raised when sending invalid username/password
571+
"""
572+
# Redis < 6
561573
with pytest.raises(redis.AuthenticationError):
562574
r.execute_command("DEBUG", "ERROR", "ERR invalid password")
563575

576+
# Redis >= 6
577+
with pytest.raises(redis.AuthenticationError):
578+
r.execute_command("DEBUG", "ERROR", "WRONGPASS")
579+
564580

565581
@pytest.mark.onlynoncluster
566582
class TestMultiConnectionClient:

0 commit comments

Comments
 (0)