Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Failover authentication fixes #311

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/moped/failover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module Failover
#
# @since 2.0.0
STRATEGIES = {
Errors::AuthenticationFailure => Ignore,
Errors::AuthenticationFailure => Retry,
Errors::ConnectionFailure => Retry,
Errors::CursorNotFound => Ignore,
Errors::OperationFailure => Reconfigure,
Expand Down
1 change: 1 addition & 0 deletions lib/moped/operation/read.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def initialize(operation)
def execute(node)
node.process(operation) do |reply|
if operation.failure?(reply)
node.down! if reply.unauthorized?
raise operation.failure_exception(reply)
end
operation.results(reply)
Expand Down
4 changes: 2 additions & 2 deletions spec/moped/failover_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
described_class.get(Moped::Errors::AuthenticationFailure.new({}, {}))
end

it "returns an ignore" do
expect(failover).to be_a(Moped::Failover::Ignore)
it "returns a retry" do
expect(failover).to be_a(Moped::Failover::Retry)
end
end

Expand Down
9 changes: 9 additions & 0 deletions spec/moped/operation/read_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
replica_set_node.unauthorized_on_next_message!
end

it "should mark the node as down" do
expect(node).to receive(:down!)
read.execute(node) rescue nil
end

it "raises a failure error" do
expect {
read.execute(node)
Expand All @@ -53,6 +58,10 @@
replica_set_node.query_failure_on_next_message!
end

it "should not mark the node as down" do
expect(node).to_not receive(:down!)
end

it "raises a failure error" do
expect {
read.execute(node)
Expand Down