rubygems-update 1.8.30 → 2.0.0.preview2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- checksums.yaml +6 -6
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +3 -0
- data/.autotest +6 -3
- data/History.txt +137 -63
- data/LICENSE.txt +1 -5
- data/Manifest.txt +69 -32
- data/README.rdoc +11 -9
- data/Rakefile +24 -38
- data/bin/gem +0 -9
- data/bin/update_rubygems +1 -0
- data/lib/rubygems.rb +193 -405
- data/lib/rubygems/available_set.rb +95 -0
- data/lib/rubygems/command.rb +88 -45
- data/lib/rubygems/command_manager.rb +67 -40
- data/lib/rubygems/commands/build_command.rb +5 -23
- data/lib/rubygems/commands/cert_command.rb +199 -57
- data/lib/rubygems/commands/check_command.rb +14 -39
- data/lib/rubygems/commands/cleanup_command.rb +9 -1
- data/lib/rubygems/commands/contents_command.rb +30 -12
- data/lib/rubygems/commands/dependency_command.rb +3 -8
- data/lib/rubygems/commands/environment_command.rb +13 -8
- data/lib/rubygems/commands/fetch_command.rb +3 -16
- data/lib/rubygems/commands/generate_index_command.rb +7 -47
- data/lib/rubygems/commands/help_command.rb +1 -1
- data/lib/rubygems/commands/install_command.rb +69 -36
- data/lib/rubygems/commands/list_command.rb +6 -4
- data/lib/rubygems/commands/lock_command.rb +1 -1
- data/lib/rubygems/commands/mirror_command.rb +17 -0
- data/lib/rubygems/commands/outdated_command.rb +6 -3
- data/lib/rubygems/commands/owner_command.rb +13 -5
- data/lib/rubygems/commands/pristine_command.rb +19 -4
- data/lib/rubygems/commands/push_command.rb +12 -1
- data/lib/rubygems/commands/query_command.rb +43 -27
- data/lib/rubygems/commands/rdoc_command.rb +23 -28
- data/lib/rubygems/commands/search_command.rb +4 -18
- data/lib/rubygems/commands/server_command.rb +1 -1
- data/lib/rubygems/commands/setup_command.rb +124 -38
- data/lib/rubygems/commands/sources_command.rb +16 -16
- data/lib/rubygems/commands/specification_command.rb +11 -13
- data/lib/rubygems/commands/uninstall_command.rb +24 -7
- data/lib/rubygems/commands/unpack_command.rb +7 -3
- data/lib/rubygems/commands/update_command.rb +22 -36
- data/lib/rubygems/commands/yank_command.rb +98 -0
- data/lib/rubygems/compatibility.rb +51 -0
- data/lib/rubygems/config_file.rb +82 -54
- data/lib/rubygems/core_ext/kernel_gem.rb +53 -0
- data/lib/rubygems/core_ext/kernel_require.rb +119 -0
- data/lib/rubygems/defaults.rb +10 -21
- data/lib/rubygems/dependency.rb +61 -10
- data/lib/rubygems/dependency_installer.rb +157 -69
- data/lib/rubygems/dependency_list.rb +11 -19
- data/lib/rubygems/dependency_resolver.rb +562 -0
- data/lib/rubygems/deprecate.rb +40 -40
- data/lib/rubygems/errors.rb +77 -24
- data/lib/rubygems/exceptions.rb +25 -7
- data/lib/rubygems/ext/builder.rb +20 -23
- data/lib/rubygems/ext/configure_builder.rb +2 -2
- data/lib/rubygems/ext/ext_conf_builder.rb +5 -45
- data/lib/rubygems/ext/rake_builder.rb +2 -2
- data/lib/rubygems/gem_runner.rb +3 -16
- data/lib/rubygems/gemcutter_utilities.rb +22 -7
- data/lib/rubygems/indexer.rb +6 -159
- data/lib/rubygems/install_message.rb +12 -0
- data/lib/rubygems/install_update_options.rb +56 -18
- data/lib/rubygems/installer.rb +244 -134
- data/lib/rubygems/installer_test_case.rb +71 -19
- data/lib/rubygems/mock_gem_ui.rb +17 -0
- data/lib/rubygems/name_tuple.rb +110 -0
- data/lib/rubygems/package.rb +514 -43
- data/lib/rubygems/package/digest_io.rb +64 -0
- data/lib/rubygems/package/old.rb +147 -0
- data/lib/rubygems/package/tar_header.rb +18 -55
- data/lib/rubygems/package/tar_reader.rb +20 -3
- data/lib/rubygems/package/tar_writer.rb +63 -7
- data/lib/rubygems/package_task.rb +3 -4
- data/lib/rubygems/path_support.rb +14 -7
- data/lib/rubygems/platform.rb +19 -26
- data/lib/rubygems/rdoc.rb +316 -0
- data/lib/rubygems/remote_fetcher.rb +117 -54
- data/lib/rubygems/request_set.rb +182 -0
- data/lib/rubygems/requirement.rb +63 -26
- data/lib/rubygems/security.rb +295 -555
- data/lib/rubygems/security/policies.rb +115 -0
- data/lib/rubygems/security/policy.rb +227 -0
- data/lib/rubygems/security/signer.rb +136 -0
- data/lib/rubygems/security/trust_dir.rb +104 -0
- data/lib/rubygems/server.rb +45 -55
- data/lib/rubygems/source.rb +144 -0
- data/lib/rubygems/source_list.rb +87 -0
- data/lib/rubygems/source_local.rb +92 -0
- data/lib/rubygems/source_specific_file.rb +28 -0
- data/lib/rubygems/spec_fetcher.rb +116 -184
- data/lib/rubygems/specification.rb +731 -335
- data/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem +88 -30
- data/lib/rubygems/ssl_certs/Entrust_net-Secure-Server-Certification-Authority.pem +90 -0
- data/lib/rubygems/ssl_certs/VerisignClass3PublicPrimaryCertificationAuthority-G2.pem +57 -0
- data/lib/rubygems/syck_hack.rb +2 -0
- data/lib/rubygems/test_case.rb +199 -109
- data/lib/rubygems/test_utilities.rb +25 -5
- data/lib/rubygems/uninstaller.rb +62 -20
- data/lib/rubygems/user_interaction.rb +10 -0
- data/lib/rubygems/validator.rb +33 -40
- data/lib/rubygems/version.rb +19 -8
- data/setup.rb +8 -1
- data/test/rubygems/alternate_cert.pem +9 -0
- data/test/rubygems/alternate_cert_32.pem +9 -0
- data/test/rubygems/alternate_key.pem +9 -0
- data/test/rubygems/bad_rake.rb +1 -0
- data/test/rubygems/child_cert.pem +9 -0
- data/test/rubygems/child_cert_32.pem +9 -0
- data/test/rubygems/child_key.pem +9 -0
- data/test/rubygems/data/null-type.gemspec.rz +0 -0
- data/test/rubygems/expired_cert.pem +9 -0
- data/test/rubygems/future_cert.pem +9 -0
- data/test/rubygems/future_cert_32.pem +9 -0
- data/test/rubygems/good_rake.rb +1 -0
- data/test/rubygems/grandchild_cert.pem +9 -0
- data/test/rubygems/grandchild_cert_32.pem +9 -0
- data/test/rubygems/grandchild_key.pem +9 -0
- data/test/rubygems/invalid_issuer_cert.pem +9 -0
- data/test/rubygems/invalid_issuer_cert_32.pem +9 -0
- data/test/rubygems/invalid_key.pem +9 -0
- data/test/rubygems/invalid_signer_cert.pem +9 -0
- data/test/rubygems/invalid_signer_cert_32.pem +9 -0
- data/test/rubygems/invalidchild_cert.pem +9 -0
- data/test/rubygems/invalidchild_cert_32.pem +9 -0
- data/test/rubygems/invalidchild_key.pem +9 -0
- data/test/rubygems/plugin/exception/rubygems_plugin.rb +1 -1
- data/test/rubygems/plugin/standarderror/rubygems_plugin.rb +1 -1
- data/test/rubygems/private_key.pem +7 -25
- data/test/rubygems/public_cert.pem +8 -18
- data/test/rubygems/public_cert_32.pem +10 -0
- data/test/rubygems/public_key.pem +4 -0
- data/test/rubygems/rubygems/commands/crash_command.rb +1 -1
- data/test/rubygems/test_config.rb +4 -6
- data/test/rubygems/test_deprecate.rb +76 -0
- data/test/rubygems/test_gem.rb +318 -83
- data/test/rubygems/test_gem_available_set.rb +106 -0
- data/test/rubygems/test_gem_command.rb +10 -0
- data/test/rubygems/test_gem_command_manager.rb +55 -9
- data/test/rubygems/test_gem_commands_build_command.rb +11 -19
- data/test/rubygems/test_gem_commands_cert_command.rb +441 -42
- data/test/rubygems/test_gem_commands_cleanup_command.rb +29 -1
- data/test/rubygems/test_gem_commands_contents_command.rb +23 -0
- data/test/rubygems/test_gem_commands_dependency_command.rb +5 -0
- data/test/rubygems/test_gem_commands_fetch_command.rb +19 -20
- data/test/rubygems/test_gem_commands_generate_index_command.rb +2 -83
- data/test/rubygems/test_gem_commands_help_command.rb +2 -1
- data/test/rubygems/test_gem_commands_install_command.rb +647 -48
- data/test/rubygems/test_gem_commands_mirror.rb +32 -0
- data/test/rubygems/test_gem_commands_owner_command.rb +4 -8
- data/test/rubygems/test_gem_commands_pristine_command.rb +99 -4
- data/test/rubygems/test_gem_commands_push_command.rb +62 -8
- data/test/rubygems/test_gem_commands_query_command.rb +51 -0
- data/test/rubygems/test_gem_commands_search_command.rb +25 -0
- data/test/rubygems/test_gem_commands_setup_command.rb +45 -0
- data/test/rubygems/test_gem_commands_sources_command.rb +21 -6
- data/test/rubygems/test_gem_commands_specification_command.rb +33 -1
- data/test/rubygems/test_gem_commands_uninstall_command.rb +91 -31
- data/test/rubygems/test_gem_commands_unpack_command.rb +3 -3
- data/test/rubygems/test_gem_commands_update_command.rb +56 -38
- data/test/rubygems/test_gem_commands_which_command.rb +4 -4
- data/test/rubygems/test_gem_commands_yank_command.rb +97 -0
- data/test/rubygems/test_gem_config_file.rb +66 -21
- data/test/rubygems/test_gem_dependency.rb +46 -0
- data/test/rubygems/test_gem_dependency_installer.rb +228 -18
- data/test/rubygems/test_gem_dependency_list.rb +0 -9
- data/test/rubygems/test_gem_dependency_resolver.rb +327 -0
- data/test/rubygems/test_gem_ext_configure_builder.rb +4 -4
- data/test/rubygems/test_gem_ext_ext_conf_builder.rb +21 -49
- data/test/rubygems/test_gem_ext_rake_builder.rb +13 -13
- data/test/rubygems/test_gem_gem_runner.rb +27 -5
- data/test/rubygems/test_gem_gemcutter_utilities.rb +19 -0
- data/test/rubygems/test_gem_indexer.rb +14 -227
- data/test/rubygems/test_gem_install_update_options.rb +83 -3
- data/test/rubygems/test_gem_installer.rb +211 -236
- data/test/rubygems/test_gem_local_remote_options.rb +8 -2
- data/test/rubygems/test_gem_name_tuple.rb +15 -0
- data/test/rubygems/test_gem_package.rb +547 -0
- data/test/rubygems/test_gem_package_old.rb +37 -0
- data/test/rubygems/test_gem_package_tar_reader.rb +32 -0
- data/test/rubygems/test_gem_package_tar_writer.rb +84 -1
- data/test/rubygems/test_gem_path_support.rb +4 -30
- data/test/rubygems/test_gem_platform.rb +3 -6
- data/test/rubygems/test_gem_rdoc.rb +245 -0
- data/test/rubygems/test_gem_remote_fetcher.rb +51 -5
- data/test/rubygems/test_gem_request_set.rb +70 -0
- data/test/rubygems/test_gem_requirement.rb +53 -24
- data/test/rubygems/test_gem_security.rb +189 -43
- data/test/rubygems/test_gem_security_policy.rb +376 -0
- data/test/rubygems/test_gem_security_signer.rb +184 -0
- data/test/rubygems/test_gem_security_trust_dir.rb +94 -0
- data/test/rubygems/test_gem_server.rb +31 -36
- data/test/rubygems/test_gem_silent_ui.rb +2 -2
- data/test/rubygems/test_gem_source.rb +188 -0
- data/test/rubygems/test_gem_source_list.rb +87 -0
- data/test/rubygems/test_gem_source_local.rb +83 -0
- data/test/rubygems/test_gem_source_specific_file.rb +33 -0
- data/test/rubygems/test_gem_spec_fetcher.rb +91 -255
- data/test/rubygems/test_gem_specification.rb +293 -39
- data/test/rubygems/test_gem_uninstaller.rb +136 -13
- data/test/rubygems/test_gem_validator.rb +14 -41
- data/test/rubygems/test_gem_version.rb +15 -21
- data/test/rubygems/test_require.rb +193 -0
- data/test/rubygems/wrong_key_cert.pem +9 -0
- data/test/rubygems/wrong_key_cert_32.pem +9 -0
- metadata +171 -83
- metadata.gz.sig +1 -0
- data/CVE-2013-4287.txt +0 -36
- data/CVE-2013-4363.txt +0 -45
- data/ci_build.sh +0 -27
- data/cruise_config.rb +0 -32
- data/lib/rbconfig/datadir.rb +0 -13
- data/lib/rubygems/builder.rb +0 -99
- data/lib/rubygems/custom_require.rb +0 -69
- data/lib/rubygems/doc_manager.rb +0 -243
- data/lib/rubygems/format.rb +0 -82
- data/lib/rubygems/gem_openssl.rb +0 -90
- data/lib/rubygems/gem_path_searcher.rb +0 -172
- data/lib/rubygems/old_format.rb +0 -153
- data/lib/rubygems/package/f_sync_dir.rb +0 -23
- data/lib/rubygems/package/tar_input.rb +0 -234
- data/lib/rubygems/package/tar_output.rb +0 -146
- data/lib/rubygems/require_paths_builder.rb +0 -18
- data/lib/rubygems/source_index.rb +0 -406
- data/lib/rubygems/ssl_certs/AddTrustExternalCARoot-2048.pem +0 -25
- data/lib/rubygems/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +0 -14
- data/lib/rubygems/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +0 -23
- data/lib/rubygems/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +0 -28
- data/lib/rubygems/ssl_certs/GeoTrustGlobalCA.pem +0 -20
- data/test/rubygems/test_bundled_ca.rb +0 -59
- data/test/rubygems/test_gem_builder.rb +0 -44
- data/test/rubygems/test_gem_doc_manager.rb +0 -32
- data/test/rubygems/test_gem_ext_builder.rb +0 -58
- data/test/rubygems/test_gem_format.rb +0 -88
- data/test/rubygems/test_gem_gem_path_searcher.rb +0 -94
- data/test/rubygems/test_gem_package_tar_input.rb +0 -129
- data/test/rubygems/test_gem_package_tar_output.rb +0 -101
- data/test/rubygems/test_gem_source_index.rb +0 -250
- data/util/update_bundled_ca_certificates.rb +0 -103
@@ -3,7 +3,8 @@ require 'ostruct'
|
|
3
3
|
require 'webrick'
|
4
4
|
require 'webrick/https'
|
5
5
|
require 'rubygems/remote_fetcher'
|
6
|
-
require 'rubygems/
|
6
|
+
require 'rubygems/package'
|
7
|
+
require 'minitest/mock'
|
7
8
|
|
8
9
|
# = Testing Proxy Settings
|
9
10
|
#
|
@@ -87,6 +88,8 @@ gems:
|
|
87
88
|
ENV.delete 'HTTP_PROXY_USER'
|
88
89
|
ENV.delete 'http_proxy_pass'
|
89
90
|
ENV.delete 'HTTP_PROXY_PASS'
|
91
|
+
ENV.delete 'no_proxy'
|
92
|
+
ENV.delete 'NO_PROXY'
|
90
93
|
|
91
94
|
base_server_uri = "http://localhost:#{SERVER_PORT}"
|
92
95
|
@proxy_uri = "http://localhost:#{PROXY_PORT}"
|
@@ -101,6 +104,7 @@ gems:
|
|
101
104
|
|
102
105
|
# TODO: why does the remote fetcher need it written to disk?
|
103
106
|
@a1, @a1_gem = util_gem 'a', '1' do |s| s.executables << 'a_bin' end
|
107
|
+
@a1.loaded_from = File.join(@gemhome, 'specifications', @a1.full_name)
|
104
108
|
|
105
109
|
Gem::RemoteFetcher.fetcher = nil
|
106
110
|
|
@@ -173,6 +177,21 @@ gems:
|
|
173
177
|
end
|
174
178
|
end
|
175
179
|
|
180
|
+
def test_api_endpoint
|
181
|
+
uri = URI.parse "http://gems.example.com/foo"
|
182
|
+
target = MiniTest::Mock.new
|
183
|
+
target.expect :target, "http://blah.com"
|
184
|
+
|
185
|
+
dns = MiniTest::Mock.new
|
186
|
+
dns.expect :getresource, target, [String, Object]
|
187
|
+
|
188
|
+
fetch = Gem::RemoteFetcher.new nil, dns
|
189
|
+
assert_equal URI.parse("http://blah.com/foo"), fetch.api_endpoint(uri)
|
190
|
+
|
191
|
+
target.verify
|
192
|
+
dns.verify
|
193
|
+
end
|
194
|
+
|
176
195
|
def util_fuck_with_fetcher data, blow = false
|
177
196
|
fetcher = Gem::RemoteFetcher.fetcher
|
178
197
|
fetcher.instance_variable_set :@test_data, data
|
@@ -278,8 +297,8 @@ gems:
|
|
278
297
|
inst = Gem::RemoteFetcher.fetcher
|
279
298
|
end
|
280
299
|
|
281
|
-
assert_equal
|
282
|
-
|
300
|
+
assert_equal(File.join(@tempdir, @a1.file_name),
|
301
|
+
inst.download(@a1, local_path))
|
283
302
|
ensure
|
284
303
|
FileUtils.chmod 0755, @a1.cache_dir
|
285
304
|
end
|
@@ -305,6 +324,7 @@ gems:
|
|
305
324
|
s.platform = Gem::Platform::CURRENT
|
306
325
|
s.instance_variable_set :@original_platform, original_platform
|
307
326
|
end
|
327
|
+
e1.loaded_from = File.join(@gemhome, 'specifications', e1.full_name)
|
308
328
|
|
309
329
|
e1_data = nil
|
310
330
|
File.open e1_gem, 'rb' do |fp|
|
@@ -334,7 +354,7 @@ gems:
|
|
334
354
|
cache_path = @a1.cache_file
|
335
355
|
FileUtils.mv local_path, cache_path
|
336
356
|
|
337
|
-
gem = Gem::
|
357
|
+
gem = Gem::Package.new cache_path
|
338
358
|
|
339
359
|
assert_equal cache_path, inst.download(gem.spec, cache_path)
|
340
360
|
end
|
@@ -342,7 +362,7 @@ gems:
|
|
342
362
|
def test_download_unsupported
|
343
363
|
inst = Gem::RemoteFetcher.fetcher
|
344
364
|
|
345
|
-
e = assert_raises
|
365
|
+
e = assert_raises ArgumentError do
|
346
366
|
inst.download @a1, 'ftp://gems.rubyforge.org'
|
347
367
|
end
|
348
368
|
|
@@ -624,6 +644,32 @@ gems:
|
|
624
644
|
assert_equal "too many redirects (#{url})", e.message
|
625
645
|
end
|
626
646
|
|
647
|
+
def test_normalize_uri
|
648
|
+
assert_equal 'FILE://example/', @fetcher.normalize_uri('FILE://example/')
|
649
|
+
assert_equal 'FTP://example/', @fetcher.normalize_uri('FTP://example/')
|
650
|
+
assert_equal 'HTTP://example/', @fetcher.normalize_uri('HTTP://example/')
|
651
|
+
assert_equal 'HTTPS://example/', @fetcher.normalize_uri('HTTPS://example/')
|
652
|
+
assert_equal 'http://example/', @fetcher.normalize_uri('example/')
|
653
|
+
end
|
654
|
+
|
655
|
+
def test_observe_no_proxy_env_single_host
|
656
|
+
use_ui @ui do
|
657
|
+
ENV["http_proxy"] = @proxy_uri
|
658
|
+
ENV["no_proxy"] = URI::parse(@server_uri).host
|
659
|
+
fetcher = Gem::RemoteFetcher.new nil
|
660
|
+
assert_data_from_server fetcher.fetch_path(@server_uri)
|
661
|
+
end
|
662
|
+
end
|
663
|
+
|
664
|
+
def test_observe_no_proxy_env_list
|
665
|
+
use_ui @ui do
|
666
|
+
ENV["http_proxy"] = @proxy_uri
|
667
|
+
ENV["no_proxy"] = "fakeurl.com, #{URI::parse(@server_uri).host}"
|
668
|
+
fetcher = Gem::RemoteFetcher.new nil
|
669
|
+
assert_data_from_server fetcher.fetch_path(@server_uri)
|
670
|
+
end
|
671
|
+
end
|
672
|
+
|
627
673
|
def test_request
|
628
674
|
uri = URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}"
|
629
675
|
util_stub_connection_for :body => :junk, :code => 200
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'rubygems/test_case'
|
2
|
+
require 'rubygems/request_set'
|
3
|
+
|
4
|
+
class TestGemRequestSet < Gem::TestCase
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
|
8
|
+
Gem::RemoteFetcher.fetcher = @fetcher = Gem::FakeFetcher.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_gem
|
12
|
+
util_spec "a", "2"
|
13
|
+
|
14
|
+
rs = Gem::RequestSet.new
|
15
|
+
rs.gem "a", "= 2"
|
16
|
+
|
17
|
+
assert_equal [Gem::Dependency.new("a", "=2")], rs.dependencies
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_resolve
|
21
|
+
a = util_spec "a", "2", "b" => ">= 2"
|
22
|
+
b = util_spec "b", "2"
|
23
|
+
|
24
|
+
rs = Gem::RequestSet.new
|
25
|
+
rs.gem "a"
|
26
|
+
|
27
|
+
res = rs.resolve StaticSet.new([a, b])
|
28
|
+
assert_equal 2, res.size
|
29
|
+
|
30
|
+
names = res.map { |s| s.full_name }.sort
|
31
|
+
|
32
|
+
assert_equal ["a-2", "b-2"], names
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_sorted_requests
|
36
|
+
a = util_spec "a", "2", "b" => ">= 2"
|
37
|
+
b = util_spec "b", "2", "c" => ">= 2"
|
38
|
+
c = util_spec "c", "2"
|
39
|
+
|
40
|
+
rs = Gem::RequestSet.new
|
41
|
+
rs.gem "a"
|
42
|
+
|
43
|
+
rs.resolve StaticSet.new([a, b, c])
|
44
|
+
|
45
|
+
names = rs.sorted_requests.map { |s| s.full_name }
|
46
|
+
assert_equal %w!c-2 b-2 a-2!, names
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_install_into
|
50
|
+
a, ad = util_gem "a", "1", "b" => "= 1"
|
51
|
+
b, bd = util_gem "b", "1"
|
52
|
+
|
53
|
+
util_setup_spec_fetcher a, b
|
54
|
+
|
55
|
+
@fetcher.data["http://gems.example.com/gems/#{a.file_name}"] = Gem.read_binary(ad)
|
56
|
+
@fetcher.data["http://gems.example.com/gems/#{b.file_name}"] = Gem.read_binary(bd)
|
57
|
+
|
58
|
+
rs = Gem::RequestSet.new
|
59
|
+
rs.gem "a"
|
60
|
+
|
61
|
+
rs.resolve
|
62
|
+
|
63
|
+
installed = rs.install_into @tempdir
|
64
|
+
|
65
|
+
assert File.exists?(File.join(@tempdir, "specifications", "a-1.gemspec"))
|
66
|
+
assert File.exists?(File.join(@tempdir, "specifications", "b-1.gemspec"))
|
67
|
+
|
68
|
+
assert_equal %w!b-1 a-1!, installed.map { |s| s.full_name }
|
69
|
+
end
|
70
|
+
end
|
@@ -21,9 +21,19 @@ class TestGemRequirement < Gem::TestCase
|
|
21
21
|
assert_requirement_equal "= 2", v(2)
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
|
26
|
-
|
24
|
+
def test_empty_requirements_is_none
|
25
|
+
r = Gem::Requirement.new
|
26
|
+
assert_equal true, r.none?
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_explicit_default_is_none
|
30
|
+
r = Gem::Requirement.new ">= 0"
|
31
|
+
assert_equal true, r.none?
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_basic_non_none
|
35
|
+
r = Gem::Requirement.new "= 1"
|
36
|
+
assert_equal false, r.none?
|
27
37
|
end
|
28
38
|
|
29
39
|
def test_parse
|
@@ -37,19 +47,19 @@ class TestGemRequirement < Gem::TestCase
|
|
37
47
|
end
|
38
48
|
|
39
49
|
def test_parse_bad
|
40
|
-
|
41
|
-
nil
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
'1..2',
|
46
|
-
].each do |bad|
|
47
|
-
e = assert_raises ArgumentError do
|
48
|
-
Gem::Requirement.parse bad
|
49
|
-
end
|
50
|
+
e = assert_raises Gem::Requirement::BadRequirementError do
|
51
|
+
Gem::Requirement.parse nil
|
52
|
+
end
|
53
|
+
|
54
|
+
assert_equal 'Illformed requirement [nil]', e.message
|
50
55
|
|
51
|
-
|
56
|
+
e = assert_raises Gem::Requirement::BadRequirementError do
|
57
|
+
Gem::Requirement.parse ""
|
52
58
|
end
|
59
|
+
|
60
|
+
assert_equal 'Illformed requirement [""]', e.message
|
61
|
+
|
62
|
+
assert_equal Gem::Requirement::BadRequirementError.superclass, ArgumentError
|
53
63
|
end
|
54
64
|
|
55
65
|
def test_prerelease_eh
|
@@ -69,28 +79,37 @@ class TestGemRequirement < Gem::TestCase
|
|
69
79
|
def test_satisfied_by_eh_bang_equal
|
70
80
|
r = req '!= 1.2'
|
71
81
|
|
72
|
-
assert_satisfied_by nil, r
|
73
82
|
assert_satisfied_by "1.1", r
|
74
83
|
refute_satisfied_by "1.2", r
|
75
84
|
assert_satisfied_by "1.3", r
|
85
|
+
|
86
|
+
assert_raises ArgumentError do
|
87
|
+
assert_satisfied_by nil, r
|
88
|
+
end
|
76
89
|
end
|
77
90
|
|
78
91
|
def test_satisfied_by_eh_blank
|
79
92
|
r = req "1.2"
|
80
93
|
|
81
|
-
refute_satisfied_by nil, r
|
82
94
|
refute_satisfied_by "1.1", r
|
83
95
|
assert_satisfied_by "1.2", r
|
84
96
|
refute_satisfied_by "1.3", r
|
97
|
+
|
98
|
+
assert_raises ArgumentError do
|
99
|
+
assert_satisfied_by nil, r
|
100
|
+
end
|
85
101
|
end
|
86
102
|
|
87
103
|
def test_satisfied_by_eh_equal
|
88
104
|
r = req "= 1.2"
|
89
105
|
|
90
|
-
refute_satisfied_by nil, r
|
91
106
|
refute_satisfied_by "1.1", r
|
92
107
|
assert_satisfied_by "1.2", r
|
93
108
|
refute_satisfied_by "1.3", r
|
109
|
+
|
110
|
+
assert_raises ArgumentError do
|
111
|
+
assert_satisfied_by nil, r
|
112
|
+
end
|
94
113
|
end
|
95
114
|
|
96
115
|
def test_satisfied_by_eh_gt
|
@@ -100,7 +119,7 @@ class TestGemRequirement < Gem::TestCase
|
|
100
119
|
refute_satisfied_by "1.2", r
|
101
120
|
assert_satisfied_by "1.3", r
|
102
121
|
|
103
|
-
assert_raises
|
122
|
+
assert_raises ArgumentError do
|
104
123
|
r.satisfied_by? nil
|
105
124
|
end
|
106
125
|
end
|
@@ -112,7 +131,7 @@ class TestGemRequirement < Gem::TestCase
|
|
112
131
|
assert_satisfied_by "1.2", r
|
113
132
|
assert_satisfied_by "1.3", r
|
114
133
|
|
115
|
-
assert_raises
|
134
|
+
assert_raises ArgumentError do
|
116
135
|
r.satisfied_by? nil
|
117
136
|
end
|
118
137
|
end
|
@@ -124,7 +143,7 @@ class TestGemRequirement < Gem::TestCase
|
|
124
143
|
assert_satisfied_by "1.2", r
|
125
144
|
refute_satisfied_by "1.3", r
|
126
145
|
|
127
|
-
assert_raises
|
146
|
+
assert_raises ArgumentError do
|
128
147
|
r.satisfied_by? nil
|
129
148
|
end
|
130
149
|
end
|
@@ -136,7 +155,7 @@ class TestGemRequirement < Gem::TestCase
|
|
136
155
|
refute_satisfied_by "1.2", r
|
137
156
|
refute_satisfied_by "1.3", r
|
138
157
|
|
139
|
-
assert_raises
|
158
|
+
assert_raises ArgumentError do
|
140
159
|
r.satisfied_by? nil
|
141
160
|
end
|
142
161
|
end
|
@@ -148,7 +167,7 @@ class TestGemRequirement < Gem::TestCase
|
|
148
167
|
assert_satisfied_by "1.2", r
|
149
168
|
refute_satisfied_by "1.3", r
|
150
169
|
|
151
|
-
assert_raises
|
170
|
+
assert_raises ArgumentError do
|
152
171
|
r.satisfied_by? nil
|
153
172
|
end
|
154
173
|
end
|
@@ -160,7 +179,7 @@ class TestGemRequirement < Gem::TestCase
|
|
160
179
|
assert_satisfied_by "1.2", r
|
161
180
|
assert_satisfied_by "1.3", r
|
162
181
|
|
163
|
-
assert_raises
|
182
|
+
assert_raises ArgumentError do
|
164
183
|
r.satisfied_by? nil
|
165
184
|
end
|
166
185
|
end
|
@@ -202,12 +221,22 @@ class TestGemRequirement < Gem::TestCase
|
|
202
221
|
|
203
222
|
def test_illformed_requirements
|
204
223
|
[ ">>> 1.3.5", "> blah" ].each do |rq|
|
205
|
-
assert_raises
|
224
|
+
assert_raises Gem::Requirement::BadRequirementError, "req [#{rq}] should fail" do
|
206
225
|
Gem::Requirement.new rq
|
207
226
|
end
|
208
227
|
end
|
209
228
|
end
|
210
229
|
|
230
|
+
def test_satisfied_by_eh_non_versions
|
231
|
+
assert_raises ArgumentError do
|
232
|
+
req(">= 0").satisfied_by? Object.new
|
233
|
+
end
|
234
|
+
|
235
|
+
assert_raises ArgumentError do
|
236
|
+
req(">= 0").satisfied_by? Gem::Requirement.default
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
211
240
|
def test_satisfied_by_eh_boxed
|
212
241
|
refute_satisfied_by "1.3", "~> 1.4"
|
213
242
|
assert_satisfied_by "1.4", "~> 1.4"
|
@@ -4,33 +4,35 @@ require 'rubygems/fix_openssl_warnings' if RUBY_VERSION < "1.9"
|
|
4
4
|
|
5
5
|
class TestGemSecurity < Gem::TestCase
|
6
6
|
|
7
|
+
CHILD_KEY = load_key 'child'
|
8
|
+
|
9
|
+
ALTERNATE_CERT = load_cert 'child'
|
10
|
+
CHILD_CERT = load_cert 'child'
|
11
|
+
EXPIRED_CERT = load_cert 'expired'
|
12
|
+
|
7
13
|
def setup
|
8
14
|
super
|
9
|
-
Gem::Security::OPT[:trust_dir] = File.join(Gem.user_home, '.gem', 'trust')
|
10
|
-
end
|
11
15
|
|
12
|
-
|
13
|
-
super
|
14
|
-
Gem::Security::OPT[:trust_dir] = File.join(Gem.user_home, '.gem', 'trust')
|
16
|
+
@SEC = Gem::Security
|
15
17
|
end
|
16
18
|
|
17
|
-
def
|
18
|
-
name =
|
19
|
-
key =
|
20
|
-
opt = { :cert_age => 60 }
|
19
|
+
def test_class_create_cert
|
20
|
+
name = PUBLIC_CERT.subject
|
21
|
+
key = PRIVATE_KEY
|
21
22
|
|
22
|
-
cert =
|
23
|
+
cert = @SEC.create_cert name, key, 60, Gem::Security::EXTENSIONS, 5
|
23
24
|
|
24
25
|
assert_kind_of OpenSSL::X509::Certificate, cert
|
25
26
|
|
26
27
|
assert_equal 2, cert.version
|
27
|
-
assert_equal
|
28
|
+
assert_equal 5, cert.serial
|
28
29
|
assert_equal key.public_key.to_pem, cert.public_key.to_pem
|
29
30
|
assert_in_delta Time.now, cert.not_before, 10
|
30
31
|
assert_in_delta Time.now + 60, cert.not_after, 10
|
31
32
|
assert_equal name.to_s, cert.subject.to_s
|
32
33
|
|
33
|
-
assert_equal 3, cert.extensions.length
|
34
|
+
assert_equal 3, cert.extensions.length,
|
35
|
+
cert.extensions.map { |e| e.to_a.first }
|
34
36
|
|
35
37
|
constraints = cert.extensions.find { |ext| ext.oid == 'basicConstraints' }
|
36
38
|
assert_equal 'CA:FALSE', constraints.value
|
@@ -41,60 +43,204 @@ class TestGemSecurity < Gem::TestCase
|
|
41
43
|
|
42
44
|
key_ident = cert.extensions.find { |ext| ext.oid == 'subjectKeyIdentifier' }
|
43
45
|
assert_equal 59, key_ident.value.length
|
46
|
+
assert_equal 'B0:EB:9C:A5:E5:8E:7D:94:BB:4B:3B:D6:80:CB:A5:AD:5D:12:88:90',
|
47
|
+
key_ident.value
|
44
48
|
|
45
|
-
assert_equal
|
49
|
+
assert_equal '', cert.issuer.to_s
|
46
50
|
assert_equal name.to_s, cert.subject.to_s
|
47
51
|
end
|
48
52
|
|
49
|
-
def
|
53
|
+
def test_class_create_cert_self_signed
|
54
|
+
subject = PUBLIC_CERT.subject
|
55
|
+
|
56
|
+
cert = @SEC.create_cert_self_signed subject, PRIVATE_KEY, 60
|
57
|
+
|
58
|
+
assert_equal '/CN=nobody/DC=example', cert.issuer.to_s
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_class_create_cert_email
|
50
62
|
email = 'nobody@example'
|
51
|
-
|
52
|
-
|
53
|
-
:key_size => 512,
|
54
|
-
:save_cert => false,
|
55
|
-
:save_key => false,
|
56
|
-
}
|
63
|
+
name = PUBLIC_CERT.subject
|
64
|
+
key = PRIVATE_KEY
|
57
65
|
|
58
|
-
|
66
|
+
cert = @SEC.create_cert_email email, key, 60
|
59
67
|
|
60
|
-
|
68
|
+
assert_kind_of OpenSSL::X509::Certificate, cert
|
61
69
|
|
62
|
-
|
63
|
-
|
70
|
+
assert_equal 2, cert.version
|
71
|
+
assert_equal 1, cert.serial
|
72
|
+
assert_equal key.public_key.to_pem, cert.public_key.to_pem
|
73
|
+
assert_in_delta Time.now, cert.not_before, 10
|
74
|
+
assert_in_delta Time.now + 60, cert.not_after, 10
|
75
|
+
assert_equal name.to_s, cert.subject.to_s
|
76
|
+
assert_equal name.to_s, cert.issuer.to_s
|
64
77
|
|
65
|
-
|
78
|
+
assert_equal 5, cert.extensions.length,
|
79
|
+
cert.extensions.map { |e| e.to_a.first }
|
66
80
|
|
67
|
-
|
68
|
-
|
81
|
+
constraints = cert.extensions.find { |ext| ext.oid == 'subjectAltName' }
|
82
|
+
assert_equal 'email:nobody@example', constraints.value
|
69
83
|
|
70
|
-
|
71
|
-
|
72
|
-
key = OpenSSL::PKey::RSA.new 512
|
73
|
-
cert = OpenSSL::X509::Certificate.new
|
84
|
+
constraints = cert.extensions.find { |ext| ext.oid == 'basicConstraints' }
|
85
|
+
assert_equal 'CA:FALSE', constraints.value
|
74
86
|
|
75
|
-
cert.
|
76
|
-
|
87
|
+
key_usage = cert.extensions.find { |ext| ext.oid == 'keyUsage' }
|
88
|
+
assert_equal 'Digital Signature, Key Encipherment, Data Encipherment',
|
89
|
+
key_usage.value
|
77
90
|
|
78
|
-
|
91
|
+
key_ident = cert.extensions.find { |ext| ext.oid == 'subjectKeyIdentifier' }
|
92
|
+
assert_equal 59, key_ident.value.length
|
93
|
+
assert_equal 'B0:EB:9C:A5:E5:8E:7D:94:BB:4B:3B:D6:80:CB:A5:AD:5D:12:88:90',
|
94
|
+
key_ident.value
|
95
|
+
end
|
79
96
|
|
80
|
-
|
81
|
-
|
97
|
+
def test_class_create_key
|
98
|
+
key = @SEC.create_key 256
|
99
|
+
|
100
|
+
assert_kind_of OpenSSL::PKey::RSA, key
|
82
101
|
end
|
83
102
|
|
84
103
|
def test_class_email_to_name
|
85
|
-
munger = Gem::Security::OPT[:munge_re]
|
86
|
-
|
87
104
|
assert_equal '/CN=nobody/DC=example',
|
88
|
-
|
105
|
+
@SEC.email_to_name('nobody@example').to_s
|
89
106
|
|
90
107
|
assert_equal '/CN=nobody/DC=example/DC=com',
|
91
|
-
|
108
|
+
@SEC.email_to_name('nobody@example.com').to_s
|
92
109
|
|
93
110
|
assert_equal '/CN=no.body/DC=example',
|
94
|
-
|
111
|
+
@SEC.email_to_name('no.body@example').to_s
|
95
112
|
|
96
113
|
assert_equal '/CN=no_body/DC=example',
|
97
|
-
|
114
|
+
@SEC.email_to_name('no+body@example').to_s
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_class_re_sign
|
118
|
+
re_signed = Gem::Security.re_sign EXPIRED_CERT, PRIVATE_KEY, 60
|
119
|
+
|
120
|
+
assert_in_delta Time.now, re_signed.not_before, 10
|
121
|
+
assert_in_delta Time.now + 60, re_signed.not_after, 10
|
122
|
+
assert_equal 2, re_signed.serial
|
123
|
+
|
124
|
+
assert re_signed.verify PUBLIC_KEY
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_class_re_sign_not_self_signed
|
128
|
+
e = assert_raises Gem::Security::Exception do
|
129
|
+
Gem::Security.re_sign CHILD_CERT, CHILD_KEY
|
130
|
+
end
|
131
|
+
|
132
|
+
assert_equal "#{ALTERNATE_CERT.subject} is not self-signed, contact " \
|
133
|
+
"#{ALTERNATE_CERT.issuer} to obtain a valid certificate",
|
134
|
+
e.message
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_class_re_sign_wrong_key
|
138
|
+
e = assert_raises Gem::Security::Exception do
|
139
|
+
Gem::Security.re_sign ALTERNATE_CERT, PRIVATE_KEY
|
140
|
+
end
|
141
|
+
|
142
|
+
assert_equal "incorrect signing key for re-signing " \
|
143
|
+
"#{ALTERNATE_CERT.subject}",
|
144
|
+
e.message
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_class_reset
|
148
|
+
trust_dir = @SEC.trust_dir
|
149
|
+
|
150
|
+
@SEC.reset
|
151
|
+
|
152
|
+
refute_equal trust_dir, @SEC.trust_dir
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_class_sign
|
156
|
+
issuer = PUBLIC_CERT.subject
|
157
|
+
signee = OpenSSL::X509::Name.parse "/CN=signee/DC=example"
|
158
|
+
|
159
|
+
key = PRIVATE_KEY
|
160
|
+
cert = OpenSSL::X509::Certificate.new
|
161
|
+
cert.subject = signee
|
162
|
+
|
163
|
+
cert.subject = signee
|
164
|
+
cert.public_key = key.public_key
|
165
|
+
|
166
|
+
signed = @SEC.sign cert, key, PUBLIC_CERT, 60
|
167
|
+
|
168
|
+
assert_equal key.public_key.to_pem, signed.public_key.to_pem
|
169
|
+
assert_equal signee.to_s, signed.subject.to_s
|
170
|
+
assert_equal issuer.to_s, signed.issuer.to_s
|
171
|
+
|
172
|
+
assert_in_delta Time.now, signed.not_before, 10
|
173
|
+
assert_in_delta Time.now + 60, signed.not_after, 10
|
174
|
+
|
175
|
+
assert_equal 4, signed.extensions.length,
|
176
|
+
signed.extensions.map { |e| e.to_a.first }
|
177
|
+
|
178
|
+
constraints = signed.extensions.find { |ext| ext.oid == 'issuerAltName' }
|
179
|
+
assert_equal 'email:nobody@example', constraints.value, 'issuerAltName'
|
180
|
+
|
181
|
+
constraints = signed.extensions.find { |ext| ext.oid == 'basicConstraints' }
|
182
|
+
assert_equal 'CA:FALSE', constraints.value
|
183
|
+
|
184
|
+
key_usage = signed.extensions.find { |ext| ext.oid == 'keyUsage' }
|
185
|
+
assert_equal 'Digital Signature, Key Encipherment, Data Encipherment',
|
186
|
+
key_usage.value
|
187
|
+
|
188
|
+
key_ident =
|
189
|
+
signed.extensions.find { |ext| ext.oid == 'subjectKeyIdentifier' }
|
190
|
+
assert_equal 59, key_ident.value.length
|
191
|
+
assert_equal 'B0:EB:9C:A5:E5:8E:7D:94:BB:4B:3B:D6:80:CB:A5:AD:5D:12:88:90',
|
192
|
+
key_ident.value
|
193
|
+
|
194
|
+
assert signed.verify key
|
98
195
|
end
|
99
196
|
|
100
|
-
|
197
|
+
def test_class_sign_AltName
|
198
|
+
issuer = PUBLIC_CERT.subject
|
199
|
+
signee = OpenSSL::X509::Name.parse "/CN=signee/DC=example"
|
200
|
+
|
201
|
+
cert = @SEC.create_cert_email 'signee@example', PRIVATE_KEY
|
202
|
+
|
203
|
+
signed = @SEC.sign cert, PRIVATE_KEY, PUBLIC_CERT, 60
|
204
|
+
|
205
|
+
assert_equal PUBLIC_KEY.to_pem, signed.public_key.to_pem
|
206
|
+
assert_equal signee.to_s, signed.subject.to_s
|
207
|
+
assert_equal issuer.to_s, signed.issuer.to_s
|
208
|
+
|
209
|
+
assert_in_delta Time.now, signed.not_before, 10
|
210
|
+
assert_in_delta Time.now + 60, signed.not_after, 10
|
211
|
+
|
212
|
+
assert_equal 5, signed.extensions.length,
|
213
|
+
signed.extensions.map { |e| e.to_a.first }
|
214
|
+
|
215
|
+
constraints = signed.extensions.find { |ext| ext.oid == 'issuerAltName' }
|
216
|
+
assert_equal 'email:nobody@example', constraints.value, 'issuerAltName'
|
217
|
+
|
218
|
+
constraints = signed.extensions.find { |ext| ext.oid == 'subjectAltName' }
|
219
|
+
assert_equal 'email:signee@example', constraints.value, 'subjectAltName'
|
220
|
+
|
221
|
+
constraints = signed.extensions.find { |ext| ext.oid == 'basicConstraints' }
|
222
|
+
assert_equal 'CA:FALSE', constraints.value
|
223
|
+
|
224
|
+
key_usage = signed.extensions.find { |ext| ext.oid == 'keyUsage' }
|
225
|
+
assert_equal 'Digital Signature, Key Encipherment, Data Encipherment',
|
226
|
+
key_usage.value
|
227
|
+
|
228
|
+
key_ident =
|
229
|
+
signed.extensions.find { |ext| ext.oid == 'subjectKeyIdentifier' }
|
230
|
+
assert_equal 59, key_ident.value.length
|
231
|
+
assert_equal 'B0:EB:9C:A5:E5:8E:7D:94:BB:4B:3B:D6:80:CB:A5:AD:5D:12:88:90',
|
232
|
+
key_ident.value
|
233
|
+
|
234
|
+
assert signed.verify PUBLIC_KEY
|
235
|
+
end
|
236
|
+
|
237
|
+
def test_class_trust_dir
|
238
|
+
trust_dir = @SEC.trust_dir
|
239
|
+
|
240
|
+
expected = File.join Gem.user_home, '.gem/trust'
|
241
|
+
|
242
|
+
assert_equal expected, trust_dir.dir
|
243
|
+
end
|
244
|
+
|
245
|
+
end
|
246
|
+
|