summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorsamisalamiws <62200850+samisalamiws@users.noreply.github.com>2022-01-17 13:47:27 +0200
committergit <svn-admin@ruby-lang.org>2024-11-08 12:15:31 +0000
commitfbe35bcc825fbae215f6ff283731f5e2f4a55a88 (patch)
tree07180b692783c62780f64dfaf0a8257d1446acfa /spec
parent10d694a1ffdcdaae67a693bb68c4bd658ec2d157 (diff)
[rubygems/rubygems] Fix private registry credentials being written to logs
https://github.com/rubygems/rubygems/commit/d070fa10c1 Co-authored-by: Artem Ignatyev <zazubrik@gmail.com>
Diffstat (limited to 'spec')
-rw-r--r--spec/bundler/bundler/rubygems_integration_spec.rb47
1 files changed, 40 insertions, 7 deletions
diff --git a/spec/bundler/bundler/rubygems_integration_spec.rb b/spec/bundler/bundler/rubygems_integration_spec.rb
index 81859d10f2..a2c63a7ca0 100644
--- a/spec/bundler/bundler/rubygems_integration_spec.rb
+++ b/spec/bundler/bundler/rubygems_integration_spec.rb
@@ -32,7 +32,6 @@ RSpec.describe Bundler::RubygemsIntegration do
describe "#download_gem" do
let(:bundler_retry) { double(Bundler::Retry) }
- let(:uri) { Gem::URI.parse("https://foo.bar") }
let(:cache_dir) { "#{Gem.path.first}/cache" }
let(:spec) do
spec = Gem::Specification.new("Foo", Gem::Version.new("2.5.2"))
@@ -41,13 +40,47 @@ RSpec.describe Bundler::RubygemsIntegration do
end
let(:fetcher) { double("gem_remote_fetcher") }
- it "successfully downloads gem with retries" do
- expect(Bundler::Retry).to receive(:new).with("download gem from #{uri}/").
- and_return(bundler_retry)
- expect(bundler_retry).to receive(:attempts).and_yield
- expect(fetcher).to receive(:cache_update_path)
+ context "when uri is public" do
+ let(:uri) { Gem::URI.parse("https://foo.bar") }
- Bundler.rubygems.download_gem(spec, uri, cache_dir, fetcher)
+ it "successfully downloads gem with retries" do
+ expect(Bundler::Retry).to receive(:new).with("download gem from #{uri}/").
+ and_return(bundler_retry)
+ expect(bundler_retry).to receive(:attempts).and_yield
+ expect(fetcher).to receive(:cache_update_path)
+
+ Bundler.rubygems.download_gem(spec, uri, cache_dir, fetcher)
+ end
+ end
+
+ context "when uri contains userinfo part" do
+ let(:uri) { Gem::URI.parse("https://#{userinfo}@foo.bar") }
+
+ context "with user and password" do
+ let(:userinfo) { "user:password" }
+
+ it "successfully downloads gem with retries with filtered log" do
+ expect(Bundler::Retry).to receive(:new).with("download gem from https://user:REDACTED@foo.bar/").
+ and_return(bundler_retry)
+ expect(bundler_retry).to receive(:attempts).and_yield
+ expect(fetcher).to receive(:cache_update_path)
+
+ Bundler.rubygems.download_gem(spec, uri, cache_dir, fetcher)
+ end
+ end
+
+ context "with token [as user]" do
+ let(:userinfo) { "token" }
+
+ it "successfully downloads gem with retries with filtered log" do
+ expect(Bundler::Retry).to receive(:new).with("download gem from https://REDACTED@foo.bar/").
+ and_return(bundler_retry)
+ expect(bundler_retry).to receive(:attempts).and_yield
+ expect(fetcher).to receive(:cache_update_path)
+
+ Bundler.rubygems.download_gem(spec, uri, cache_dir, fetcher)
+ end
+ end
end
end