rubygems-update 3.0.4 → 3.0.9
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/.travis.yml +2 -0
- data/History.txt +85 -0
- data/Manifest.txt +5 -3
- data/Rakefile +8 -6
- data/bundler/lib/bundler/build_metadata.rb +2 -2
- data/lib/rubygems.rb +6 -12
- data/lib/rubygems/commands/push_command.rb +2 -0
- data/lib/rubygems/commands/setup_command.rb +9 -11
- 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.rb +1 -1
- 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 +8 -5
- 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/resolver.rb +4 -1
- data/lib/rubygems/s3_uri_signer.rb +183 -0
- data/lib/rubygems/security_option.rb +0 -1
- data/lib/rubygems/specification.rb +13 -14
- data/lib/rubygems/ssl_certs/{index.rubygems.org → rubygems.org}/GlobalSignRootCA.pem +0 -0
- data/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA_R3.pem +21 -0
- 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_bundled_ca.rb +7 -4
- data/test/rubygems/test_gem.rb +40 -3
- data/test/rubygems/test_gem_commands_push_command.rb +15 -0
- data/test/rubygems/test_gem_commands_setup_command.rb +11 -7
- 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 +78 -19
- 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_specification.rb +29 -0
- data/test/rubygems/test_gem_util.rb +8 -0
- data/util/cops/deprecations.rb +52 -0
- data/util/create_certs.sh +27 -0
- data/util/update_bundled_ca_certificates.rb +1 -3
- metadata +12 -9
- data/lib/rubygems/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
- data/lib/rubygems/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
@@ -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
|
@@ -1822,28 +1822,87 @@ gem 'other', version
|
|
1822
1822
|
assert_predicate spec, :default_gem?
|
1823
1823
|
end
|
1824
1824
|
|
1825
|
-
def
|
1825
|
+
def test_default_gem_without_wrappers
|
1826
1826
|
FileUtils.rm_f File.join(Gem.dir, 'specifications')
|
1827
1827
|
|
1828
|
-
@installer.wrappers =
|
1828
|
+
@installer.wrappers = false
|
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
|
1846
|
+
|
1847
|
+
assert_directory_exists util_inst_bindir
|
1848
|
+
|
1849
|
+
installed_exec = File.join util_inst_bindir, 'executable'
|
1850
|
+
assert_path_exists installed_exec
|
1851
|
+
|
1852
|
+
wrapper = File.read installed_exec
|
1853
|
+
refute_match %r|generated by RubyGems|, wrapper
|
1854
|
+
end
|
1855
|
+
|
1856
|
+
def test_default_gem_with_wrappers
|
1857
|
+
FileUtils.rm_f File.join(Gem.dir, 'specifications')
|
1858
|
+
|
1859
|
+
@installer.wrappers = true
|
1860
|
+
@installer.options[:install_as_default] = true
|
1861
|
+
@installer.gem_dir = @spec.gem_dir
|
1862
|
+
|
1863
|
+
use_ui @ui do
|
1864
|
+
@installer.install
|
1865
|
+
end
|
1866
|
+
|
1867
|
+
assert_directory_exists util_inst_bindir
|
1868
|
+
|
1869
|
+
installed_exec = File.join util_inst_bindir, 'executable'
|
1870
|
+
assert_path_exists installed_exec
|
1871
|
+
|
1872
|
+
wrapper = File.read installed_exec
|
1873
|
+
assert_match %r|generated by RubyGems|, wrapper
|
1874
|
+
end
|
1875
|
+
|
1876
|
+
def test_default_gem_with_exe_as_bindir
|
1877
|
+
FileUtils.rm_f File.join(Gem.dir, 'specifications')
|
1878
|
+
|
1879
|
+
@spec = quick_gem 'c' do |spec|
|
1880
|
+
util_make_exec spec, '#!/usr/bin/ruby', 'exe'
|
1881
|
+
end
|
1882
|
+
|
1883
|
+
util_build_gem @spec
|
1884
|
+
|
1885
|
+
@spec.cache_file
|
1886
|
+
|
1887
|
+
installer = util_installer @spec, @gemhome
|
1888
|
+
|
1889
|
+
installer.options[:install_as_default] = true
|
1890
|
+
installer.gem_dir = @spec.gem_dir
|
1891
|
+
|
1892
|
+
use_ui @ui do
|
1893
|
+
installer.install
|
1894
|
+
end
|
1895
|
+
|
1896
|
+
assert_directory_exists File.join(@spec.gem_dir, 'exe')
|
1897
|
+
installed_exec = File.join @spec.gem_dir, 'exe', 'executable'
|
1898
|
+
assert_path_exists installed_exec
|
1899
|
+
|
1900
|
+
assert_directory_exists File.join(Gem.default_dir, 'specifications')
|
1901
|
+
assert_directory_exists File.join(Gem.default_dir, 'specifications', 'default')
|
1902
|
+
|
1903
|
+
default_spec = eval File.read File.join(Gem.default_dir, 'specifications', 'default', 'c-2.gemspec')
|
1904
|
+
assert_equal Gem::Version.new("2"), default_spec.version
|
1905
|
+
assert_equal ['exe/executable'], default_spec.files
|
1847
1906
|
end
|
1848
1907
|
|
1849
1908
|
def old_ruby_required(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
|
@@ -20,35 +20,28 @@ class TestGemRequestSetGemDependencyAPI < Gem::TestCase
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def with_engine_version(name, version)
|
23
|
-
engine
|
24
|
-
|
25
|
-
engine_version = Object.const_get engine_version_const
|
23
|
+
engine = RUBY_ENGINE
|
24
|
+
engine_version = RUBY_ENGINE_VERSION
|
26
25
|
|
27
|
-
Object.send :remove_const, :RUBY_ENGINE
|
28
|
-
Object.send :remove_const,
|
29
|
-
Object.const_defined? engine_version_const
|
26
|
+
Object.send :remove_const, :RUBY_ENGINE
|
27
|
+
Object.send :remove_const, :RUBY_ENGINE_VERSION
|
30
28
|
|
31
|
-
|
32
|
-
Object.const_set :
|
33
|
-
Object.const_set new_engine_version_const, version if version
|
29
|
+
Object.const_set :RUBY_ENGINE, name if name
|
30
|
+
Object.const_set :RUBY_ENGINE_VERSION, version if version
|
34
31
|
|
35
32
|
Gem.instance_variable_set :@ruby_version, Gem::Version.new(version)
|
36
33
|
|
37
|
-
|
34
|
+
begin
|
35
|
+
yield
|
36
|
+
ensure
|
37
|
+
Object.send :remove_const, :RUBY_ENGINE if name
|
38
|
+
Object.send :remove_const, :RUBY_ENGINE_VERSION if version
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
Object.send :remove_const, new_engine_version_const if version
|
42
|
-
|
43
|
-
Object.send :remove_const, engine_version_const if name == 'ruby' and
|
44
|
-
Object.const_defined? engine_version_const
|
45
|
-
|
46
|
-
Object.const_set :RUBY_ENGINE, engine if engine
|
47
|
-
Object.const_set engine_version_const, engine_version unless
|
48
|
-
Object.const_defined? engine_version_const
|
40
|
+
Object.const_set :RUBY_ENGINE, engine
|
41
|
+
Object.const_set :RUBY_ENGINE_VERSION, engine_version
|
49
42
|
|
50
|
-
|
51
|
-
|
43
|
+
Gem.send :remove_instance_variable, :@ruby_version
|
44
|
+
end
|
52
45
|
end
|
53
46
|
|
54
47
|
def test_gempspec_with_multiple_runtime_deps
|
@@ -837,23 +830,20 @@ end
|
|
837
830
|
|
838
831
|
def test_with_engine_version
|
839
832
|
version = RUBY_VERSION
|
840
|
-
engine
|
841
|
-
|
842
|
-
engine_version_const = "#{Gem.ruby_engine.upcase}_VERSION"
|
843
|
-
engine_version = Object.const_get engine_version_const
|
833
|
+
engine = Gem.ruby_engine
|
834
|
+
engine_version = RUBY_ENGINE_VERSION
|
844
835
|
|
845
836
|
with_engine_version 'other', '1.2.3' do
|
846
837
|
assert_equal 'other', Gem.ruby_engine
|
847
|
-
assert_equal '1.2.3',
|
838
|
+
assert_equal '1.2.3', RUBY_ENGINE_VERSION
|
848
839
|
|
849
|
-
assert_equal version, RUBY_VERSION
|
840
|
+
assert_equal version, RUBY_VERSION
|
850
841
|
end
|
851
842
|
|
852
843
|
assert_equal version, RUBY_VERSION
|
853
844
|
assert_equal engine, Gem.ruby_engine
|
854
845
|
|
855
|
-
assert_equal engine_version,
|
856
|
-
engine
|
846
|
+
assert_equal engine_version, RUBY_ENGINE_VERSION if engine
|
857
847
|
end
|
858
848
|
|
859
849
|
end
|