rubygems-update 3.0.4 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.txt +53 -0
- data/Manifest.txt +3 -1
- data/Rakefile +7 -5
- data/bundler/lib/bundler/build_metadata.rb +1 -1
- data/lib/rubygems.rb +6 -12
- data/lib/rubygems/commands/environment_command.rb +0 -3
- data/lib/rubygems/commands/push_command.rb +2 -0
- data/lib/rubygems/commands/uninstall_command.rb +16 -6
- data/lib/rubygems/commands/which_command.rb +1 -3
- data/lib/rubygems/defaults.rb +1 -8
- data/lib/rubygems/dependency_installer.rb +1 -2
- data/lib/rubygems/exceptions.rb +0 -4
- data/lib/rubygems/gemcutter_utilities.rb +9 -5
- data/lib/rubygems/installer.rb +1 -1
- data/lib/rubygems/installer_test_case.rb +2 -2
- data/lib/rubygems/package/tar_header.rb +11 -2
- data/lib/rubygems/remote_fetcher.rb +15 -54
- data/lib/rubygems/request.rb +1 -1
- data/lib/rubygems/request_set/gem_dependency_api.rb +3 -5
- data/lib/rubygems/s3_uri_signer.rb +175 -0
- data/lib/rubygems/security_option.rb +0 -1
- data/lib/rubygems/specification.rb +0 -1
- data/lib/rubygems/stub_specification.rb +1 -2
- data/lib/rubygems/test_case.rb +8 -4
- data/lib/rubygems/util.rb +12 -0
- data/rubygems-update.gemspec +1 -1
- data/test/rubygems/test_gem.rb +6 -3
- data/test/rubygems/test_gem_commands_environment_command.rb +0 -11
- data/test/rubygems/test_gem_commands_push_command.rb +15 -0
- data/test/rubygems/test_gem_commands_uninstall_command.rb +80 -1
- data/test/rubygems/test_gem_indexer.rb +8 -8
- data/test/rubygems/test_gem_installer.rb +48 -17
- data/test/rubygems/test_gem_package_tar_header.rb +41 -0
- data/test/rubygems/test_gem_remote_fetcher.rb +133 -14
- data/test/rubygems/test_gem_request.rb +4 -4
- data/test/rubygems/test_gem_request_set_gem_dependency_api.rb +20 -30
- data/test/rubygems/test_gem_util.rb +8 -0
- data/util/cops/deprecations.rb +52 -0
- data/util/create_certs.sh +27 -0
- metadata +5 -3
- data/lib/rubygems/compatibility.rb +0 -40
@@ -103,8 +103,8 @@ class TestGemIndexer < Gem::TestCase
|
|
103
103
|
quickdir = File.join @tempdir, 'quick'
|
104
104
|
marshal_quickdir = File.join quickdir, "Marshal.#{@marshal_version}"
|
105
105
|
|
106
|
-
|
107
|
-
|
106
|
+
assert_directory_exists quickdir
|
107
|
+
assert_directory_exists marshal_quickdir
|
108
108
|
|
109
109
|
assert_indexed marshal_quickdir, "#{File.basename(@a1.spec_file)}.rz"
|
110
110
|
assert_indexed marshal_quickdir, "#{File.basename(@a2.spec_file)}.rz"
|
@@ -133,8 +133,8 @@ class TestGemIndexer < Gem::TestCase
|
|
133
133
|
quickdir = File.join @tempdir, 'quick'
|
134
134
|
marshal_quickdir = File.join quickdir, "Marshal.#{@marshal_version}"
|
135
135
|
|
136
|
-
|
137
|
-
|
136
|
+
assert_directory_exists quickdir, 'quickdir should be directory'
|
137
|
+
assert_directory_exists marshal_quickdir
|
138
138
|
|
139
139
|
refute_indexed quickdir, "index"
|
140
140
|
refute_indexed quickdir, "index.rz"
|
@@ -179,8 +179,8 @@ class TestGemIndexer < Gem::TestCase
|
|
179
179
|
quickdir = File.join @tempdir, 'quick'
|
180
180
|
marshal_quickdir = File.join quickdir, "Marshal.#{@marshal_version}"
|
181
181
|
|
182
|
-
|
183
|
-
|
182
|
+
assert_directory_exists quickdir
|
183
|
+
assert_directory_exists marshal_quickdir
|
184
184
|
|
185
185
|
assert_indexed marshal_quickdir, "#{File.basename(@a1.spec_file)}.rz"
|
186
186
|
assert_indexed marshal_quickdir, "#{File.basename(@a2.spec_file)}.rz"
|
@@ -315,8 +315,8 @@ class TestGemIndexer < Gem::TestCase
|
|
315
315
|
quickdir = File.join @tempdir, 'quick'
|
316
316
|
marshal_quickdir = File.join quickdir, "Marshal.#{@marshal_version}"
|
317
317
|
|
318
|
-
|
319
|
-
|
318
|
+
assert_directory_exists quickdir
|
319
|
+
assert_directory_exists marshal_quickdir
|
320
320
|
|
321
321
|
@d2_1 = util_spec 'd', '2.1'
|
322
322
|
util_build_gem @d2_1
|
@@ -313,7 +313,7 @@ gem 'other', version
|
|
313
313
|
@installer.wrappers = true
|
314
314
|
|
315
315
|
@spec.executables = %w[executable]
|
316
|
-
@spec.bindir = '
|
316
|
+
@spec.bindir = 'bin'
|
317
317
|
|
318
318
|
exec_file = @installer.formatted_program_filename 'executable'
|
319
319
|
exec_path = File.join @spec.gem_dir, exec_file
|
@@ -325,7 +325,7 @@ gem 'other', version
|
|
325
325
|
|
326
326
|
@installer.generate_bin
|
327
327
|
|
328
|
-
|
328
|
+
assert_directory_exists (util_inst_bindir)
|
329
329
|
installed_exec = File.join(util_inst_bindir, 'executable')
|
330
330
|
assert_path_exists installed_exec
|
331
331
|
assert_equal mask, File.stat(installed_exec).mode unless win_platform?
|
@@ -366,7 +366,7 @@ gem 'other', version
|
|
366
366
|
@installer.gem_dir = @spec.gem_dir
|
367
367
|
|
368
368
|
@installer.generate_bin
|
369
|
-
|
369
|
+
assert_directory_exists util_inst_bindir
|
370
370
|
installed_exec = File.join util_inst_bindir, 'executable'
|
371
371
|
assert_path_exists installed_exec
|
372
372
|
assert_equal mask, File.stat(installed_exec).mode unless win_platform?
|
@@ -383,7 +383,7 @@ gem 'other', version
|
|
383
383
|
|
384
384
|
Gem::Installer.exec_format = 'foo-%s-bar'
|
385
385
|
@installer.generate_bin
|
386
|
-
|
386
|
+
assert_directory_exists util_inst_bindir
|
387
387
|
installed_exec = File.join util_inst_bindir, 'foo-executable-bar'
|
388
388
|
assert_path_exists installed_exec
|
389
389
|
ensure
|
@@ -397,7 +397,7 @@ gem 'other', version
|
|
397
397
|
|
398
398
|
Gem::Installer.exec_format = 'foo-%s-bar'
|
399
399
|
@installer.generate_bin
|
400
|
-
|
400
|
+
assert_directory_exists util_inst_bindir
|
401
401
|
installed_exec = File.join util_inst_bindir, 'executable'
|
402
402
|
assert_path_exists installed_exec
|
403
403
|
ensure
|
@@ -496,7 +496,7 @@ gem 'other', version
|
|
496
496
|
end
|
497
497
|
|
498
498
|
@installer.generate_bin
|
499
|
-
|
499
|
+
assert_directory_exists util_inst_bindir
|
500
500
|
assert_path_exists installed_exec
|
501
501
|
assert_equal mask, File.stat(installed_exec).mode unless win_platform?
|
502
502
|
|
@@ -514,7 +514,7 @@ gem 'other', version
|
|
514
514
|
@installer.gem_dir = @spec.gem_dir
|
515
515
|
|
516
516
|
@installer.generate_bin
|
517
|
-
|
517
|
+
assert_directory_exists util_inst_bindir
|
518
518
|
installed_exec = File.join util_inst_bindir, 'executable'
|
519
519
|
assert_equal true, File.symlink?(installed_exec)
|
520
520
|
assert_equal(File.join(@spec.gem_dir, 'bin', 'executable'),
|
@@ -666,7 +666,7 @@ gem 'other', version
|
|
666
666
|
@installer.generate_bin
|
667
667
|
end
|
668
668
|
|
669
|
-
|
669
|
+
assert_directory_exists util_inst_bindir
|
670
670
|
installed_exec = File.join(util_inst_bindir, 'executable')
|
671
671
|
assert_path_exists installed_exec
|
672
672
|
|
@@ -977,16 +977,16 @@ gem 'other', version
|
|
977
977
|
|
978
978
|
def test_install_missing_dirs
|
979
979
|
FileUtils.rm_f File.join(Gem.dir, 'cache')
|
980
|
-
FileUtils.rm_f File.join(Gem.dir, '
|
980
|
+
FileUtils.rm_f File.join(Gem.dir, 'doc')
|
981
981
|
FileUtils.rm_f File.join(Gem.dir, 'specifications')
|
982
982
|
|
983
983
|
use_ui @ui do
|
984
984
|
@installer.install
|
985
985
|
end
|
986
986
|
|
987
|
-
|
988
|
-
|
989
|
-
|
987
|
+
assert_directory_exists File.join(Gem.dir, 'cache')
|
988
|
+
assert_directory_exists File.join(Gem.dir, 'doc')
|
989
|
+
assert_directory_exists File.join(Gem.dir, 'specifications')
|
990
990
|
|
991
991
|
assert_path_exists File.join @gemhome, 'cache', @spec.file_name
|
992
992
|
assert_path_exists File.join @gemhome, 'specifications', @spec.spec_name
|
@@ -1828,24 +1828,55 @@ gem 'other', version
|
|
1828
1828
|
@installer.wrappers = true
|
1829
1829
|
@installer.options[:install_as_default] = true
|
1830
1830
|
@installer.gem_dir = @spec.gem_dir
|
1831
|
-
@installer.generate_bin
|
1832
1831
|
|
1833
1832
|
use_ui @ui do
|
1834
1833
|
@installer.install
|
1835
1834
|
end
|
1836
1835
|
|
1837
|
-
|
1838
|
-
installed_exec = File.join
|
1836
|
+
assert_directory_exists File.join(@spec.gem_dir, 'bin')
|
1837
|
+
installed_exec = File.join @spec.gem_dir, 'bin', 'executable'
|
1839
1838
|
assert_path_exists installed_exec
|
1840
1839
|
|
1841
|
-
|
1842
|
-
|
1840
|
+
assert_directory_exists File.join(Gem.default_dir, 'specifications')
|
1841
|
+
assert_directory_exists File.join(Gem.default_dir, 'specifications', 'default')
|
1843
1842
|
|
1844
1843
|
default_spec = eval File.read File.join(Gem.default_dir, 'specifications', 'default', 'a-2.gemspec')
|
1845
1844
|
assert_equal Gem::Version.new("2"), default_spec.version
|
1846
1845
|
assert_equal ['bin/executable'], default_spec.files
|
1847
1846
|
end
|
1848
1847
|
|
1848
|
+
def test_default_gem_with_exe_as_bindir
|
1849
|
+
FileUtils.rm_f File.join(Gem.dir, 'specifications')
|
1850
|
+
|
1851
|
+
@spec = quick_gem 'c' do |spec|
|
1852
|
+
util_make_exec spec, '#!/usr/bin/ruby', 'exe'
|
1853
|
+
end
|
1854
|
+
|
1855
|
+
util_build_gem @spec
|
1856
|
+
|
1857
|
+
@spec.cache_file
|
1858
|
+
|
1859
|
+
installer = util_installer @spec, @gemhome
|
1860
|
+
|
1861
|
+
installer.options[:install_as_default] = true
|
1862
|
+
installer.gem_dir = @spec.gem_dir
|
1863
|
+
|
1864
|
+
use_ui @ui do
|
1865
|
+
installer.install
|
1866
|
+
end
|
1867
|
+
|
1868
|
+
assert_directory_exists File.join(@spec.gem_dir, 'exe')
|
1869
|
+
installed_exec = File.join @spec.gem_dir, 'exe', 'executable'
|
1870
|
+
assert_path_exists installed_exec
|
1871
|
+
|
1872
|
+
assert_directory_exists File.join(Gem.default_dir, 'specifications')
|
1873
|
+
assert_directory_exists File.join(Gem.default_dir, 'specifications', 'default')
|
1874
|
+
|
1875
|
+
default_spec = eval File.read File.join(Gem.default_dir, 'specifications', 'default', 'c-2.gemspec')
|
1876
|
+
assert_equal Gem::Version.new("2"), default_spec.version
|
1877
|
+
assert_equal ['exe/executable'], default_spec.files
|
1878
|
+
end
|
1879
|
+
|
1849
1880
|
def old_ruby_required(requirement)
|
1850
1881
|
spec = util_spec 'old_ruby_required', '1' do |s|
|
1851
1882
|
s.required_ruby_version = requirement
|
@@ -164,4 +164,45 @@ group\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000
|
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
167
|
+
def test_big_uid_gid
|
168
|
+
stream = StringIO.new(
|
169
|
+
<<-EOF.dup.force_encoding('binary').split("\n").join
|
170
|
+
GeoIP2-City_20190528/
|
171
|
+
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
172
|
+
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
173
|
+
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
174
|
+
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x000000755\x00\x80\x00
|
175
|
+
\x00\x00v\xB2Z\x9E\x80\x00\x00\x00v\xB2Z\x9E00000000000\x0013473270100\x00015424
|
176
|
+
\x00 5\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
177
|
+
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
178
|
+
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
179
|
+
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
180
|
+
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00ustar \x00
|
181
|
+
tjmather\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
182
|
+
\x00\x00\x00\x00\x00tjmather\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
183
|
+
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
184
|
+
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
185
|
+
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
186
|
+
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
187
|
+
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
188
|
+
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
189
|
+
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
190
|
+
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
191
|
+
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
|
192
|
+
\x00\x00\x00\x00
|
193
|
+
EOF
|
194
|
+
)
|
195
|
+
|
196
|
+
tar_header = Gem::Package::TarHeader.from stream
|
197
|
+
|
198
|
+
assert_equal 1991400094, tar_header.uid
|
199
|
+
assert_equal 1991400094, tar_header.gid
|
200
|
+
|
201
|
+
assert_equal 'GeoIP2-City_20190528/', tar_header.name
|
202
|
+
assert_equal 0755, tar_header.mode
|
203
|
+
assert_equal 0, tar_header.size
|
204
|
+
assert_equal 1559064640, tar_header.mtime
|
205
|
+
assert_equal 6932, tar_header.checksum
|
206
|
+
end
|
207
|
+
|
167
208
|
end
|
@@ -648,10 +648,11 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
|
|
648
648
|
assert_equal "murphy", fetcher.fetch_path(@server_uri)
|
649
649
|
end
|
650
650
|
|
651
|
-
def assert_fetch_s3(url)
|
651
|
+
def assert_fetch_s3(url, signature, token=nil, region='us-east-1', instance_profile_json=nil)
|
652
652
|
fetcher = Gem::RemoteFetcher.new nil
|
653
653
|
@fetcher = fetcher
|
654
654
|
$fetched_uri = nil
|
655
|
+
$instance_profile = instance_profile_json
|
655
656
|
|
656
657
|
def fetcher.request(uri, request_class, last_modified = nil)
|
657
658
|
$fetched_uri = uri
|
@@ -660,13 +661,21 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
|
|
660
661
|
res
|
661
662
|
end
|
662
663
|
|
663
|
-
def fetcher.
|
664
|
-
|
664
|
+
def fetcher.s3_uri_signer(uri)
|
665
|
+
require 'json'
|
666
|
+
s3_uri_signer = Gem::S3URISigner.new(uri)
|
667
|
+
def s3_uri_signer.ec2_metadata_credentials_json
|
668
|
+
JSON.parse($instance_profile)
|
669
|
+
end
|
670
|
+
# Running sign operation to make sure uri.query is not mutated
|
671
|
+
s3_uri_signer.sign
|
672
|
+
raise "URI query is not empty: #{uri.query}" unless uri.query.nil?
|
673
|
+
s3_uri_signer
|
665
674
|
end
|
666
675
|
|
667
676
|
data = fetcher.fetch_s3 URI.parse(url)
|
668
677
|
|
669
|
-
assert_equal
|
678
|
+
assert_equal "https://my-bucket.s3.#{region}.amazonaws.com/gems/specs.4.8.gz?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=testuser%2F20190624%2F#{region}%2Fs3%2Faws4_request&X-Amz-Date=20190624T050641Z&X-Amz-Expires=86400#{token ? "&X-Amz-Security-Token=" + token : ""}&X-Amz-SignedHeaders=host&X-Amz-Signature=#{signature}", $fetched_uri.to_s
|
670
679
|
assert_equal 'success', data
|
671
680
|
ensure
|
672
681
|
$fetched_uri = nil
|
@@ -677,14 +686,132 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
|
|
677
686
|
'my-bucket' => {:id => 'testuser', :secret => 'testpass'}
|
678
687
|
}
|
679
688
|
url = 's3://my-bucket/gems/specs.4.8.gz'
|
680
|
-
|
689
|
+
Time.stub :now, Time.at(1561353581) do
|
690
|
+
assert_fetch_s3 url, '20f974027db2f3cd6193565327a7c73457a138efb1a63ea248d185ce6827d41b'
|
691
|
+
end
|
692
|
+
ensure
|
693
|
+
Gem.configuration[:s3_source] = nil
|
694
|
+
end
|
695
|
+
|
696
|
+
def test_fetch_s3_config_creds_with_region
|
697
|
+
Gem.configuration[:s3_source] = {
|
698
|
+
'my-bucket' => {:id => 'testuser', :secret => 'testpass', :region => 'us-west-2'}
|
699
|
+
}
|
700
|
+
url = 's3://my-bucket/gems/specs.4.8.gz'
|
701
|
+
Time.stub :now, Time.at(1561353581) do
|
702
|
+
assert_fetch_s3 url, '4afc3010757f1fd143e769f1d1dabd406476a4fc7c120e9884fd02acbb8f26c9', nil, 'us-west-2'
|
703
|
+
end
|
681
704
|
ensure
|
682
705
|
Gem.configuration[:s3_source] = nil
|
683
706
|
end
|
684
707
|
|
708
|
+
def test_fetch_s3_config_creds_with_token
|
709
|
+
Gem.configuration[:s3_source] = {
|
710
|
+
'my-bucket' => {:id => 'testuser', :secret => 'testpass', :security_token => 'testtoken'}
|
711
|
+
}
|
712
|
+
url = 's3://my-bucket/gems/specs.4.8.gz'
|
713
|
+
Time.stub :now, Time.at(1561353581) do
|
714
|
+
assert_fetch_s3 url, '935160a427ef97e7630f799232b8f208c4a4e49aad07d0540572a2ad5fe9f93c', 'testtoken'
|
715
|
+
end
|
716
|
+
ensure
|
717
|
+
Gem.configuration[:s3_source] = nil
|
718
|
+
end
|
719
|
+
|
720
|
+
def test_fetch_s3_env_creds
|
721
|
+
ENV['AWS_ACCESS_KEY_ID'] = 'testuser'
|
722
|
+
ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass'
|
723
|
+
ENV['AWS_SESSION_TOKEN'] = nil
|
724
|
+
Gem.configuration[:s3_source] = {
|
725
|
+
'my-bucket' => {:provider => 'env'}
|
726
|
+
}
|
727
|
+
url = 's3://my-bucket/gems/specs.4.8.gz'
|
728
|
+
Time.stub :now, Time.at(1561353581) do
|
729
|
+
assert_fetch_s3 url, '20f974027db2f3cd6193565327a7c73457a138efb1a63ea248d185ce6827d41b'
|
730
|
+
end
|
731
|
+
ensure
|
732
|
+
ENV.each_key {|key| ENV.delete(key) if key.start_with?('AWS')}
|
733
|
+
Gem.configuration[:s3_source] = nil
|
734
|
+
end
|
735
|
+
|
736
|
+
def test_fetch_s3_env_creds_with_region
|
737
|
+
ENV['AWS_ACCESS_KEY_ID'] = 'testuser'
|
738
|
+
ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass'
|
739
|
+
ENV['AWS_SESSION_TOKEN'] = nil
|
740
|
+
Gem.configuration[:s3_source] = {
|
741
|
+
'my-bucket' => {:provider => 'env', :region => 'us-west-2'}
|
742
|
+
}
|
743
|
+
url = 's3://my-bucket/gems/specs.4.8.gz'
|
744
|
+
Time.stub :now, Time.at(1561353581) do
|
745
|
+
assert_fetch_s3 url, '4afc3010757f1fd143e769f1d1dabd406476a4fc7c120e9884fd02acbb8f26c9', nil, 'us-west-2'
|
746
|
+
end
|
747
|
+
ensure
|
748
|
+
ENV.each_key {|key| ENV.delete(key) if key.start_with?('AWS')}
|
749
|
+
Gem.configuration[:s3_source] = nil
|
750
|
+
end
|
751
|
+
|
752
|
+
def test_fetch_s3_env_creds_with_token
|
753
|
+
ENV['AWS_ACCESS_KEY_ID'] = 'testuser'
|
754
|
+
ENV['AWS_SECRET_ACCESS_KEY'] = 'testpass'
|
755
|
+
ENV['AWS_SESSION_TOKEN'] = 'testtoken'
|
756
|
+
Gem.configuration[:s3_source] = {
|
757
|
+
'my-bucket' => {:provider => 'env'}
|
758
|
+
}
|
759
|
+
url = 's3://my-bucket/gems/specs.4.8.gz'
|
760
|
+
Time.stub :now, Time.at(1561353581) do
|
761
|
+
assert_fetch_s3 url, '935160a427ef97e7630f799232b8f208c4a4e49aad07d0540572a2ad5fe9f93c', 'testtoken'
|
762
|
+
end
|
763
|
+
ensure
|
764
|
+
ENV.each_key {|key| ENV.delete(key) if key.start_with?('AWS')}
|
765
|
+
Gem.configuration[:s3_source] = nil
|
766
|
+
end
|
767
|
+
|
685
768
|
def test_fetch_s3_url_creds
|
686
769
|
url = 's3://testuser:testpass@my-bucket/gems/specs.4.8.gz'
|
687
|
-
|
770
|
+
Time.stub :now, Time.at(1561353581) do
|
771
|
+
assert_fetch_s3 url, '20f974027db2f3cd6193565327a7c73457a138efb1a63ea248d185ce6827d41b'
|
772
|
+
end
|
773
|
+
end
|
774
|
+
|
775
|
+
def test_fetch_s3_instance_profile_creds
|
776
|
+
Gem.configuration[:s3_source] = {
|
777
|
+
'my-bucket' => {:provider => 'instance_profile'}
|
778
|
+
}
|
779
|
+
|
780
|
+
url = 's3://my-bucket/gems/specs.4.8.gz'
|
781
|
+
Time.stub :now, Time.at(1561353581) do
|
782
|
+
assert_fetch_s3 url, '20f974027db2f3cd6193565327a7c73457a138efb1a63ea248d185ce6827d41b', nil, 'us-east-1',
|
783
|
+
'{"AccessKeyId": "testuser", "SecretAccessKey": "testpass"}'
|
784
|
+
end
|
785
|
+
ensure
|
786
|
+
Gem.configuration[:s3_source] = nil
|
787
|
+
end
|
788
|
+
|
789
|
+
def test_fetch_s3_instance_profile_creds_with_region
|
790
|
+
Gem.configuration[:s3_source] = {
|
791
|
+
'my-bucket' => {:provider => 'instance_profile', :region => 'us-west-2'}
|
792
|
+
}
|
793
|
+
|
794
|
+
url = 's3://my-bucket/gems/specs.4.8.gz'
|
795
|
+
Time.stub :now, Time.at(1561353581) do
|
796
|
+
assert_fetch_s3 url, '4afc3010757f1fd143e769f1d1dabd406476a4fc7c120e9884fd02acbb8f26c9', nil, 'us-west-2',
|
797
|
+
'{"AccessKeyId": "testuser", "SecretAccessKey": "testpass"}'
|
798
|
+
end
|
799
|
+
ensure
|
800
|
+
Gem.configuration[:s3_source] = nil
|
801
|
+
end
|
802
|
+
|
803
|
+
def test_fetch_s3_instance_profile_creds_with_token
|
804
|
+
Gem.configuration[:s3_source] = {
|
805
|
+
'my-bucket' => {:provider => 'instance_profile'}
|
806
|
+
}
|
807
|
+
|
808
|
+
url = 's3://my-bucket/gems/specs.4.8.gz'
|
809
|
+
Time.stub :now, Time.at(1561353581) do
|
810
|
+
assert_fetch_s3 url, '935160a427ef97e7630f799232b8f208c4a4e49aad07d0540572a2ad5fe9f93c', 'testtoken', 'us-east-1',
|
811
|
+
'{"AccessKeyId": "testuser", "SecretAccessKey": "testpass", "Token": "testtoken"}'
|
812
|
+
end
|
813
|
+
ensure
|
814
|
+
Gem.configuration[:s3_source] = nil
|
688
815
|
end
|
689
816
|
|
690
817
|
def refute_fetch_s3(url, expected_message)
|
@@ -1044,12 +1171,4 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg==
|
|
1044
1171
|
end
|
1045
1172
|
end
|
1046
1173
|
|
1047
|
-
def test_correct_for_windows_path
|
1048
|
-
path = "/C:/WINDOWS/Temp/gems"
|
1049
|
-
assert_equal "C:/WINDOWS/Temp/gems", @fetcher.correct_for_windows_path(path)
|
1050
|
-
|
1051
|
-
path = "/home/skillet"
|
1052
|
-
assert_equal "/home/skillet", @fetcher.correct_for_windows_path(path)
|
1053
|
-
end
|
1054
|
-
|
1055
1174
|
end if defined?(OpenSSL::SSL)
|
@@ -250,7 +250,7 @@ class TestGemRequest < Gem::TestCase
|
|
250
250
|
def test_user_agent_engine
|
251
251
|
util_save_version
|
252
252
|
|
253
|
-
Object.send :remove_const, :RUBY_ENGINE
|
253
|
+
Object.send :remove_const, :RUBY_ENGINE
|
254
254
|
Object.send :const_set, :RUBY_ENGINE, 'vroom'
|
255
255
|
|
256
256
|
ua = make_request(@uri, nil, nil, nil).user_agent
|
@@ -263,7 +263,7 @@ class TestGemRequest < Gem::TestCase
|
|
263
263
|
def test_user_agent_engine_ruby
|
264
264
|
util_save_version
|
265
265
|
|
266
|
-
Object.send :remove_const, :RUBY_ENGINE
|
266
|
+
Object.send :remove_const, :RUBY_ENGINE
|
267
267
|
Object.send :const_set, :RUBY_ENGINE, 'ruby'
|
268
268
|
|
269
269
|
ua = make_request(@uri, nil, nil, nil).user_agent
|
@@ -447,7 +447,7 @@ ERROR: Certificate is an invalid CA certificate
|
|
447
447
|
end
|
448
448
|
|
449
449
|
def util_restore_version
|
450
|
-
Object.send :remove_const, :RUBY_ENGINE
|
450
|
+
Object.send :remove_const, :RUBY_ENGINE
|
451
451
|
Object.send :const_set, :RUBY_ENGINE, @orig_RUBY_ENGINE if
|
452
452
|
defined?(@orig_RUBY_ENGINE)
|
453
453
|
|
@@ -460,7 +460,7 @@ ERROR: Certificate is an invalid CA certificate
|
|
460
460
|
end
|
461
461
|
|
462
462
|
def util_save_version
|
463
|
-
@orig_RUBY_ENGINE = RUBY_ENGINE
|
463
|
+
@orig_RUBY_ENGINE = RUBY_ENGINE
|
464
464
|
@orig_RUBY_PATCHLEVEL = RUBY_PATCHLEVEL
|
465
465
|
@orig_RUBY_REVISION = RUBY_REVISION if defined? RUBY_REVISION
|
466
466
|
end
|