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
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'rubygems/test_case'
|
2
|
+
|
3
|
+
class TestGemSecurityTrustDir < Gem::TestCase
|
4
|
+
|
5
|
+
CHILD_CERT = load_cert 'child'
|
6
|
+
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
|
10
|
+
@dest_dir = File.join @tempdir, 'trust'
|
11
|
+
|
12
|
+
@trust_dir = Gem::Security::TrustDir.new @dest_dir
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_cert_path
|
16
|
+
digest = OpenSSL::Digest::SHA1.hexdigest PUBLIC_CERT.subject.to_s
|
17
|
+
|
18
|
+
expected = File.join @dest_dir, "cert-#{digest}.pem"
|
19
|
+
|
20
|
+
assert_equal expected, @trust_dir.cert_path(PUBLIC_CERT)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_issuer_of
|
24
|
+
assert_nil @trust_dir.issuer_of(CHILD_CERT)
|
25
|
+
|
26
|
+
@trust_dir.trust_cert PUBLIC_CERT
|
27
|
+
|
28
|
+
assert_equal PUBLIC_CERT.to_pem, @trust_dir.issuer_of(CHILD_CERT).to_pem
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_load_certificate
|
32
|
+
@trust_dir.trust_cert PUBLIC_CERT
|
33
|
+
|
34
|
+
path = @trust_dir.cert_path PUBLIC_CERT
|
35
|
+
|
36
|
+
assert_equal PUBLIC_CERT.to_pem, @trust_dir.load_certificate(path).to_pem
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_name_path
|
40
|
+
digest = OpenSSL::Digest::SHA1.hexdigest PUBLIC_CERT.subject.to_s
|
41
|
+
|
42
|
+
expected = File.join @dest_dir, "cert-#{digest}.pem"
|
43
|
+
|
44
|
+
assert_equal expected, @trust_dir.name_path(PUBLIC_CERT.subject)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_trust_cert
|
48
|
+
@trust_dir.trust_cert PUBLIC_CERT
|
49
|
+
|
50
|
+
trusted = @trust_dir.cert_path PUBLIC_CERT
|
51
|
+
|
52
|
+
assert_path_exists trusted
|
53
|
+
|
54
|
+
mask = 0100600 & (~File.umask)
|
55
|
+
|
56
|
+
assert_equal mask, File.stat(trusted).mode unless win_platform?
|
57
|
+
|
58
|
+
assert_equal PUBLIC_CERT.to_pem, File.read(trusted)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_verify
|
62
|
+
refute_path_exists @dest_dir
|
63
|
+
|
64
|
+
@trust_dir.verify
|
65
|
+
|
66
|
+
assert_path_exists @dest_dir
|
67
|
+
|
68
|
+
mask = 040700 & (~File.umask)
|
69
|
+
|
70
|
+
assert_equal mask, File.stat(@dest_dir).mode unless win_platform?
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_verify_file
|
74
|
+
FileUtils.touch @dest_dir
|
75
|
+
|
76
|
+
e = assert_raises Gem::Security::Exception do
|
77
|
+
@trust_dir.verify
|
78
|
+
end
|
79
|
+
|
80
|
+
assert_equal "trust directory #{@dest_dir} is not a directory", e.message
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_verify_wrong_permissions
|
84
|
+
FileUtils.mkdir_p @dest_dir, :mode => 0777
|
85
|
+
|
86
|
+
@trust_dir.verify
|
87
|
+
|
88
|
+
mask = 040700 & (~File.umask)
|
89
|
+
|
90
|
+
assert_equal mask, File.stat(@dest_dir).mode unless win_platform?
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
@@ -18,55 +18,50 @@ class TestGemServer < Gem::TestCase
|
|
18
18
|
@res = WEBrick::HTTPResponse.new :HTTPVersion => '1.0'
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
|
21
|
+
def test_doc_root_3
|
22
|
+
orig_rdoc_version = Gem::RDoc.rdoc_version
|
23
|
+
Gem::RDoc.instance_variable_set :@rdoc_version, Gem::Version.new('3.12')
|
23
24
|
|
24
|
-
assert_equal
|
25
|
-
|
26
|
-
s = Gem::Server.new [Gem.dir, Gem.dir], process_based_port, false
|
25
|
+
assert_equal '/doc_root/X-1/rdoc/index.html', @server.doc_root('X-1')
|
27
26
|
|
28
|
-
|
29
|
-
|
27
|
+
ensure
|
28
|
+
Gem::RDoc.instance_variable_set :@rdoc_version, orig_rdoc_version
|
30
29
|
end
|
31
30
|
|
32
|
-
def
|
33
|
-
|
34
|
-
|
31
|
+
def test_doc_root_4
|
32
|
+
orig_rdoc_version = Gem::RDoc.rdoc_version
|
33
|
+
Gem::RDoc.instance_variable_set :@rdoc_version, Gem::Version.new('4.0')
|
35
34
|
|
36
|
-
|
37
|
-
@server.Marshal @req, @res
|
38
|
-
end
|
35
|
+
assert_equal '/doc_root/X-1/', @server.doc_root('X-1')
|
39
36
|
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
ensure
|
38
|
+
Gem::RDoc.instance_variable_set :@rdoc_version, orig_rdoc_version
|
39
|
+
end
|
43
40
|
|
44
|
-
|
45
|
-
|
46
|
-
|
41
|
+
def test_have_rdoc_4_plus_eh
|
42
|
+
orig_rdoc_version = Gem::RDoc.rdoc_version
|
43
|
+
Gem::RDoc.instance_variable_set :@rdoc_version, Gem::Version.new('4.0')
|
47
44
|
|
48
|
-
|
49
|
-
|
50
|
-
end
|
45
|
+
server = Gem::Server.new Gem.dir, 0, false
|
46
|
+
assert server.have_rdoc_4_plus?
|
51
47
|
|
52
|
-
|
53
|
-
data = StringIO.new "GET /Marshal.#{Gem.marshal_version}.Z HTTP/1.0\r\n\r\n"
|
54
|
-
@req.parse data
|
48
|
+
Gem::RDoc.instance_variable_set :@rdoc_version, Gem::Version.new('3.12')
|
55
49
|
|
56
|
-
Gem::
|
57
|
-
|
58
|
-
|
50
|
+
server = Gem::Server.new Gem.dir, 0, false
|
51
|
+
refute server.have_rdoc_4_plus?
|
52
|
+
ensure
|
53
|
+
Gem::RDoc.instance_variable_set :@rdoc_version, orig_rdoc_version
|
54
|
+
end
|
59
55
|
|
60
|
-
|
61
|
-
|
62
|
-
assert_equal 'application/x-deflate', @res['content-type']
|
56
|
+
def test_spec_dirs
|
57
|
+
s = Gem::Server.new Gem.dir, process_based_port, false
|
63
58
|
|
64
|
-
Gem
|
65
|
-
si = Gem::SourceIndex.new
|
66
|
-
si.add_specs @a1, @a2
|
59
|
+
assert_equal [File.join(Gem.dir, 'specifications')], s.spec_dirs
|
67
60
|
|
68
|
-
|
69
|
-
|
61
|
+
s = Gem::Server.new [Gem.dir, Gem.dir], process_based_port, false
|
62
|
+
|
63
|
+
assert_equal [File.join(Gem.dir, 'specifications'),
|
64
|
+
File.join(Gem.dir, 'specifications')], s.spec_dirs
|
70
65
|
end
|
71
66
|
|
72
67
|
def test_latest_specs
|
@@ -49,7 +49,7 @@ class TestGemSilentUI < Gem::TestCase
|
|
49
49
|
|
50
50
|
assert_empty out, 'No output'
|
51
51
|
assert_empty err, 'No output'
|
52
|
-
|
52
|
+
|
53
53
|
out, err = capture_io do
|
54
54
|
use_ui @sui do
|
55
55
|
value = @sui.ask_yes_no 'Problem?', true
|
@@ -60,7 +60,7 @@ class TestGemSilentUI < Gem::TestCase
|
|
60
60
|
assert_empty err, 'No output'
|
61
61
|
|
62
62
|
assert value, 'Value is true'
|
63
|
-
|
63
|
+
|
64
64
|
out, err = capture_io do
|
65
65
|
use_ui @sui do
|
66
66
|
value = @sui.ask_yes_no 'Problem?', false
|
@@ -0,0 +1,188 @@
|
|
1
|
+
require 'rubygems/test_case'
|
2
|
+
require 'rubygems/source'
|
3
|
+
|
4
|
+
class TestGemSource < Gem::TestCase
|
5
|
+
|
6
|
+
def tuple(*args)
|
7
|
+
Gem::NameTuple.new(*args)
|
8
|
+
end
|
9
|
+
|
10
|
+
def setup
|
11
|
+
super
|
12
|
+
|
13
|
+
util_setup_fake_fetcher
|
14
|
+
|
15
|
+
@a_pre = new_spec 'a', '1.a'
|
16
|
+
|
17
|
+
install_specs @a_pre
|
18
|
+
|
19
|
+
@source = Gem::Source.new(@gem_repo)
|
20
|
+
|
21
|
+
Gem::Specification.remove_spec @b2
|
22
|
+
|
23
|
+
all = Gem::Specification.map { |spec|
|
24
|
+
Gem::NameTuple.new(spec.name, spec.version, spec.original_platform)
|
25
|
+
}.sort
|
26
|
+
|
27
|
+
@prerelease_specs, @specs = all.partition { |g| g.prerelease? }
|
28
|
+
|
29
|
+
# TODO: couldn't all of this come from the fake spec fetcher?
|
30
|
+
@latest_specs = Gem::Specification.latest_specs.sort.map { |spec|
|
31
|
+
Gem::NameTuple.new(spec.name, spec.version, spec.original_platform)
|
32
|
+
}
|
33
|
+
|
34
|
+
v = Gem.marshal_version
|
35
|
+
s_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@specs)))
|
36
|
+
l_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@latest_specs)))
|
37
|
+
p_zip = util_gzip(Marshal.dump(Gem::NameTuple.to_basic(@prerelease_specs)))
|
38
|
+
@fetcher.data["#{@gem_repo}specs.#{v}.gz"] = s_zip
|
39
|
+
@fetcher.data["#{@gem_repo}latest_specs.#{v}.gz"] = l_zip
|
40
|
+
@fetcher.data["#{@gem_repo}prerelease_specs.#{v}.gz"] = p_zip
|
41
|
+
|
42
|
+
@released = Gem::NameTuple.from_list \
|
43
|
+
[["a", Gem::Version.new("1"), "ruby"],
|
44
|
+
["a", Gem::Version.new("2"), "ruby"],
|
45
|
+
["a_evil", Gem::Version.new("9"), "ruby"],
|
46
|
+
["c", Gem::Version.new("1.2"), "ruby"],
|
47
|
+
['dep_x', Gem::Version.new(1), 'ruby'],
|
48
|
+
["pl", Gem::Version.new("1"), "i386-linux"],
|
49
|
+
['x', Gem::Version.new(1), 'ruby']]
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_api_uri
|
53
|
+
assert_equal @source.api_uri, @source.uri
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_api_uri_resolved_from_remote_fetcher
|
57
|
+
uri = URI.parse "http://gem.example/foo"
|
58
|
+
@fetcher.api_endpoints[uri] = URI.parse "http://api.blah"
|
59
|
+
|
60
|
+
src = Gem::Source.new uri
|
61
|
+
assert_equal URI.parse("http://api.blah"), src.api_uri
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_cache_dir_escapes_windows_paths
|
65
|
+
uri = URI.parse("file:///C:/WINDOWS/Temp/gem_repo")
|
66
|
+
root = File.join Gem.user_home, '.gem', 'specs'
|
67
|
+
cache_dir = @source.cache_dir(uri).gsub(root, '')
|
68
|
+
assert cache_dir !~ /:/, "#{cache_dir} should not contain a :"
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_fetch_spec
|
72
|
+
spec_uri = "#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a1.spec_name}"
|
73
|
+
@fetcher.data["#{spec_uri}.rz"] = util_zip(Marshal.dump(@a1))
|
74
|
+
|
75
|
+
spec = @source.fetch_spec tuple('a', Gem::Version.new(1), 'ruby')
|
76
|
+
assert_equal @a1.full_name, spec.full_name
|
77
|
+
|
78
|
+
cache_dir = @source.cache_dir URI.parse(spec_uri)
|
79
|
+
|
80
|
+
cache_file = File.join cache_dir, @a1.spec_name
|
81
|
+
|
82
|
+
assert File.exist?(cache_file)
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_fetch_spec_cached
|
86
|
+
spec_uri = "#{@gem_repo}/#{Gem::MARSHAL_SPEC_DIR}#{@a1.spec_name}"
|
87
|
+
@fetcher.data["#{spec_uri}.rz"] = nil
|
88
|
+
|
89
|
+
cache_dir = @source.cache_dir URI.parse(spec_uri)
|
90
|
+
FileUtils.mkdir_p cache_dir
|
91
|
+
|
92
|
+
cache_file = File.join cache_dir, @a1.spec_name
|
93
|
+
|
94
|
+
open cache_file, 'wb' do |io|
|
95
|
+
Marshal.dump @a1, io
|
96
|
+
end
|
97
|
+
|
98
|
+
spec = @source.fetch_spec tuple('a', Gem::Version.new(1), 'ruby')
|
99
|
+
assert_equal @a1.full_name, spec.full_name
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_fetch_spec_platform
|
103
|
+
@fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@pl1.original_name}.gemspec.rz"] =
|
104
|
+
util_zip(Marshal.dump(@pl1))
|
105
|
+
|
106
|
+
spec = @source.fetch_spec tuple('pl', Gem::Version.new(1), 'i386-linux')
|
107
|
+
|
108
|
+
assert_equal @pl1.full_name, spec.full_name
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_fetch_spec_platform_ruby
|
112
|
+
@fetcher.data["#{@gem_repo}#{Gem::MARSHAL_SPEC_DIR}#{@a1.spec_name}.rz"] =
|
113
|
+
util_zip(Marshal.dump(@a1))
|
114
|
+
|
115
|
+
spec = @source.fetch_spec tuple('a', Gem::Version.new(1), nil)
|
116
|
+
assert_equal @a1.full_name, spec.full_name
|
117
|
+
|
118
|
+
spec = @source.fetch_spec tuple('a', Gem::Version.new(1), '')
|
119
|
+
assert_equal @a1.full_name, spec.full_name
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_load_specs
|
123
|
+
expected = @released
|
124
|
+
assert_equal expected, @source.load_specs(:released)
|
125
|
+
|
126
|
+
cache_dir = File.join Gem.user_home, '.gem', 'specs', 'gems.example.com%80'
|
127
|
+
assert File.exist?(cache_dir), "#{cache_dir} does not exist"
|
128
|
+
|
129
|
+
cache_file = File.join cache_dir, "specs.#{Gem.marshal_version}"
|
130
|
+
assert File.exist?(cache_file)
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_load_specs_cached
|
134
|
+
# Make sure the cached version is actually different:
|
135
|
+
@latest_specs << Gem::NameTuple.new('cached', Gem::Version.new('1.0.0'), 'ruby')
|
136
|
+
|
137
|
+
@fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] = nil
|
138
|
+
@fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}"] =
|
139
|
+
' ' * Marshal.dump(@latest_specs).length
|
140
|
+
|
141
|
+
cache_dir = File.join Gem.user_home, '.gem', 'specs', 'gems.example.com%80'
|
142
|
+
|
143
|
+
FileUtils.mkdir_p cache_dir
|
144
|
+
|
145
|
+
cache_file = File.join cache_dir, "latest_specs.#{Gem.marshal_version}"
|
146
|
+
|
147
|
+
open cache_file, 'wb' do |io|
|
148
|
+
Marshal.dump @latest_specs, io
|
149
|
+
end
|
150
|
+
|
151
|
+
latest_specs = @source.load_specs :latest
|
152
|
+
|
153
|
+
assert_equal @latest_specs, latest_specs
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_load_specs_cached_empty
|
157
|
+
# Make sure the cached version is actually different:
|
158
|
+
@latest_specs << Gem::NameTuple.new('fixed', Gem::Version.new('1.0.0'), 'ruby')
|
159
|
+
# Setup valid data on the 'remote'
|
160
|
+
@fetcher.data["#{@gem_repo}latest_specs.#{Gem.marshal_version}.gz"] =
|
161
|
+
util_gzip(Marshal.dump(@latest_specs))
|
162
|
+
|
163
|
+
cache_dir = File.join Gem.user_home, '.gem', 'specs', 'gems.example.com%80'
|
164
|
+
|
165
|
+
FileUtils.mkdir_p cache_dir
|
166
|
+
|
167
|
+
cache_file = File.join cache_dir, "latest_specs.#{Gem.marshal_version}"
|
168
|
+
|
169
|
+
open cache_file, 'wb' do |io|
|
170
|
+
# Setup invalid data in the cache:
|
171
|
+
io.write Marshal.dump(@latest_specs)[0, 10]
|
172
|
+
end
|
173
|
+
|
174
|
+
latest_specs = @source.load_specs :latest
|
175
|
+
|
176
|
+
assert_equal @latest_specs, latest_specs
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_load_specs_from_unavailable_uri
|
180
|
+
src = Gem::Source.new("http://not-there.nothing")
|
181
|
+
|
182
|
+
assert_raises Gem::RemoteFetcher::FetchError do
|
183
|
+
src.load_specs :latest
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
188
|
+
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'rubygems/source_list'
|
2
|
+
require 'rubygems/test_case'
|
3
|
+
|
4
|
+
class TestGemSourceList < Gem::TestCase
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
|
8
|
+
@uri = "http://blah.com"
|
9
|
+
@source = Gem::Source.new(@uri)
|
10
|
+
|
11
|
+
@sl = Gem::SourceList.new
|
12
|
+
@sl << @source
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_self_from
|
16
|
+
sl = Gem::SourceList.from [@uri]
|
17
|
+
|
18
|
+
assert_equal [Gem::Source.new(@uri)], sl.sources
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_append
|
22
|
+
sl = Gem::SourceList.new
|
23
|
+
source = (sl << @uri)
|
24
|
+
|
25
|
+
assert_kind_of Gem::Source, source
|
26
|
+
|
27
|
+
assert_kind_of URI, source.uri
|
28
|
+
assert_equal source.uri.to_s, @uri
|
29
|
+
|
30
|
+
assert_equal [source], sl.sources
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_replace
|
34
|
+
sl = Gem::SourceList.new
|
35
|
+
sl.replace [@uri]
|
36
|
+
|
37
|
+
assert_equal [@source], sl.sources
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_each
|
41
|
+
@sl.each do |x|
|
42
|
+
assert_equal @uri, x
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_each_source
|
47
|
+
@sl.each_source do |x|
|
48
|
+
assert_equal @source, x
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_equal_to_another_list
|
53
|
+
sl2 = Gem::SourceList.new
|
54
|
+
sl2 << Gem::Source.new(@uri)
|
55
|
+
|
56
|
+
assert @sl == sl2, "lists not equal"
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_equal_to_array
|
60
|
+
assert @sl == [@uri], "lists not equal"
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_to_a
|
64
|
+
assert_equal @sl.to_a, [@uri]
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_include_eh
|
68
|
+
assert @sl.include?(@uri), "string comparison not working"
|
69
|
+
assert @sl.include?(URI.parse(@uri)), "uri comparison not working"
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_include_matches_a_source
|
73
|
+
assert @sl.include?(@source), "source comparison not working"
|
74
|
+
assert @sl.include?(Gem::Source.new(@uri)), "source comparison not working"
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_delete
|
78
|
+
@sl.delete @uri
|
79
|
+
assert_equal @sl.sources, []
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_delete_a_source
|
83
|
+
@sl.delete Gem::Source.new(@uri)
|
84
|
+
assert_equal @sl.sources, []
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|