Skip to content

Commit 9bf4a46

Browse files
committed
merge revision(s) 41076: [Backport ruby#8558]
* lib/rubygems: Update to RubyGems 2.0.3 * test/rubygems: Tests for the above. * NEWS: Added RubyGems 2.0.3 note. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@41543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 9970a90 commit 9bf4a46

File tree

11 files changed

+61
-26
lines changed

11 files changed

+61
-26
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Sat Jun 22 00:54:41 2013 Eric Hodel <[email protected]>
2+
3+
* lib/rubygems: Update to RubyGems 2.0.3
4+
5+
* test/rubygems: Tests for the above.
6+
7+
* NEWS: Added RubyGems 2.0.3 note.
8+
19
Wed Jun 19 04:20:31 2013 Charlie Somerville <[email protected]>
210

311
* vm_insnhelper.c (vm_call_method): ensure methods of type

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,10 @@ with all sufficient information, see the ChangeLog file.
461461
XML declaration is used for XML document encoding.
462462

463463
* RubyGems
464+
* Updated to 2.0.3. See
465+
http://rubygems.rubyforge.org/rubygems-update/History_txt.html#label-2.0.3+%2F+2012-03-1
466+
for release notes.
467+
464468
* Updated to 2.0.0
465469

466470
RubyGems 2.0.0 features the following improvements:

lib/rubygems.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
require 'rbconfig'
99

1010
module Gem
11-
VERSION = '2.0.2'
11+
VERSION = '2.0.3'
1212
end
1313

1414
# Must be first since it unloads the prelude from 1.9.2

lib/rubygems/commands/cert_command.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def description # :nodoc:
180180
end
181181

182182
def load_default_cert
183-
cert_file = File.join Gem.user_home, 'gem-public_cert.pem'
183+
cert_file = File.join Gem.default_cert_path
184184
cert = File.read cert_file
185185
options[:issuer_cert] = OpenSSL::X509::Certificate.new cert
186186
rescue Errno::ENOENT
@@ -196,7 +196,7 @@ def load_default_cert
196196
end
197197

198198
def load_default_key
199-
key_file = File.join Gem.user_home, 'gem-private_key.pem'
199+
key_file = File.join Gem.default_key_path
200200
key = File.read key_file
201201
options[:key] = OpenSSL::PKey::RSA.new key
202202
rescue Errno::ENOENT

lib/rubygems/defaults.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,18 @@ def self.ruby_engine
110110
'ruby'
111111
end
112112
end
113+
114+
##
115+
# The default signing key path
116+
117+
def self.default_key_path
118+
File.join Gem.user_home, ".gem", "gem-private_key.pem"
119+
end
120+
121+
##
122+
# The default signing certificate chain path
123+
124+
def self.default_cert_path
125+
File.join Gem.user_home, ".gem", "gem-public_cert.pem"
126+
end
113127
end

lib/rubygems/security/signer.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ def initialize key, cert_chain
3434
@key = key
3535

3636
unless @key then
37-
default_key = File.join Gem.user_home, 'gem-private_key.pem'
37+
default_key = File.join Gem.default_key_path
3838
@key = default_key if File.exist? default_key
3939
end
4040

4141
unless @cert_chain then
42-
default_cert = File.join Gem.user_home, 'gem-public_cert.pem'
42+
default_cert = File.join Gem.default_cert_path
4343
@cert_chain = [default_cert] if File.exist? default_cert
4444
end
4545

@@ -110,15 +110,15 @@ def sign data
110110
def re_sign_key # :nodoc:
111111
old_cert = @cert_chain.last
112112

113-
disk_cert_path = File.join Gem.user_home, 'gem-public_cert.pem'
113+
disk_cert_path = File.join Gem.default_cert_path
114114
disk_cert = File.read disk_cert_path rescue nil
115115
disk_key =
116-
File.read File.join(Gem.user_home, 'gem-private_key.pem') rescue nil
116+
File.read File.join(Gem.default_key_path) rescue nil
117117

118118
if disk_key == @key.to_pem and disk_cert == old_cert.to_pem then
119119
expiry = old_cert.not_after.strftime '%Y%m%d%H%M%S'
120120
old_cert_file = "gem-public_cert.pem.expired.#{expiry}"
121-
old_cert_path = File.join Gem.user_home, old_cert_file
121+
old_cert_path = File.join Gem.user_home, ".gem", old_cert_file
122122

123123
unless File.exist? old_cert_path then
124124
Gem::Security.write old_cert, old_cert_path

test/rubygems/test_gem_commands_cert_command.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,12 @@ def test_execute_sign
308308
end
309309

310310
def test_execute_sign_default
311-
private_key_path = File.join Gem.user_home, 'gem-private_key.pem'
311+
FileUtils.mkdir_p File.join Gem.user_home, '.gem'
312+
313+
private_key_path = File.join Gem.user_home, '.gem', 'gem-private_key.pem'
312314
Gem::Security.write PRIVATE_KEY, private_key_path
313315

314-
public_cert_path = File.join Gem.user_home, 'gem-public_cert.pem'
316+
public_cert_path = File.join Gem.user_home, '.gem', 'gem-public_cert.pem'
315317
Gem::Security.write PUBLIC_CERT, public_cert_path
316318

317319
path = File.join @tempdir, 'cert.pem'
@@ -338,7 +340,9 @@ def test_execute_sign_default
338340
end
339341

340342
def test_execute_sign_no_cert
341-
private_key_path = File.join Gem.user_home, 'gem-private_key.pem'
343+
FileUtils.mkdir_p File.join Gem.user_home, '.gem'
344+
345+
private_key_path = File.join Gem.user_home, '.gem', 'gem-private_key.pem'
342346
Gem::Security.write PRIVATE_KEY, private_key_path
343347

344348
path = File.join @tempdir, 'cert.pem'
@@ -364,7 +368,9 @@ def test_execute_sign_no_cert
364368
end
365369

366370
def test_execute_sign_no_key
367-
public_cert_path = File.join Gem.user_home, 'gem-public_cert.pem'
371+
FileUtils.mkdir_p File.join Gem.user_home, '.gem'
372+
373+
public_cert_path = File.join Gem.user_home, '.gem', 'gem-public_cert.pem'
368374
Gem::Security.write PUBLIC_CERT, public_cert_path
369375

370376
path = File.join @tempdir, 'cert.pem'

test/rubygems/test_gem_installer.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,6 @@ def test_install_extension_flat
10731073
10741074
CONFIG['CC'] = '$(TOUCH) $@ ||'
10751075
CONFIG['LDSHARED'] = '$(TOUCH) $@ ||'
1076-
$ruby = '#{Gem.ruby}'
10771076
10781077
create_makefile("#{@spec.name}")
10791078
RUBY

test/rubygems/test_gem_package.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,12 @@ def test_build
162162
end
163163

164164
def test_build_auto_signed
165-
private_key_path = File.join Gem.user_home, 'gem-private_key.pem'
165+
FileUtils.mkdir_p File.join(Gem.user_home, '.gem')
166+
167+
private_key_path = File.join Gem.user_home, '.gem', 'gem-private_key.pem'
166168
Gem::Security.write PRIVATE_KEY, private_key_path
167169

168-
public_cert_path = File.join Gem.user_home, 'gem-public_cert.pem'
170+
public_cert_path = File.join Gem.user_home, '.gem', 'gem-public_cert.pem'
169171
Gem::Security.write PUBLIC_CERT, public_cert_path
170172

171173
spec = Gem::Specification.new 'build', '1'
@@ -509,7 +511,7 @@ def test_verify_nonexistent
509511
package.verify
510512
end
511513

512-
assert_equal 'No such file or directory - nonexistent.gem', e.message
514+
assert_match ' - nonexistent.gem', e.message
513515
end
514516

515517
def test_verify_security_policy

test/rubygems/test_gem_security_signer.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ def test_initialize_cert_chain_path
5050
end
5151

5252
def test_initialize_default
53-
private_key_path = File.join Gem.user_home, 'gem-private_key.pem'
53+
FileUtils.mkdir_p File.join(Gem.user_home, '.gem')
54+
55+
private_key_path = File.join Gem.user_home, '.gem', 'gem-private_key.pem'
5456
Gem::Security.write PRIVATE_KEY, private_key_path
5557

56-
public_cert_path = File.join Gem.user_home, 'gem-public_cert.pem'
58+
public_cert_path = File.join Gem.user_home, '.gem', 'gem-public_cert.pem'
5759
Gem::Security.write PUBLIC_CERT, public_cert_path
5860

5961
signer = Gem::Security::Signer.new nil, nil
@@ -120,12 +122,12 @@ def test_sign_expired
120122
end
121123

122124
def test_sign_expired_auto_update
123-
FileUtils.mkdir_p Gem.user_home, :mode => 0700
125+
FileUtils.mkdir_p File.join(Gem.user_home, '.gem'), :mode => 0700
124126

125-
private_key_path = File.join(Gem.user_home, 'gem-private_key.pem')
127+
private_key_path = File.join(Gem.user_home, '.gem', 'gem-private_key.pem')
126128
Gem::Security.write PRIVATE_KEY, private_key_path
127129

128-
cert_path = File.join Gem.user_home, 'gem-public_cert.pem'
130+
cert_path = File.join Gem.user_home, '.gem', 'gem-public_cert.pem'
129131
Gem::Security.write EXPIRED_CERT, cert_path
130132

131133
signer = Gem::Security::Signer.new PRIVATE_KEY, [EXPIRED_CERT]
@@ -140,14 +142,14 @@ def test_sign_expired_auto_update
140142
expiry = EXPIRED_CERT.not_after.strftime "%Y%m%d%H%M%S"
141143

142144
expired_path =
143-
File.join Gem.user_home, "gem-public_cert.pem.expired.#{expiry}"
145+
File.join Gem.user_home, '.gem', "gem-public_cert.pem.expired.#{expiry}"
144146

145147
assert_path_exists expired_path
146148
assert_equal EXPIRED_CERT.to_pem, File.read(expired_path)
147149
end
148150

149151
def test_sign_expired_auto_update_exists
150-
FileUtils.mkdir_p Gem.user_home, :mode => 0700
152+
FileUtils.mkdir_p File.join(Gem.user_home, '.gem'), :mode => 0700
151153

152154
expiry = EXPIRED_CERT.not_after.strftime "%Y%m%d%H%M%S"
153155
expired_path =

0 commit comments

Comments
 (0)