Skip to content

Commit

Permalink
[rubygems/rubygems] Bad auth should not fallback either
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez authored and hsbt committed Aug 16, 2023
1 parent c076ac8 commit e678aff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bundler/fetcher/compact_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def self.compact_index_request(method_name)
method.bind(self).call(*args, &blk)
rescue NetworkDownError, CompactIndexClient::Updater::MisMatchedChecksumError => e
raise HTTPError, e.message
rescue AuthenticationRequiredError
rescue AuthenticationRequiredError, BadAuthenticationError
# Fail since we got a 401 from the server.
raise
rescue HTTPError => e
Expand Down
9 changes: 9 additions & 0 deletions spec/bundler/install/gems/compact_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,15 @@ def require(*args)
bundle :install, :artifice => "compact_index_strict_basic_authentication", :raise_on_error => false
expect(err).to include("Bad username or password")
end

it "does not fallback to old dependency API if bad authentication is provided" do
bundle "config set #{source_hostname} #{user}:wrong"

bundle :install, :artifice => "compact_index_strict_basic_authentication", :raise_on_error => false, :verbose => true
expect(err).to include("Bad username or password")
expect(out).to include("HTTP 401 Unauthorized http://user@localgemserver.test/versions")
expect(out).not_to include("HTTP 401 Unauthorized http://user@localgemserver.test/api/v1/dependencies")
end
end

describe "with no password" do
Expand Down

0 comments on commit e678aff

Please sign in to comment.