Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacillario committed Aug 10, 2022
1 parent d416b3e commit bd5c8ac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def teardown():

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

with pytest.raises(exceptions.ResponseError):
with pytest.raises(exceptions.AuthenticationError):
r.auth(username=username, password="wrong_password")

def test_command_on_invalid_key_type(self, r):
Expand Down
26 changes: 21 additions & 5 deletions tests/test_connection_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,22 +545,38 @@ def test_connect_from_url_unix(self):
)

@skip_if_redis_enterprise()
def test_connect_no_auth_supplied_when_required(self, r):
def test_connect_no_auth_configured(self, r):
"""
AuthenticationError should be raised when the server requires a
password but one isn't supplied.
AuthenticationError should be raised when the server is not configured with auth
but credentials are supplied by the user.
"""
# Redis < 6
with pytest.raises(redis.AuthenticationError):
r.execute_command(
"DEBUG", "ERROR", "ERR Client sent AUTH, but no password is set"
)

# Redis >= 6
with pytest.raises(redis.AuthenticationError):
r.execute_command(
"DEBUG", "ERROR", "ERR AUTH <password> called without any password "
"configured for the default user. Are you sure "
"your configuration is correct?"
)

@skip_if_redis_enterprise()
def test_connect_invalid_password_supplied(self, r):
"AuthenticationError should be raised when sending the wrong password"
def test_connect_invalid_auth_credentials_supplied(self, r):
"""
AuthenticationError should be raised when sending invalid username/password
"""
# Redis < 6
with pytest.raises(redis.AuthenticationError):
r.execute_command("DEBUG", "ERROR", "ERR invalid password")

# Redis >= 6
with pytest.raises(redis.AuthenticationError):
r.execute_command("DEBUG", "ERROR", "WRONGPASS")


@pytest.mark.onlynoncluster
class TestMultiConnectionClient:
Expand Down

0 comments on commit bd5c8ac

Please sign in to comment.