-
Notifications
You must be signed in to change notification settings - Fork 69
retry connection prelude on connect errors #276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
nerdrew
wants to merge
1
commit into
redis-rb:master
Choose a base branch
from
nerdrew:wrongpass-retry
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -328,7 +328,12 @@ def test_command_missing | |
| end | ||
|
|
||
| def test_authentication | ||
| @redis.call("ACL", "SETUSER", "AzureDiamond", ">hunter2", "on", "+PING") | ||
| @redis.call("ACL", "DELUSER", "AzureDiamond") | ||
| @redis.call("ACL", "SETUSER", "AzureDiamond", ">hunter2", "on", "+PING", "+CLIENT") | ||
| @redis.call("ACL", "DELUSER", "backup_admin") | ||
| @redis.call("ACL", "SETUSER", "backup_admin", ">hunter2", "on", "~*", "&*", "+@all") | ||
| backup = new_client(username: "backup_admin", password: "hunter2") | ||
| backup.call("ACL", "SETUSER", "default", "off") | ||
|
|
||
| client = new_client(username: "AzureDiamond", password: "hunter2") | ||
| assert_equal "PONG", client.call("PING") | ||
|
|
@@ -337,10 +342,70 @@ def test_authentication | |
| client.call("GET", "foo") | ||
| end | ||
|
|
||
| # Wrong password | ||
| client = new_client(username: "AzureDiamond", password: "trolilol") | ||
| assert_raises RedisClient::AuthenticationError do | ||
| error = assert_raises RedisClient::AuthenticationError do | ||
| client.call("PING") | ||
| end | ||
| assert_match(/WRONGPASS invalid username-password pair/, error.message) | ||
|
|
||
| # The same error is raised, this shows that the client retried AUTH and didn't fall back to the default user | ||
| error = assert_raises RedisClient::AuthenticationError do | ||
| client.call("PING") | ||
| end | ||
| assert_match(/WRONGPASS invalid username-password pair/, error.message) | ||
|
|
||
| # Correct password, but user disabled | ||
| backup.call("ACL", "SETUSER", "AzureDiamond", "<hunter2", ">trolilol", "off") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mutating an existing user, and trying to fix it in a rescue isn't good, as it may fail and leave the server in a state that fail other tests. You can create a different user. |
||
| error = assert_raises RedisClient::AuthenticationError do | ||
| client.call_once("PING") | ||
| end | ||
| assert_match(/WRONGPASS invalid username-password pair/, error.message) | ||
|
|
||
| # Correct password, user enabled | ||
| backup.call("ACL", "SETUSER", "AzureDiamond", "on") | ||
| assert_equal "PONG", client.call_once("PING") | ||
| assert_match(/user=AzureDiamond/, client.call("CLIENT", "INFO")) | ||
|
|
||
| # Wrong username | ||
| client = new_client(username: "GreenOpal", password: "trolilol") | ||
| error = assert_raises RedisClient::AuthenticationError do | ||
| client.call("PING") | ||
| end | ||
| assert_match(/WRONGPASS invalid username-password pair/, error.message) | ||
| ensure | ||
| backup.call("ACL", "SETUSER", "default", "on") | ||
| end | ||
|
|
||
| def test_prelude_failure | ||
| client = new_client(db: 100) | ||
| error = assert_raises RedisClient::CommandError do | ||
| client.call("PING") | ||
| end | ||
| assert_match(/ERR DB index is out of range/, error.message) | ||
|
|
||
| error = assert_raises RedisClient::CommandError do | ||
| client.call("PING") | ||
| end | ||
| assert_match(/ERR DB index is out of range/, error.message) | ||
| end | ||
|
|
||
| def test_noauth | ||
| @redis.call("ACL", "DELUSER", "AzureDiamond") | ||
| @redis.call("ACL", "SETUSER", "AzureDiamond", ">hunter2", "on", "~*", "&*", "+@all") | ||
| backup = new_client(username: "AzureDiamond", password: "hunter2") | ||
| backup.call("ACL", "SETUSER", "default", "off") | ||
|
|
||
| client = new_client(protocol: 2) | ||
| error = assert_raises RedisClient::CommandError do | ||
| client.call("PING") | ||
| end | ||
| assert_match(/NOAUTH Authentication required/, error.message) | ||
|
|
||
| backup.call("ACL", "SETUSER", "default", "on") | ||
| client.call("PING") | ||
| ensure | ||
| backup.call("ACL", "SETUSER", "default", "on") | ||
| end | ||
|
|
||
| def test_transaction | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why you moved these rescues. Now only the
send_preludecall inconnectis covered.