rubygems-update 2.2.1 → 2.2.2

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.

Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/History.txt +29 -0
  5. data/Manifest.txt +1 -0
  6. data/lib/rubygems.rb +1 -1
  7. data/lib/rubygems/available_set.rb +3 -0
  8. data/lib/rubygems/commands/generate_index_command.rb +1 -1
  9. data/lib/rubygems/config_file.rb +3 -2
  10. data/lib/rubygems/dependency_installer.rb +1 -0
  11. data/lib/rubygems/ext/ext_conf_builder.rb +5 -1
  12. data/lib/rubygems/installer.rb +1 -1
  13. data/lib/rubygems/package/tar_header.rb +1 -1
  14. data/lib/rubygems/remote_fetcher.rb +24 -16
  15. data/lib/rubygems/request.rb +4 -4
  16. data/lib/rubygems/request_set.rb +8 -0
  17. data/lib/rubygems/resolver.rb +2 -0
  18. data/lib/rubygems/resolver/api_set.rb +6 -1
  19. data/lib/rubygems/resolver/best_set.rb +20 -1
  20. data/lib/rubygems/resolver/composed_set.rb +11 -0
  21. data/lib/rubygems/resolver/git_set.rb +3 -0
  22. data/lib/rubygems/resolver/index_set.rb +4 -0
  23. data/lib/rubygems/resolver/installer_set.rb +15 -1
  24. data/lib/rubygems/resolver/lock_set.rb +2 -0
  25. data/lib/rubygems/resolver/set.rb +17 -0
  26. data/lib/rubygems/resolver/vendor_set.rb +2 -0
  27. data/lib/rubygems/security.rb +3 -3
  28. data/lib/rubygems/source/git.rb +14 -0
  29. data/lib/rubygems/specification.rb +22 -22
  30. data/lib/rubygems/test_case.rb +29 -1
  31. data/lib/rubygems/version.rb +17 -11
  32. data/test/rubygems/test_gem.rb +28 -30
  33. data/test/rubygems/test_gem_ext_ext_conf_builder.rb +41 -27
  34. data/test/rubygems/test_gem_installer.rb +6 -2
  35. data/test/rubygems/test_gem_package_tar_header.rb +14 -0
  36. data/test/rubygems/test_gem_platform.rb +5 -1
  37. data/test/rubygems/test_gem_remote_fetcher.rb +3 -3
  38. data/test/rubygems/test_gem_request.rb +69 -0
  39. data/test/rubygems/test_gem_request_set.rb +21 -0
  40. data/test/rubygems/test_gem_resolver.rb +8 -0
  41. data/test/rubygems/test_gem_resolver_api_set.rb +41 -0
  42. data/test/rubygems/test_gem_resolver_best_set.rb +50 -0
  43. data/test/rubygems/test_gem_resolver_composed_set.rb +18 -0
  44. data/test/rubygems/test_gem_resolver_git_set.rb +15 -0
  45. data/test/rubygems/test_gem_resolver_index_set.rb +35 -0
  46. data/test/rubygems/test_gem_resolver_installer_set.rb +70 -0
  47. data/test/rubygems/test_gem_source_git.rb +43 -0
  48. data/test/rubygems/test_gem_specification.rb +9 -12
  49. data/test/rubygems/test_gem_version.rb +10 -0
  50. metadata +5 -3
  51. metadata.gz.sig +0 -0
@@ -41,7 +41,7 @@ version = \">= 0\"
41
41
  if ARGV.first
42
42
  str = ARGV.first
43
43
  str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
44
- if str =~ /\\A_(.*)_\\z/
44
+ if str =~ /\\A_(.*)_\\z/ and Gem::Version.correct?($1) then
45
45
  version = $1
46
46
  ARGV.shift
47
47
  end
@@ -102,7 +102,11 @@ load Gem.bin_path('a', 'executable', version)
102
102
  ensure
103
103
  Object.const_set :RUBY_FRAMEWORK_VERSION, orig_RUBY_FRAMEWORK_VERSION if
104
104
  orig_RUBY_FRAMEWORK_VERSION
105
- RbConfig::CONFIG['bindir'] = orig_bindir
105
+ if orig_bindir then
106
+ RbConfig::CONFIG['bindir'] = orig_bindir
107
+ else
108
+ RbConfig::CONFIG.delete 'bindir'
109
+ end
106
110
  end
107
111
 
108
112
  def test_check_executable_overwrite_format_executable
@@ -72,6 +72,20 @@ class TestGemPackageTarHeader < Gem::Package::TarTestCase
72
72
  end
73
73
  end
74
74
 
75
+ def test_initialize_typeflag
76
+ header = {
77
+ :mode => '',
78
+ :name => '',
79
+ :prefix => '',
80
+ :size => '',
81
+ :typeflag => '',
82
+ }
83
+
84
+ tar_header = Gem::Package::TarHeader.new header
85
+
86
+ assert_equal '0', tar_header.typeflag
87
+ end
88
+
75
89
  def test_empty_eh
76
90
  refute_empty @tar_header
77
91
 
@@ -116,7 +116,11 @@ class TestGemPlatform < Gem::TestCase
116
116
 
117
117
  assert_equal expected, platform.to_a, 'i386-mswin32 VC6'
118
118
  ensure
119
- RbConfig::CONFIG['RUBY_SO_NAME'] = orig_RUBY_SO_NAME
119
+ if orig_RUBY_SO_NAME then
120
+ RbConfig::CONFIG['RUBY_SO_NAME'] = orig_RUBY_SO_NAME
121
+ else
122
+ RbConfig::CONFIG.delete 'RUBY_SO_NAME'
123
+ end
120
124
  end
121
125
 
122
126
  def test_initialize_platform
@@ -208,15 +208,15 @@ gems:
208
208
  fetcher.instance_variable_set :@test_data, data
209
209
 
210
210
  unless blow then
211
- def fetcher.fetch_path arg
211
+ def fetcher.fetch_path arg, *rest
212
212
  @test_arg = arg
213
213
  @test_data
214
214
  end
215
215
  else
216
- def fetcher.fetch_path arg
216
+ def fetcher.fetch_path arg, *rest
217
217
  # OMG I'm such an ass
218
218
  class << self; remove_method :fetch_path; end
219
- def self.fetch_path arg
219
+ def self.fetch_path arg, *rest
220
220
  @test_arg = arg
221
221
  @test_data
222
222
  end
@@ -1,9 +1,16 @@
1
1
  require 'rubygems/test_case'
2
2
  require 'rubygems/request'
3
3
  require 'ostruct'
4
+ require 'base64'
4
5
 
5
6
  class TestGemRequest < Gem::TestCase
6
7
 
8
+ CA_CERT_FILE = cert_path 'ca'
9
+ CHILD_CERT = load_cert 'child'
10
+ PUBLIC_CERT = load_cert 'public'
11
+ PUBLIC_CERT_FILE = cert_path 'public'
12
+ SSL_CERT = load_cert 'ssl'
13
+
7
14
  def setup
8
15
  @proxies = %w[http_proxy HTTP_PROXY http_proxy_user HTTP_PROXY_USER http_proxy_pass HTTP_PROXY_PASS no_proxy NO_PROXY]
9
16
  @old_proxies = @proxies.map {|k| ENV[k] }
@@ -62,6 +69,44 @@ class TestGemRequest < Gem::TestCase
62
69
  assert_equal URI(@proxy_uri), proxy
63
70
  end
64
71
 
72
+ def test_configure_connection_for_https
73
+ connection = Net::HTTP.new 'localhost', 443
74
+
75
+ request = Gem::Request.new URI('https://example'), nil, nil, nil
76
+
77
+ def request.add_rubygems_trusted_certs store
78
+ store.add_cert TestGemRequest::PUBLIC_CERT
79
+ end
80
+
81
+ request.configure_connection_for_https connection
82
+
83
+ cert_store = connection.cert_store
84
+
85
+ assert cert_store.verify CHILD_CERT
86
+ end
87
+
88
+ def test_configure_connection_for_https_ssl_ca_cert
89
+ ssl_ca_cert, Gem.configuration.ssl_ca_cert =
90
+ Gem.configuration.ssl_ca_cert, CA_CERT_FILE
91
+
92
+ connection = Net::HTTP.new 'localhost', 443
93
+
94
+ request = Gem::Request.new URI('https://example'), nil, nil, nil
95
+
96
+ def request.add_rubygems_trusted_certs store
97
+ store.add_cert TestGemRequest::PUBLIC_CERT
98
+ end
99
+
100
+ request.configure_connection_for_https connection
101
+
102
+ cert_store = connection.cert_store
103
+
104
+ assert cert_store.verify CHILD_CERT
105
+ assert cert_store.verify SSL_CERT
106
+ ensure
107
+ Gem.configuration.ssl_ca_cert = ssl_ca_cert
108
+ end
109
+
65
110
  def test_get_proxy_from_env_fallback
66
111
  ENV['http_proxy'] = @proxy_uri
67
112
 
@@ -124,6 +169,30 @@ class TestGemRequest < Gem::TestCase
124
169
  assert_equal :junk, response.body
125
170
  end
126
171
 
172
+ def test_fetch_basic_auth
173
+ uri = URI.parse "https://user:pass@example.rubygems/specs.#{Gem.marshal_version}"
174
+ @request = Gem::Request.new(uri, Net::HTTP::Get, nil, nil)
175
+ conn = util_stub_connection_for :body => :junk, :code => 200
176
+
177
+ @request.fetch
178
+
179
+ auth_header = conn.payload['Authorization']
180
+
181
+ assert_equal "Basic #{Base64.encode64('user:pass')}".strip, auth_header
182
+ end
183
+
184
+ def test_fetch_basic_auth_encoded
185
+ uri = URI.parse "https://user:%7BDEScede%7Dpass@example.rubygems/specs.#{Gem.marshal_version}"
186
+ @request = Gem::Request.new(uri, Net::HTTP::Get, nil, nil)
187
+ conn = util_stub_connection_for :body => :junk, :code => 200
188
+
189
+ @request.fetch
190
+
191
+ auth_header = conn.payload['Authorization']
192
+
193
+ assert_equal "Basic #{Base64.encode64('user:{DEScede}pass')}".strip, auth_header
194
+ end
195
+
127
196
  def test_fetch_head
128
197
  uri = URI.parse "#{@gem_repo}/specs.#{Gem.marshal_version}"
129
198
  @request = Gem::Request.new(uri, Net::HTTP::Get, nil, nil)
@@ -59,6 +59,8 @@ class TestGemRequestSet < Gem::TestCase
59
59
  assert_includes installed, 'a-2'
60
60
  assert_path_exists File.join @gemhome, 'gems', 'a-2'
61
61
  assert_path_exists 'gem.deps.rb.lock'
62
+
63
+ assert rs.remote
62
64
  end
63
65
 
64
66
  def test_install_from_gemdeps_install_dir
@@ -89,6 +91,25 @@ class TestGemRequestSet < Gem::TestCase
89
91
  refute_path_exists File.join Gem.dir, 'gems', 'a-2'
90
92
  end
91
93
 
94
+ def test_install_from_gemdeps_local
95
+ spec_fetcher do |fetcher|
96
+ fetcher.gem 'a', 2
97
+ end
98
+
99
+ rs = Gem::RequestSet.new
100
+
101
+ open 'gem.deps.rb', 'w' do |io|
102
+ io.puts 'gem "a"'
103
+ io.flush
104
+
105
+ assert_raises Gem::UnsatisfiableDependencyError do
106
+ rs.install_from_gemdeps :gemdeps => io.path, :domain => :local
107
+ end
108
+ end
109
+
110
+ refute rs.remote
111
+ end
112
+
92
113
  def test_install_from_gemdeps_lockfile
93
114
  spec_fetcher do |fetcher|
94
115
  fetcher.gem 'a', 1
@@ -33,6 +33,14 @@ class TestGemResolver < Gem::TestCase
33
33
  assert_same Gem::Resolver, Gem::DependencyResolver
34
34
  end
35
35
 
36
+ def test_self_compose_sets_best_set
37
+ best_set = @DR::BestSet.new
38
+
39
+ composed = @DR.compose_sets best_set
40
+
41
+ assert_equal best_set, composed
42
+ end
43
+
36
44
  def test_self_compose_sets_multiple
37
45
  index_set = @DR::IndexSet.new
38
46
  vendor_set = @DR::VendorSet.new
@@ -17,6 +17,14 @@ class TestGemResolverAPISet < Gem::TestCase
17
17
  assert_equal Gem::Source.new(URI('https://rubygems.org')), set.source
18
18
  end
19
19
 
20
+ def test_initialize_deeper_uri
21
+ set = @DR::APISet.new 'https://rubygemsserver.com/mygems/api/v1/dependencies'
22
+
23
+ assert_equal URI('https://rubygemsserver.com/mygems/api/v1/dependencies'), set.dep_uri
24
+ assert_equal URI('https://rubygemsserver.com/mygems/'), set.uri
25
+ assert_equal Gem::Source.new(URI('https://rubygemsserver.com/mygems/')), set.source
26
+ end
27
+
20
28
  def test_initialize_uri
21
29
  set = @DR::APISet.new @dep_uri
22
30
 
@@ -74,6 +82,15 @@ class TestGemResolverAPISet < Gem::TestCase
74
82
  assert_equal expected, set.find_all(a_dep)
75
83
  end
76
84
 
85
+ def test_find_all_local
86
+ set = @DR::APISet.new @dep_uri
87
+ set.remote = false
88
+
89
+ a_dep = @DR::DependencyRequest.new dep('a'), nil
90
+
91
+ assert_empty set.find_all(a_dep)
92
+ end
93
+
77
94
  def test_find_all_missing
78
95
  spec_fetcher
79
96
 
@@ -163,5 +180,29 @@ class TestGemResolverAPISet < Gem::TestCase
163
180
  set.prefetch [a_dep, b_dep]
164
181
  end
165
182
 
183
+ def test_prefetch_local
184
+ spec_fetcher
185
+
186
+ data = [
187
+ { :name => 'a',
188
+ :number => '1',
189
+ :platform => 'ruby',
190
+ :dependencies => [], },
191
+ ]
192
+
193
+ @fetcher.data["#{@dep_uri}?gems=a,b"] = Marshal.dump data
194
+ @fetcher.data["#{@dep_uri}?gems=b"] = Marshal.dump []
195
+
196
+ set = @DR::APISet.new @dep_uri
197
+ set.remote = false
198
+
199
+ a_dep = @DR::DependencyRequest.new dep('a'), nil
200
+ b_dep = @DR::DependencyRequest.new dep('b'), nil
201
+
202
+ set.prefetch [a_dep, b_dep]
203
+
204
+ assert_empty set.instance_variable_get :@data
205
+ end
206
+
166
207
  end
167
208
 
@@ -8,6 +8,12 @@ class TestGemResolverBestSet < Gem::TestCase
8
8
  @DR = Gem::Resolver
9
9
  end
10
10
 
11
+ def test_initialize
12
+ set = @DR::BestSet.new
13
+
14
+ assert_empty set.sets
15
+ end
16
+
11
17
  def test_find_all_index
12
18
  spec_fetcher do |fetcher|
13
19
  fetcher.spec 'a', 1
@@ -26,5 +32,49 @@ class TestGemResolverBestSet < Gem::TestCase
26
32
  assert_equal %w[a-1], found.map { |s| s.full_name }
27
33
  end
28
34
 
35
+ def test_find_all_local
36
+ spec_fetcher do |fetcher|
37
+ fetcher.spec 'a', 1
38
+ fetcher.spec 'a', 2
39
+ fetcher.spec 'b', 1
40
+ end
41
+
42
+ set = @DR::BestSet.new
43
+ set.remote = false
44
+
45
+ dependency = dep 'a', '~> 1'
46
+
47
+ req = @DR::DependencyRequest.new dependency, nil
48
+
49
+ found = set.find_all req
50
+
51
+ assert_empty found
52
+ end
53
+
54
+ def test_prefetch
55
+ spec_fetcher do |fetcher|
56
+ fetcher.spec 'a', 1
57
+ end
58
+
59
+ set = @DR::BestSet.new
60
+
61
+ set.prefetch []
62
+
63
+ refute_empty set.sets
64
+ end
65
+
66
+ def test_prefetch_local
67
+ spec_fetcher do |fetcher|
68
+ fetcher.spec 'a', 1
69
+ end
70
+
71
+ set = @DR::BestSet.new
72
+ set.remote = false
73
+
74
+ set.prefetch []
75
+
76
+ assert_empty set.sets
77
+ end
78
+
29
79
  end
30
80
 
@@ -0,0 +1,18 @@
1
+ require 'rubygems/test_case'
2
+
3
+ class TestGemResolverComposedSet < Gem::TestCase
4
+
5
+ def test_remote_equals
6
+ best_set = Gem::Resolver::BestSet.new
7
+ current_set = Gem::Resolver::CurrentSet.new
8
+
9
+ set = Gem::Resolver::ComposedSet.new best_set, current_set
10
+
11
+ set.remote = false
12
+
13
+ refute best_set.remote?
14
+ refute current_set.remote?
15
+ end
16
+
17
+ end
18
+
@@ -70,6 +70,21 @@ class TestGemResolverGitSet < Gem::TestCase
70
70
  assert_equal [@set.specs['a']], found
71
71
  end
72
72
 
73
+ def test_find_all_local
74
+ name, _, repository, = git_gem
75
+
76
+ @set.add_git_gem name, repository, 'master', false
77
+ @set.remote = false
78
+
79
+ dependency = dep 'a', '~> 1.0'
80
+ req = Gem::Resolver::DependencyRequest.new dependency, nil
81
+ @reqs.add req
82
+
83
+ @set.prefetch @reqs
84
+
85
+ assert_empty @set.find_all dependency
86
+ end
87
+
73
88
  def test_root_dir
74
89
  assert_equal Gem.dir, @set.root_dir
75
90
 
@@ -24,5 +24,40 @@ class TestGemResolverIndexSet < Gem::TestCase
24
24
  refute_same Gem::SpecFetcher.fetcher, fetcher
25
25
  end
26
26
 
27
+ def test_find_all
28
+ spec_fetcher do |fetcher|
29
+ fetcher.spec 'a', 1
30
+ fetcher.spec 'a', 2
31
+ fetcher.spec 'b', 1
32
+ end
33
+
34
+ set = @DR::BestSet.new
35
+
36
+ dependency = dep 'a', '~> 1'
37
+
38
+ req = @DR::DependencyRequest.new dependency, nil
39
+
40
+ found = set.find_all req
41
+
42
+ assert_equal %w[a-1], found.map { |s| s.full_name }
43
+ end
44
+
45
+ def test_find_all_local
46
+ spec_fetcher do |fetcher|
47
+ fetcher.spec 'a', 1
48
+ fetcher.spec 'a', 2
49
+ fetcher.spec 'b', 1
50
+ end
51
+
52
+ set = @DR::BestSet.new
53
+ set.remote = false
54
+
55
+ dependency = dep 'a', '~> 1'
56
+
57
+ req = @DR::DependencyRequest.new dependency, nil
58
+
59
+ assert_empty set.find_all req
60
+ end
61
+
27
62
  end
28
63
 
@@ -2,6 +2,34 @@ require 'rubygems/test_case'
2
2
 
3
3
  class TestGemResolverInstallerSet < Gem::TestCase
4
4
 
5
+ def test_consider_local_eh
6
+ set = Gem::Resolver::InstallerSet.new :remote
7
+
8
+ refute set.consider_local?
9
+
10
+ set = Gem::Resolver::InstallerSet.new :both
11
+
12
+ assert set.consider_local?
13
+
14
+ set = Gem::Resolver::InstallerSet.new :local
15
+
16
+ assert set.consider_local?
17
+ end
18
+
19
+ def test_consider_remote_eh
20
+ set = Gem::Resolver::InstallerSet.new :remote
21
+
22
+ assert set.consider_remote?
23
+
24
+ set = Gem::Resolver::InstallerSet.new :both
25
+
26
+ assert set.consider_remote?
27
+
28
+ set = Gem::Resolver::InstallerSet.new :local
29
+
30
+ refute set.consider_remote?
31
+ end
32
+
5
33
  def test_load_spec
6
34
  specs = spec_fetcher do |fetcher|
7
35
  fetcher.spec 'a', 2
@@ -18,5 +46,47 @@ class TestGemResolverInstallerSet < Gem::TestCase
18
46
  assert_equal specs["a-2-#{Gem::Platform.local}"].full_name, spec.full_name
19
47
  end
20
48
 
49
+ def test_remote_equals_both
50
+ set = Gem::Resolver::InstallerSet.new :both
51
+ set.remote = true
52
+
53
+ assert set.consider_local?
54
+ assert set.consider_remote?
55
+
56
+ set = Gem::Resolver::InstallerSet.new :both
57
+ set.remote = false
58
+
59
+ assert set.consider_local?
60
+ refute set.consider_remote?
61
+ end
62
+
63
+ def test_remote_equals_local
64
+ set = Gem::Resolver::InstallerSet.new :local
65
+ set.remote = true
66
+
67
+ assert set.consider_local?
68
+ assert set.consider_remote?
69
+
70
+ set = Gem::Resolver::InstallerSet.new :local
71
+ set.remote = false
72
+
73
+ assert set.consider_local?
74
+ refute set.consider_remote?
75
+ end
76
+
77
+ def test_remote_equals_remote
78
+ set = Gem::Resolver::InstallerSet.new :remote
79
+ set.remote = true
80
+
81
+ refute set.consider_local?
82
+ assert set.consider_remote?
83
+
84
+ set = Gem::Resolver::InstallerSet.new :remote
85
+ set.remote = false
86
+
87
+ refute set.consider_local?
88
+ refute set.consider_remote?
89
+ end
90
+
21
91
  end
22
92