rubygems-update 2.0.17 → 2.1.0.rc.1
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -0
- data/.autotest +1 -1
- data/History.txt +82 -153
- data/Manifest.txt +35 -9
- data/Rakefile +35 -36
- data/lib/rubygems.rb +106 -18
- data/lib/rubygems/available_set.rb +68 -0
- data/lib/rubygems/basic_specification.rb +139 -0
- data/lib/rubygems/command_manager.rb +37 -40
- data/lib/rubygems/commands/cert_command.rb +78 -29
- data/lib/rubygems/commands/cleanup_command.rb +2 -2
- data/lib/rubygems/commands/contents_command.rb +101 -58
- data/lib/rubygems/commands/dependency_command.rb +94 -53
- data/lib/rubygems/commands/environment_command.rb +70 -53
- data/lib/rubygems/commands/fetch_command.rb +1 -2
- data/lib/rubygems/commands/help_command.rb +85 -55
- data/lib/rubygems/commands/install_command.rb +84 -42
- data/lib/rubygems/commands/outdated_command.rb +2 -12
- data/lib/rubygems/commands/owner_command.rb +6 -0
- data/lib/rubygems/commands/pristine_command.rb +26 -16
- data/lib/rubygems/commands/sources_command.rb +85 -70
- data/lib/rubygems/commands/uninstall_command.rb +32 -2
- data/lib/rubygems/commands/update_command.rb +111 -75
- data/lib/rubygems/config_file.rb +15 -3
- data/lib/rubygems/core_ext/kernel_require.rb +9 -31
- data/lib/rubygems/defaults.rb +8 -0
- data/lib/rubygems/dependency.rb +4 -2
- data/lib/rubygems/dependency_installer.rb +180 -170
- data/lib/rubygems/dependency_resolver.rb +191 -526
- data/lib/rubygems/dependency_resolver/activation_request.rb +109 -0
- data/lib/rubygems/dependency_resolver/api_set.rb +65 -0
- data/lib/rubygems/dependency_resolver/api_specification.rb +36 -0
- data/lib/rubygems/dependency_resolver/composed_set.rb +18 -0
- data/lib/rubygems/dependency_resolver/current_set.rb +16 -0
- data/lib/rubygems/dependency_resolver/dependency_conflict.rb +85 -0
- data/lib/rubygems/dependency_resolver/dependency_request.rb +51 -0
- data/lib/rubygems/dependency_resolver/index_set.rb +59 -0
- data/lib/rubygems/dependency_resolver/index_specification.rb +53 -0
- data/lib/rubygems/dependency_resolver/installed_specification.rb +38 -0
- data/lib/rubygems/dependency_resolver/installer_set.rb +130 -0
- data/lib/rubygems/exceptions.rb +88 -1
- data/lib/rubygems/ext/builder.rb +1 -1
- data/lib/rubygems/gem_runner.rb +17 -9
- data/lib/rubygems/gemcutter_utilities.rb +72 -42
- data/lib/rubygems/install_default_message.rb +12 -0
- data/lib/rubygems/install_update_options.rb +3 -0
- data/lib/rubygems/installer.rb +55 -30
- data/lib/rubygems/name_tuple.rb +18 -7
- data/lib/rubygems/package.rb +50 -25
- data/lib/rubygems/package/tar_test_case.rb +9 -9
- data/lib/rubygems/package/tar_writer.rb +35 -12
- data/lib/rubygems/package_task.rb +2 -5
- data/lib/rubygems/path_support.rb +10 -0
- data/lib/rubygems/platform.rb +9 -3
- data/lib/rubygems/psych_additions.rb +1 -1
- data/lib/rubygems/remote_fetcher.rb +9 -276
- data/lib/rubygems/request.rb +267 -0
- data/lib/rubygems/request_set.rb +123 -125
- data/lib/rubygems/request_set/gem_dependency_api.rb +39 -0
- data/lib/rubygems/security.rb +32 -23
- data/lib/rubygems/security/policy.rb +35 -9
- data/lib/rubygems/security/signer.rb +2 -2
- data/lib/rubygems/server.rb +8 -16
- data/lib/rubygems/source.rb +25 -14
- data/lib/rubygems/source/installed.rb +28 -0
- data/lib/rubygems/source/local.rb +122 -0
- data/lib/rubygems/source/specific_file.rb +28 -0
- data/lib/rubygems/source_local.rb +2 -89
- data/lib/rubygems/source_specific_file.rb +2 -26
- data/lib/rubygems/spec_fetcher.rb +11 -11
- data/lib/rubygems/specification.rb +186 -198
- 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/{GeoTrustGlobalCA.pem → GeoTrust_Global_CA.pem} +20 -20
- data/lib/rubygems/ssl_certs/VerisignClass3PublicPrimaryCertificationAuthority-G2.pem +57 -0
- data/lib/rubygems/stub_specification.rb +119 -0
- data/lib/rubygems/test_case.rb +117 -49
- data/lib/rubygems/uninstaller.rb +14 -9
- data/lib/rubygems/uri_formatter.rb +39 -0
- data/lib/rubygems/util/list.rb +44 -0
- data/lib/rubygems/version.rb +15 -5
- data/lib/rubygems/version_option.rb +8 -2
- data/test/rubygems/ca_cert.pem +23 -0
- data/test/rubygems/client.pem +49 -0
- data/test/rubygems/encrypted_private_key.pem +30 -0
- data/test/rubygems/invalid_client.pem +49 -0
- data/test/rubygems/specifications/bar-0.0.2.gemspec +9 -0
- data/test/rubygems/specifications/foo-0.0.1.gemspec +0 -0
- data/test/rubygems/test_gem.rb +76 -454
- data/test/rubygems/test_gem_command_manager.rb +23 -21
- data/test/rubygems/test_gem_commands_cert_command.rb +154 -14
- data/test/rubygems/test_gem_commands_cleanup_command.rb +15 -0
- data/test/rubygems/test_gem_commands_contents_command.rb +32 -4
- data/test/rubygems/test_gem_commands_environment_command.rb +9 -1
- data/test/rubygems/test_gem_commands_fetch_command.rb +2 -28
- data/test/rubygems/test_gem_commands_help_command.rb +6 -3
- data/test/rubygems/test_gem_commands_install_command.rb +2 -65
- data/test/rubygems/test_gem_commands_owner_command.rb +49 -0
- data/test/rubygems/test_gem_commands_pristine_command.rb +30 -0
- data/test/rubygems/test_gem_commands_sources_command.rb +1 -1
- data/test/rubygems/test_gem_commands_uninstall_command.rb +33 -0
- data/test/rubygems/test_gem_commands_update_command.rb +2 -1
- data/test/rubygems/test_gem_config_file.rb +12 -0
- data/test/rubygems/test_gem_dependency_installer.rb +58 -65
- data/test/rubygems/test_gem_dependency_resolver.rb +6 -3
- data/test/rubygems/test_gem_dependency_resolver_dependency_conflict.rb +36 -0
- data/test/rubygems/test_gem_ext_builder.rb +2 -4
- data/test/rubygems/test_gem_ext_ext_conf_builder.rb +7 -2
- data/test/rubygems/test_gem_gem_runner.rb +17 -13
- data/test/rubygems/test_gem_gemcutter_utilities.rb +6 -19
- data/test/rubygems/test_gem_impossible_dependencies_error.rb +41 -0
- data/test/rubygems/test_gem_install_update_options.rb +4 -1
- data/test/rubygems/test_gem_installer.rb +31 -2
- data/test/rubygems/test_gem_name_tuple.rb +22 -0
- data/test/rubygems/test_gem_package.rb +122 -11
- data/test/rubygems/test_gem_package_old.rb +8 -0
- data/test/rubygems/test_gem_package_tar_reader.rb +9 -8
- data/test/rubygems/test_gem_package_tar_reader_entry.rb +1 -1
- data/test/rubygems/test_gem_package_tar_writer.rb +78 -56
- data/test/rubygems/test_gem_package_task.rb +2 -23
- data/test/rubygems/test_gem_path_support.rb +17 -0
- data/test/rubygems/test_gem_platform.rb +18 -0
- data/test/rubygems/test_gem_remote_fetcher.rb +106 -385
- data/test/rubygems/test_gem_request.rb +239 -0
- data/test/rubygems/test_gem_requirement.rb +9 -11
- data/test/rubygems/test_gem_security.rb +58 -2
- data/test/rubygems/test_gem_security_policy.rb +42 -1
- data/test/rubygems/test_gem_security_signer.rb +13 -1
- data/test/rubygems/test_gem_security_trust_dir.rb +5 -1
- data/test/rubygems/test_gem_server.rb +1 -105
- data/test/rubygems/test_gem_source.rb +4 -14
- data/test/rubygems/test_gem_source_local.rb +4 -4
- data/test/rubygems/test_gem_source_specific_file.rb +1 -1
- data/test/rubygems/test_gem_spec_fetcher.rb +0 -12
- data/test/rubygems/test_gem_specification.rb +452 -28
- data/test/rubygems/test_gem_stub_specification.rb +30 -0
- data/test/rubygems/test_gem_uninstaller.rb +14 -0
- data/test/rubygems/test_gem_uri_formatter.rb +20 -0
- data/test/rubygems/test_gem_version.rb +23 -13
- data/test/rubygems/test_gem_version_option.rb +63 -1
- data/test/rubygems/test_require.rb +0 -12
- data/util/create_encrypted_key.rb +16 -0
- metadata +161 -23
- metadata.gz.sig +0 -0
- data/CVE-2013-4287.txt +0 -36
- data/CVE-2013-4363.txt +0 -45
- 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/test/rubygems/test_bundled_ca.rb +0 -59
- data/util/update_bundled_ca_certificates.rb +0 -103
@@ -58,7 +58,7 @@ class TestGemCommandManager < Gem::TestCase
|
|
58
58
|
|
59
59
|
use_ui @ui do
|
60
60
|
assert_raises Gem::MockGemUi::TermError do
|
61
|
-
@command_manager.run
|
61
|
+
@command_manager.run %w[interrupt]
|
62
62
|
end
|
63
63
|
assert_equal '', ui.output
|
64
64
|
assert_equal "ERROR: Interrupted\n", ui.error
|
@@ -75,7 +75,7 @@ class TestGemCommandManager < Gem::TestCase
|
|
75
75
|
@command_manager.register_command :crash
|
76
76
|
use_ui @ui do
|
77
77
|
assert_raises Gem::MockGemUi::TermError do
|
78
|
-
@command_manager.run
|
78
|
+
@command_manager.run %w[crash]
|
79
79
|
end
|
80
80
|
assert_equal '', ui.output
|
81
81
|
err = ui.error.split("\n").first
|
@@ -89,7 +89,7 @@ class TestGemCommandManager < Gem::TestCase
|
|
89
89
|
def test_process_args_bad_arg
|
90
90
|
use_ui @ui do
|
91
91
|
assert_raises Gem::MockGemUi::TermError do
|
92
|
-
@command_manager.process_args
|
92
|
+
@command_manager.process_args %w[--bad-arg]
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -107,7 +107,7 @@ class TestGemCommandManager < Gem::TestCase
|
|
107
107
|
end
|
108
108
|
|
109
109
|
#check defaults
|
110
|
-
@command_manager.process_args
|
110
|
+
@command_manager.process_args %w[install]
|
111
111
|
assert_equal %w[ri], check_options[:document].sort
|
112
112
|
assert_equal false, check_options[:force]
|
113
113
|
assert_equal :both, check_options[:domain]
|
@@ -118,8 +118,10 @@ class TestGemCommandManager < Gem::TestCase
|
|
118
118
|
|
119
119
|
#check settings
|
120
120
|
check_options = nil
|
121
|
-
@command_manager.process_args
|
122
|
-
|
121
|
+
@command_manager.process_args %w[
|
122
|
+
install --force --local --rdoc --install-dir .
|
123
|
+
--version 3.0 --no-wrapper --bindir .
|
124
|
+
]
|
123
125
|
assert_equal %w[rdoc ri], check_options[:document].sort
|
124
126
|
assert_equal true, check_options[:force]
|
125
127
|
assert_equal :local, check_options[:domain]
|
@@ -130,17 +132,17 @@ class TestGemCommandManager < Gem::TestCase
|
|
130
132
|
|
131
133
|
#check remote domain
|
132
134
|
check_options = nil
|
133
|
-
@command_manager.process_args
|
135
|
+
@command_manager.process_args %w[install --remote]
|
134
136
|
assert_equal :remote, check_options[:domain]
|
135
137
|
|
136
138
|
#check both domain
|
137
139
|
check_options = nil
|
138
|
-
@command_manager.process_args
|
140
|
+
@command_manager.process_args %w[install --both]
|
139
141
|
assert_equal :both, check_options[:domain]
|
140
142
|
|
141
143
|
#check both domain
|
142
144
|
check_options = nil
|
143
|
-
@command_manager.process_args
|
145
|
+
@command_manager.process_args %w[install --both]
|
144
146
|
assert_equal :both, check_options[:domain]
|
145
147
|
end
|
146
148
|
end
|
@@ -155,12 +157,12 @@ class TestGemCommandManager < Gem::TestCase
|
|
155
157
|
end
|
156
158
|
|
157
159
|
#check defaults
|
158
|
-
@command_manager.process_args
|
160
|
+
@command_manager.process_args %w[uninstall]
|
159
161
|
assert_equal Gem::Requirement.default, check_options[:version]
|
160
162
|
|
161
163
|
#check settings
|
162
164
|
check_options = nil
|
163
|
-
@command_manager.process_args
|
165
|
+
@command_manager.process_args %w[uninstall foobar --version 3.0]
|
164
166
|
assert_equal "foobar", check_options[:args].first
|
165
167
|
assert_equal Gem::Requirement.new('3.0'), check_options[:version]
|
166
168
|
end
|
@@ -175,12 +177,12 @@ class TestGemCommandManager < Gem::TestCase
|
|
175
177
|
end
|
176
178
|
|
177
179
|
#check defaults
|
178
|
-
@command_manager.process_args
|
180
|
+
@command_manager.process_args %w[check]
|
179
181
|
assert_equal true, check_options[:alien]
|
180
182
|
|
181
183
|
#check settings
|
182
184
|
check_options = nil
|
183
|
-
@command_manager.process_args
|
185
|
+
@command_manager.process_args %w[check foobar --alien]
|
184
186
|
assert_equal true, check_options[:alien]
|
185
187
|
end
|
186
188
|
|
@@ -194,12 +196,12 @@ class TestGemCommandManager < Gem::TestCase
|
|
194
196
|
end
|
195
197
|
|
196
198
|
#check defaults
|
197
|
-
@command_manager.process_args
|
199
|
+
@command_manager.process_args %w[build]
|
198
200
|
#NOTE: Currently no defaults
|
199
201
|
|
200
202
|
#check settings
|
201
203
|
check_options = nil
|
202
|
-
@command_manager.process_args
|
204
|
+
@command_manager.process_args %w[build foobar.rb]
|
203
205
|
assert_equal 'foobar.rb', check_options[:args].first
|
204
206
|
end
|
205
207
|
|
@@ -213,26 +215,26 @@ class TestGemCommandManager < Gem::TestCase
|
|
213
215
|
end
|
214
216
|
|
215
217
|
#check defaults
|
216
|
-
@command_manager.process_args
|
218
|
+
@command_manager.process_args %w[query]
|
217
219
|
assert_equal(//, check_options[:name])
|
218
220
|
assert_equal :local, check_options[:domain]
|
219
221
|
assert_equal false, check_options[:details]
|
220
222
|
|
221
223
|
#check settings
|
222
224
|
check_options = nil
|
223
|
-
@command_manager.process_args
|
225
|
+
@command_manager.process_args %w[query --name foobar --local --details]
|
224
226
|
assert_equal(/foobar/i, check_options[:name])
|
225
227
|
assert_equal :local, check_options[:domain]
|
226
228
|
assert_equal true, check_options[:details]
|
227
229
|
|
228
230
|
#remote domain
|
229
231
|
check_options = nil
|
230
|
-
@command_manager.process_args
|
232
|
+
@command_manager.process_args %w[query --remote]
|
231
233
|
assert_equal :remote, check_options[:domain]
|
232
234
|
|
233
235
|
#both (local/remote) domains
|
234
236
|
check_options = nil
|
235
|
-
@command_manager.process_args
|
237
|
+
@command_manager.process_args %w[query --both]
|
236
238
|
assert_equal :both, check_options[:domain]
|
237
239
|
end
|
238
240
|
|
@@ -246,12 +248,12 @@ class TestGemCommandManager < Gem::TestCase
|
|
246
248
|
end
|
247
249
|
|
248
250
|
#check defaults
|
249
|
-
@command_manager.process_args
|
251
|
+
@command_manager.process_args %w[update]
|
250
252
|
assert_includes check_options[:document], 'rdoc'
|
251
253
|
|
252
254
|
#check settings
|
253
255
|
check_options = nil
|
254
|
-
@command_manager.process_args
|
256
|
+
@command_manager.process_args %w[update --force --rdoc --install-dir .]
|
255
257
|
assert_includes check_options[:document], 'ri'
|
256
258
|
assert_equal true, check_options[:force]
|
257
259
|
assert_equal Dir.pwd, check_options[:install_dir]
|
@@ -2,8 +2,8 @@ require 'rubygems/test_case'
|
|
2
2
|
require 'rubygems/commands/cert_command'
|
3
3
|
require 'rubygems/fix_openssl_warnings' if RUBY_VERSION < "1.9"
|
4
4
|
|
5
|
-
unless defined?
|
6
|
-
warn
|
5
|
+
unless defined?(OpenSSL::SSL) then
|
6
|
+
warn 'Skipping `gem cert` tests. openssl not found.'
|
7
7
|
end
|
8
8
|
|
9
9
|
class TestGemCommandsCertCommand < Gem::TestCase
|
@@ -98,14 +98,22 @@ Added '/CN=alternate/DC=example'
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def test_execute_build
|
101
|
+
passphrase = 'Foo bar'
|
102
|
+
|
101
103
|
@cmd.handle_options %W[--build nobody@example.com]
|
102
104
|
|
103
|
-
|
105
|
+
@build_ui = Gem::MockGemUi.new "#{passphrase}\n#{passphrase}"
|
106
|
+
|
107
|
+
use_ui @build_ui do
|
104
108
|
@cmd.execute
|
105
109
|
end
|
106
110
|
|
107
|
-
output = @
|
111
|
+
output = @build_ui.output.split "\n"
|
108
112
|
|
113
|
+
assert_equal "Passphrase for your Private Key: ",
|
114
|
+
output.shift
|
115
|
+
assert_equal "Please repeat the passphrase for your Private Key: ",
|
116
|
+
output.shift
|
109
117
|
assert_equal "Certificate: #{File.join @tempdir, 'gem-public_cert.pem'}",
|
110
118
|
output.shift
|
111
119
|
assert_equal "Private Key: #{File.join @tempdir, 'gem-private_key.pem'}",
|
@@ -115,12 +123,43 @@ Added '/CN=alternate/DC=example'
|
|
115
123
|
output.shift
|
116
124
|
|
117
125
|
assert_empty output
|
118
|
-
assert_empty @
|
126
|
+
assert_empty @build_ui.error
|
119
127
|
|
120
128
|
assert_path_exists File.join(@tempdir, 'gem-private_key.pem')
|
121
129
|
assert_path_exists File.join(@tempdir, 'gem-public_cert.pem')
|
122
130
|
end
|
123
131
|
|
132
|
+
def test_execute_build_bad_passphrase_confirmation
|
133
|
+
passphrase = 'Foo bar'
|
134
|
+
passphrase_confirmation = 'Fu bar'
|
135
|
+
|
136
|
+
@cmd.handle_options %W[--build nobody@example.com]
|
137
|
+
|
138
|
+
@build_ui = Gem::MockGemUi.new "#{passphrase}\n#{passphrase_confirmation}"
|
139
|
+
|
140
|
+
use_ui @build_ui do
|
141
|
+
e = assert_raises Gem::CommandLineError do
|
142
|
+
@cmd.execute
|
143
|
+
end
|
144
|
+
|
145
|
+
output = @build_ui.output.split "\n"
|
146
|
+
|
147
|
+
assert_equal "Passphrase for your Private Key: ",
|
148
|
+
output.shift
|
149
|
+
assert_equal "Please repeat the passphrase for your Private Key: ",
|
150
|
+
output.shift
|
151
|
+
|
152
|
+
assert_empty output
|
153
|
+
|
154
|
+
assert_equal "Passphrase and passphrase confirmation don't match",
|
155
|
+
e.message
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
refute_path_exists File.join(@tempdir, 'gem-private_key.pem')
|
160
|
+
refute_path_exists File.join(@tempdir, 'gem-public_cert.pem')
|
161
|
+
end
|
162
|
+
|
124
163
|
def test_execute_build_key
|
125
164
|
@cmd.handle_options %W[
|
126
165
|
--build nobody@example.com
|
@@ -135,21 +174,32 @@ Added '/CN=alternate/DC=example'
|
|
135
174
|
|
136
175
|
assert_equal "Certificate: #{File.join @tempdir, 'gem-public_cert.pem'}",
|
137
176
|
output.shift
|
138
|
-
assert_equal "Private Key: #{File.join @tempdir, 'gem-private_key.pem'}",
|
139
|
-
output.shift
|
140
|
-
|
141
|
-
assert_equal "Don't forget to move the key file to somewhere private!",
|
142
|
-
output.shift
|
143
177
|
|
144
178
|
assert_empty output
|
145
179
|
assert_empty @ui.error
|
146
180
|
|
147
181
|
assert_path_exists File.join(@tempdir, 'gem-public_cert.pem')
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_execute_build_encrypted_key
|
185
|
+
@cmd.handle_options %W[
|
186
|
+
--build nobody@example.com
|
187
|
+
--private-key #{ENCRYPTED_PRIVATE_KEY_PATH}
|
188
|
+
]
|
189
|
+
|
190
|
+
use_ui @ui do
|
191
|
+
@cmd.execute
|
192
|
+
end
|
193
|
+
|
194
|
+
output = @ui.output.split "\n"
|
195
|
+
|
196
|
+
assert_equal "Certificate: #{File.join @tempdir, 'gem-public_cert.pem'}",
|
197
|
+
output.shift
|
148
198
|
|
149
|
-
|
150
|
-
|
199
|
+
assert_empty output
|
200
|
+
assert_empty @ui.error
|
151
201
|
|
152
|
-
|
202
|
+
assert_path_exists File.join(@tempdir, 'gem-public_cert.pem')
|
153
203
|
end
|
154
204
|
|
155
205
|
def test_execute_certificate
|
@@ -203,6 +253,17 @@ Added '/CN=alternate/DC=example'
|
|
203
253
|
assert_equal PRIVATE_KEY.to_pem, @cmd.options[:key].to_pem
|
204
254
|
end
|
205
255
|
|
256
|
+
def test_execute_encrypted_private_key
|
257
|
+
use_ui @ui do
|
258
|
+
@cmd.send :handle_options, %W[--private-key #{ENCRYPTED_PRIVATE_KEY_PATH}]
|
259
|
+
end
|
260
|
+
|
261
|
+
assert_equal '', @ui.output
|
262
|
+
assert_equal '', @ui.error
|
263
|
+
|
264
|
+
assert_equal ENCRYPTED_PRIVATE_KEY.to_pem, @cmd.options[:key].to_pem
|
265
|
+
end
|
266
|
+
|
206
267
|
def test_execute_remove
|
207
268
|
@trust_dir.trust_cert PUBLIC_CERT
|
208
269
|
|
@@ -307,6 +368,35 @@ Removed '/CN=alternate/DC=example'
|
|
307
368
|
assert_equal mask, File.stat(path).mode unless win_platform?
|
308
369
|
end
|
309
370
|
|
371
|
+
def test_execute_sign_encrypted_key
|
372
|
+
path = File.join @tempdir, 'cert.pem'
|
373
|
+
Gem::Security.write ALTERNATE_CERT, path, 0600
|
374
|
+
|
375
|
+
assert_equal '/CN=alternate/DC=example', ALTERNATE_CERT.issuer.to_s
|
376
|
+
|
377
|
+
@cmd.handle_options %W[
|
378
|
+
--private-key #{ENCRYPTED_PRIVATE_KEY_PATH}
|
379
|
+
--certificate #{PUBLIC_CERT_FILE}
|
380
|
+
|
381
|
+
--sign #{path}
|
382
|
+
]
|
383
|
+
|
384
|
+
use_ui @ui do
|
385
|
+
@cmd.execute
|
386
|
+
end
|
387
|
+
|
388
|
+
assert_equal '', @ui.output
|
389
|
+
assert_equal '', @ui.error
|
390
|
+
|
391
|
+
cert = OpenSSL::X509::Certificate.new File.read path
|
392
|
+
|
393
|
+
assert_equal '/CN=nobody/DC=example', cert.issuer.to_s
|
394
|
+
|
395
|
+
mask = 0100600 & (~File.umask)
|
396
|
+
|
397
|
+
assert_equal mask, File.stat(path).mode unless win_platform?
|
398
|
+
end
|
399
|
+
|
310
400
|
def test_execute_sign_default
|
311
401
|
FileUtils.mkdir_p File.join Gem.user_home, '.gem'
|
312
402
|
|
@@ -339,6 +429,38 @@ Removed '/CN=alternate/DC=example'
|
|
339
429
|
assert_equal mask, File.stat(path).mode unless win_platform?
|
340
430
|
end
|
341
431
|
|
432
|
+
def test_execute_sign_default_encrypted_key
|
433
|
+
FileUtils.mkdir_p File.join(Gem.user_home, '.gem')
|
434
|
+
|
435
|
+
private_key_path = File.join Gem.user_home, '.gem', 'gem-private_key.pem'
|
436
|
+
Gem::Security.write ENCRYPTED_PRIVATE_KEY, private_key_path, 0600, PRIVATE_KEY_PASSPHRASE
|
437
|
+
|
438
|
+
public_cert_path = File.join Gem.user_home, '.gem', 'gem-public_cert.pem'
|
439
|
+
Gem::Security.write PUBLIC_CERT, public_cert_path
|
440
|
+
|
441
|
+
path = File.join @tempdir, 'cert.pem'
|
442
|
+
Gem::Security.write ALTERNATE_CERT, path, 0600
|
443
|
+
|
444
|
+
assert_equal '/CN=alternate/DC=example', ALTERNATE_CERT.issuer.to_s
|
445
|
+
|
446
|
+
@cmd.handle_options %W[--sign #{path}]
|
447
|
+
|
448
|
+
use_ui @ui do
|
449
|
+
@cmd.execute
|
450
|
+
end
|
451
|
+
|
452
|
+
assert_equal '', @ui.output
|
453
|
+
assert_equal '', @ui.error
|
454
|
+
|
455
|
+
cert = OpenSSL::X509::Certificate.new File.read path
|
456
|
+
|
457
|
+
assert_equal '/CN=nobody/DC=example', cert.issuer.to_s
|
458
|
+
|
459
|
+
mask = 0100600 & (~File.umask)
|
460
|
+
|
461
|
+
assert_equal mask, File.stat(path).mode unless win_platform?
|
462
|
+
end
|
463
|
+
|
342
464
|
def test_execute_sign_no_cert
|
343
465
|
FileUtils.mkdir_p File.join Gem.user_home, '.gem'
|
344
466
|
|
@@ -509,6 +631,24 @@ ERROR: --private-key not specified and ~/.gem/gem-private_key.pem does not exis
|
|
509
631
|
assert_equal [ALTERNATE_CERT_FILE, CHILD_CERT_FILE], @cmd.options[:sign]
|
510
632
|
end
|
511
633
|
|
634
|
+
def test_handle_options_sign_encrypted_key
|
635
|
+
@cmd.handle_options %W[
|
636
|
+
--private-key #{ALTERNATE_KEY_FILE}
|
637
|
+
--private-key #{ENCRYPTED_PRIVATE_KEY_PATH}
|
638
|
+
|
639
|
+
--certificate #{ALTERNATE_CERT_FILE}
|
640
|
+
--certificate #{PUBLIC_CERT_FILE}
|
641
|
+
|
642
|
+
--sign #{ALTERNATE_CERT_FILE}
|
643
|
+
--sign #{CHILD_CERT_FILE}
|
644
|
+
]
|
645
|
+
|
646
|
+
assert_equal ENCRYPTED_PRIVATE_KEY.to_pem, @cmd.options[:key].to_pem
|
647
|
+
assert_equal PUBLIC_CERT.to_pem, @cmd.options[:issuer_cert].to_pem
|
648
|
+
|
649
|
+
assert_equal [ALTERNATE_CERT_FILE, CHILD_CERT_FILE], @cmd.options[:sign]
|
650
|
+
end
|
651
|
+
|
512
652
|
def test_handle_options_sign_nonexistent
|
513
653
|
nonexistent = File.join @tempdir, 'nonexistent'
|
514
654
|
e = assert_raises OptionParser::InvalidArgument do
|
@@ -525,5 +665,5 @@ ERROR: --private-key not specified and ~/.gem/gem-private_key.pem does not exis
|
|
525
665
|
e.message
|
526
666
|
end
|
527
667
|
|
528
|
-
end if defined?
|
668
|
+
end if defined?(OpenSSL::SSL)
|
529
669
|
|
@@ -15,6 +15,21 @@ class TestGemCommandsCleanupCommand < Gem::TestCase
|
|
15
15
|
install_gem @a_2
|
16
16
|
end
|
17
17
|
|
18
|
+
def test_handle_options_d
|
19
|
+
@cmd.handle_options %w[-d]
|
20
|
+
assert @cmd.options[:dryrun]
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_handle_options_dry_run
|
24
|
+
@cmd.handle_options %w[--dryrun]
|
25
|
+
assert @cmd.options[:dryrun]
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_handle_options_n
|
29
|
+
@cmd.handle_options %w[-n]
|
30
|
+
assert @cmd.options[:dryrun]
|
31
|
+
end
|
32
|
+
|
18
33
|
def test_execute
|
19
34
|
@cmd.options[:args] = %w[a]
|
20
35
|
|
@@ -91,6 +91,34 @@ class TestGemCommandsContentsCommand < Gem::TestCase
|
|
91
91
|
assert_equal "", @ui.error
|
92
92
|
end
|
93
93
|
|
94
|
+
def test_execute_missing_single
|
95
|
+
@cmd.options[:args] = %w[foo]
|
96
|
+
|
97
|
+
assert_raises Gem::MockGemUi::TermError do
|
98
|
+
use_ui @ui do
|
99
|
+
@cmd.execute
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
assert_match "Unable to find gem 'foo'", @ui.output
|
104
|
+
assert_empty @ui.error
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_execute_missing_multiple
|
108
|
+
@cmd.options[:args] = %w[foo bar]
|
109
|
+
|
110
|
+
gem 'foo'
|
111
|
+
|
112
|
+
use_ui @ui do
|
113
|
+
@cmd.execute
|
114
|
+
end
|
115
|
+
|
116
|
+
assert_match "lib/foo.rb", @ui.output
|
117
|
+
assert_match "Unable to find gem 'bar'", @ui.output
|
118
|
+
|
119
|
+
assert_empty @ui.error
|
120
|
+
end
|
121
|
+
|
94
122
|
def test_execute_multiple
|
95
123
|
@cmd.options[:args] = %w[foo bar]
|
96
124
|
|
@@ -140,10 +168,10 @@ lib/foo.rb
|
|
140
168
|
@cmd.execute
|
141
169
|
end
|
142
170
|
|
143
|
-
expected =
|
144
|
-
|
145
|
-
|
146
|
-
|
171
|
+
expected = [
|
172
|
+
File.join(Gem::ConfigMap[:bindir], 'default_command'),
|
173
|
+
File.join(Gem::ConfigMap[:rubylibdir], 'default/gem.rb'),
|
174
|
+
File.join(Gem::ConfigMap[:archdir], 'default_gem.so')
|
147
175
|
].sort.join "\n"
|
148
176
|
|
149
177
|
assert_equal expected, @ui.output.chomp
|