dependabot-bundler 0.230.0 → 0.232.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/helpers/v1/lib/functions/conflicting_dependency_resolver.rb +1 -0
- data/helpers/v1/lib/functions/dependency_source.rb +10 -9
- data/helpers/v1/lib/functions/file_parser.rb +8 -7
- data/helpers/v1/lib/functions/force_updater.rb +22 -21
- data/helpers/v1/lib/functions/lockfile_updater.rb +12 -11
- data/helpers/v1/lib/functions/version_resolver.rb +7 -6
- data/helpers/v1/lib/functions.rb +16 -15
- data/helpers/v1/monkey_patches/definition_bundler_version_patch.rb +3 -2
- data/helpers/v1/monkey_patches/definition_ruby_version_patch.rb +1 -0
- data/helpers/v1/monkey_patches/fileutils_keyword_splat_patch.rb +4 -3
- data/helpers/v1/monkey_patches/git_source_patch.rb +3 -2
- data/helpers/v1/monkey_patches/resolver_spec_group_sane_eql.rb +1 -0
- data/helpers/v1/run.rb +1 -0
- data/helpers/v1/spec/functions/conflicting_dependency_resolver_spec.rb +1 -0
- data/helpers/v1/spec/functions/dependency_source_spec.rb +66 -65
- data/helpers/v1/spec/functions/file_parser_spec.rb +1 -0
- data/helpers/v1/spec/functions/force_updater_spec.rb +1 -0
- data/helpers/v1/spec/functions/version_resolver_spec.rb +15 -14
- data/helpers/v1/spec/native_spec_helper.rb +1 -0
- data/helpers/v1/spec/shared_contexts.rb +7 -6
- data/helpers/v2/lib/functions/conflicting_dependency_resolver.rb +1 -0
- data/helpers/v2/lib/functions/dependency_source.rb +10 -9
- data/helpers/v2/lib/functions/file_parser.rb +8 -7
- data/helpers/v2/lib/functions/force_updater.rb +10 -9
- data/helpers/v2/lib/functions/lockfile_updater.rb +5 -4
- data/helpers/v2/lib/functions/version_resolver.rb +7 -6
- data/helpers/v2/lib/functions.rb +16 -15
- data/helpers/v2/monkey_patches/definition_bundler_version_patch.rb +1 -0
- data/helpers/v2/monkey_patches/definition_ruby_version_patch.rb +1 -0
- data/helpers/v2/monkey_patches/git_source_patch.rb +3 -2
- data/helpers/v2/run.rb +1 -0
- data/helpers/v2/spec/functions/conflicting_dependency_resolver_spec.rb +1 -0
- data/helpers/v2/spec/functions/dependency_source_spec.rb +67 -66
- data/helpers/v2/spec/functions/file_parser_spec.rb +1 -0
- data/helpers/v2/spec/functions/force_updater_spec.rb +1 -0
- data/helpers/v2/spec/functions/version_resolver_spec.rb +19 -18
- data/helpers/v2/spec/functions_spec.rb +1 -0
- data/helpers/v2/spec/native_spec_helper.rb +1 -0
- data/helpers/v2/spec/shared_contexts.rb +7 -6
- data/lib/dependabot/bundler/file_fetcher/child_gemfile_finder.rb +1 -0
- data/lib/dependabot/bundler/file_fetcher/gemspec_finder.rb +3 -2
- data/lib/dependabot/bundler/file_fetcher/path_gemspec_finder.rb +3 -2
- data/lib/dependabot/bundler/file_fetcher/require_relative_finder.rb +1 -0
- data/lib/dependabot/bundler/file_fetcher.rb +25 -24
- data/lib/dependabot/bundler/file_parser/file_preparer.rb +15 -14
- data/lib/dependabot/bundler/file_parser/gemfile_declaration_finder.rb +1 -0
- data/lib/dependabot/bundler/file_parser/gemspec_declaration_finder.rb +1 -0
- data/lib/dependabot/bundler/file_parser.rb +23 -22
- data/lib/dependabot/bundler/file_updater/gemfile_updater.rb +19 -18
- data/lib/dependabot/bundler/file_updater/gemspec_dependency_name_finder.rb +1 -0
- data/lib/dependabot/bundler/file_updater/gemspec_sanitizer.rb +8 -7
- data/lib/dependabot/bundler/file_updater/gemspec_updater.rb +7 -6
- data/lib/dependabot/bundler/file_updater/git_pin_replacer.rb +4 -3
- data/lib/dependabot/bundler/file_updater/git_source_remover.rb +1 -0
- data/lib/dependabot/bundler/file_updater/lockfile_updater.rb +22 -21
- data/lib/dependabot/bundler/file_updater/requirement_replacer.rb +5 -4
- data/lib/dependabot/bundler/file_updater/ruby_requirement_setter.rb +4 -3
- data/lib/dependabot/bundler/file_updater.rb +16 -15
- data/lib/dependabot/bundler/helpers.rb +1 -0
- data/lib/dependabot/bundler/metadata_finder.rb +24 -23
- data/lib/dependabot/bundler/native_helpers.rb +4 -3
- data/lib/dependabot/bundler/requirement.rb +3 -2
- data/lib/dependabot/bundler/update_checker/conflicting_dependency_resolver.rb +1 -0
- data/lib/dependabot/bundler/update_checker/file_preparer.rb +33 -32
- data/lib/dependabot/bundler/update_checker/force_updater.rb +4 -3
- data/lib/dependabot/bundler/update_checker/latest_version_finder/dependency_source.rb +5 -4
- data/lib/dependabot/bundler/update_checker/latest_version_finder.rb +5 -4
- data/lib/dependabot/bundler/update_checker/requirements_updater.rb +6 -5
- data/lib/dependabot/bundler/update_checker/shared_bundler_helpers.rb +15 -14
- data/lib/dependabot/bundler/update_checker/version_resolver.rb +4 -3
- data/lib/dependabot/bundler/update_checker.rb +27 -26
- data/lib/dependabot/bundler/version.rb +3 -2
- data/lib/dependabot/bundler.rb +3 -2
- metadata +19 -5
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: false
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require "native_spec_helper"
|
@@ -51,16 +52,16 @@ RSpec.describe Functions::VersionResolver do
|
|
51
52
|
gemfury_url = "https://repo.fury.io/greysteil/"
|
52
53
|
gemfury_deps_url = gemfury_url + "api/v1/dependencies"
|
53
54
|
|
54
|
-
stub_request(:get, gemfury_url + "versions")
|
55
|
-
to_return(status: 200, body: fixture("ruby", "gemfury-index"))
|
55
|
+
stub_request(:get, gemfury_url + "versions")
|
56
|
+
.to_return(status: 200, body: fixture("ruby", "gemfury-index"))
|
56
57
|
stub_request(:get, gemfury_url + "info/business").to_return(status: 404)
|
57
58
|
stub_request(:get, gemfury_deps_url).to_return(status: 200)
|
58
|
-
stub_request(:get, gemfury_deps_url + "?gems=business,statesman")
|
59
|
-
to_return(status: 200, body: fixture("ruby", "gemfury_response"))
|
60
|
-
stub_request(:get, gemfury_deps_url + "?gems=business")
|
61
|
-
to_return(status: 200, body: fixture("ruby", "gemfury_response"))
|
62
|
-
stub_request(:get, gemfury_deps_url + "?gems=statesman")
|
63
|
-
to_return(status: 200, body: fixture("ruby", "gemfury_response"))
|
59
|
+
stub_request(:get, gemfury_deps_url + "?gems=business,statesman")
|
60
|
+
.to_return(status: 200, body: fixture("ruby", "gemfury_response"))
|
61
|
+
stub_request(:get, gemfury_deps_url + "?gems=business")
|
62
|
+
.to_return(status: 200, body: fixture("ruby", "gemfury_response"))
|
63
|
+
stub_request(:get, gemfury_deps_url + "?gems=statesman")
|
64
|
+
.to_return(status: 200, body: fixture("ruby", "gemfury_response"))
|
64
65
|
end
|
65
66
|
|
66
67
|
its([:version]) { is_expected.to eq(Gem::Version.new("1.9.0")) }
|
@@ -76,13 +77,13 @@ RSpec.describe Functions::VersionResolver do
|
|
76
77
|
|
77
78
|
context "when Bundler's compact index is down" do
|
78
79
|
before do
|
79
|
-
stub_request(:get, "https://index.rubygems.org/versions")
|
80
|
-
to_return(status: 500, body: "We'll be back soon")
|
81
|
-
stub_request(:get, "https://index.rubygems.org/info/public_suffix")
|
82
|
-
to_return(status: 500, body: "We'll be back soon")
|
80
|
+
stub_request(:get, "https://index.rubygems.org/versions")
|
81
|
+
.to_return(status: 500, body: "We'll be back soon")
|
82
|
+
stub_request(:get, "https://index.rubygems.org/info/public_suffix")
|
83
|
+
.to_return(status: 500, body: "We'll be back soon")
|
83
84
|
stub_request(:get, old_index_url).to_return(status: 200)
|
84
|
-
stub_request(:get, old_index_url + "?gems=business,statesman")
|
85
|
-
to_return(
|
85
|
+
stub_request(:get, old_index_url + "?gems=business,statesman")
|
86
|
+
.to_return(
|
86
87
|
status: 200,
|
87
88
|
body: fixture("rubygems_responses",
|
88
89
|
"dependencies-default-gemfile")
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: false
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require "bundler/compact_index_client"
|
@@ -28,8 +29,8 @@ end
|
|
28
29
|
RSpec.shared_context "without caching rubygems" do
|
29
30
|
before do
|
30
31
|
# Stub Bundler to stop it using a cached versions of Rubygems
|
31
|
-
allow_any_instance_of(Bundler::CompactIndexClient::Updater)
|
32
|
-
to receive(:etag_for).and_return("")
|
32
|
+
allow_any_instance_of(Bundler::CompactIndexClient::Updater)
|
33
|
+
.to receive(:etag_for).and_return("")
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
@@ -38,8 +39,8 @@ RSpec.shared_context "stub rubygems compact index" do
|
|
38
39
|
|
39
40
|
before do
|
40
41
|
# Stub the Rubygems index
|
41
|
-
stub_request(:get, "https://index.rubygems.org/versions")
|
42
|
-
to_return(
|
42
|
+
stub_request(:get, "https://index.rubygems.org/versions")
|
43
|
+
.to_return(
|
43
44
|
status: 200,
|
44
45
|
body: fixture("rubygems_responses", "index")
|
45
46
|
)
|
@@ -49,8 +50,8 @@ RSpec.shared_context "stub rubygems compact index" do
|
|
49
50
|
Dir[File.join("../../spec", "fixtures", "rubygems_responses", "info-*")]
|
50
51
|
fixtures.each do |path|
|
51
52
|
dep_name = path.split("/").last.gsub("info-", "")
|
52
|
-
stub_request(:get, "https://index.rubygems.org/info/#{dep_name}")
|
53
|
-
to_return(
|
53
|
+
stub_request(:get, "https://index.rubygems.org/info/#{dep_name}")
|
54
|
+
.to_return(
|
54
55
|
status: 200,
|
55
56
|
body: fixture("rubygems_responses", "info-#{dep_name}")
|
56
57
|
)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: true
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Functions
|
@@ -37,13 +38,13 @@ module Functions
|
|
37
38
|
def private_registry_versions
|
38
39
|
bundler_source = specified_source || default_source
|
39
40
|
|
40
|
-
bundler_source
|
41
|
-
fetchers.flat_map do |fetcher|
|
42
|
-
fetcher
|
43
|
-
specs([dependency_name], bundler_source)
|
44
|
-
search_all(dependency_name)
|
45
|
-
end
|
46
|
-
map(&:version)
|
41
|
+
bundler_source
|
42
|
+
.fetchers.flat_map do |fetcher|
|
43
|
+
fetcher
|
44
|
+
.specs([dependency_name], bundler_source)
|
45
|
+
.search_all(dependency_name)
|
46
|
+
end
|
47
|
+
.map(&:version)
|
47
48
|
end
|
48
49
|
|
49
50
|
private
|
@@ -67,8 +68,8 @@ module Functions
|
|
67
68
|
def specified_source
|
68
69
|
return @specified_source if defined? @specified_source
|
69
70
|
|
70
|
-
@specified_source = definition.dependencies
|
71
|
-
|
71
|
+
@specified_source = definition.dependencies
|
72
|
+
.find { |dep| dep.name == dependency_name }&.source
|
72
73
|
end
|
73
74
|
|
74
75
|
def default_source
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: true
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require "uri"
|
@@ -11,16 +12,16 @@ module Functions
|
|
11
12
|
attr_reader :lockfile_name
|
12
13
|
|
13
14
|
def parsed_gemfile(gemfile_name:)
|
14
|
-
Bundler::Definition.build(gemfile_name, nil, {})
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
Bundler::Definition.build(gemfile_name, nil, {})
|
16
|
+
.dependencies.select(&:current_platform?)
|
17
|
+
.reject { |dep| local_sources.include?(dep.source.class) }
|
18
|
+
.map { |dep| serialize_bundler_dependency(dep) }
|
18
19
|
end
|
19
20
|
|
20
21
|
def parsed_gemspec(gemspec_name:)
|
21
|
-
Bundler.load_gemspec_uncached(gemspec_name)
|
22
|
-
|
23
|
-
|
22
|
+
Bundler.load_gemspec_uncached(gemspec_name)
|
23
|
+
.dependencies
|
24
|
+
.map { |dep| serialize_bundler_dependency(dep) }
|
24
25
|
end
|
25
26
|
|
26
27
|
private
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: true
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Functions
|
@@ -86,8 +87,8 @@ module Functions
|
|
86
87
|
unlock_gem(definition: definition, gem_name: gem_name)
|
87
88
|
end
|
88
89
|
|
89
|
-
dep = definition.dependencies
|
90
|
-
|
90
|
+
dep = definition.dependencies
|
91
|
+
.find { |d| d.name == dependency_name }
|
91
92
|
|
92
93
|
# If the dependency is not found in the Gemfile it means this is a
|
93
94
|
# transitive dependency that we can't force update.
|
@@ -117,19 +118,19 @@ module Functions
|
|
117
118
|
# subdependencies
|
118
119
|
return [] unless lockfile
|
119
120
|
|
120
|
-
all_deps = Bundler::LockfileParser.new(lockfile)
|
121
|
-
|
122
|
-
top_level = Bundler::Definition
|
123
|
-
build(gemfile_name, lockfile_name, {})
|
124
|
-
dependencies.map(&:name)
|
121
|
+
all_deps = Bundler::LockfileParser.new(lockfile)
|
122
|
+
.specs.map(&:name)
|
123
|
+
top_level = Bundler::Definition
|
124
|
+
.build(gemfile_name, lockfile_name, {})
|
125
|
+
.dependencies.map(&:name)
|
125
126
|
|
126
127
|
all_deps - top_level
|
127
128
|
end
|
128
129
|
|
129
130
|
def unlock_gem(definition:, gem_name:)
|
130
131
|
dep = definition.dependencies.find { |d| d.name == gem_name }
|
131
|
-
version = definition.locked_gems.specs
|
132
|
-
|
132
|
+
version = definition.locked_gems.specs
|
133
|
+
.find { |d| d.name == gem_name }.version
|
133
134
|
|
134
135
|
dep&.instance_variable_set(
|
135
136
|
:@requirement,
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: true
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require "fileutils"
|
@@ -136,8 +137,8 @@ module Functions
|
|
136
137
|
def unlock_yanked_gem(dependencies_to_unlock, error)
|
137
138
|
raise unless error.message.match?(GEM_NOT_FOUND_ERROR_REGEX)
|
138
139
|
|
139
|
-
gem_name = error.message.match(GEM_NOT_FOUND_ERROR_REGEX)
|
140
|
-
|
140
|
+
gem_name = error.message.match(GEM_NOT_FOUND_ERROR_REGEX)
|
141
|
+
.named_captures["name"]
|
141
142
|
raise if dependencies_to_unlock.include?(gem_name)
|
142
143
|
|
143
144
|
dependencies_to_unlock << gem_name
|
@@ -145,8 +146,8 @@ module Functions
|
|
145
146
|
|
146
147
|
def unlock_blocking_subdeps(dependencies_to_unlock, error)
|
147
148
|
all_deps = lockfile_specs.map { |x| x.name.to_s }
|
148
|
-
top_level = build_definition([]).dependencies
|
149
|
-
|
149
|
+
top_level = build_definition([]).dependencies
|
150
|
+
.map { |x| x.name.to_s }
|
150
151
|
allowed_new_unlocks = all_deps - top_level - dependencies_to_unlock
|
151
152
|
|
152
153
|
raise if allowed_new_unlocks.none?
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: true
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Functions
|
@@ -81,10 +82,10 @@ module Functions
|
|
81
82
|
# subdependencies
|
82
83
|
return [] unless lockfile
|
83
84
|
|
84
|
-
all_deps = ::Bundler::LockfileParser.new(lockfile)
|
85
|
-
|
86
|
-
top_level = build_definition([]).dependencies
|
87
|
-
|
85
|
+
all_deps = ::Bundler::LockfileParser.new(lockfile)
|
86
|
+
.specs.map { |x| x.name.to_s }.uniq
|
87
|
+
top_level = build_definition([]).dependencies
|
88
|
+
.map { |x| x.name.to_s }
|
88
89
|
|
89
90
|
all_deps - top_level
|
90
91
|
end
|
@@ -104,8 +105,8 @@ module Functions
|
|
104
105
|
def unlock_yanked_gem(dependencies_to_unlock, error)
|
105
106
|
raise unless error.message.match?(GEM_NOT_FOUND_ERROR_REGEX)
|
106
107
|
|
107
|
-
gem_name = error.message.match(GEM_NOT_FOUND_ERROR_REGEX)
|
108
|
-
|
108
|
+
gem_name = error.message.match(GEM_NOT_FOUND_ERROR_REGEX)
|
109
|
+
.named_captures["name"]
|
109
110
|
raise if dependencies_to_unlock.include?(gem_name)
|
110
111
|
|
111
112
|
dependencies_to_unlock << gem_name
|
data/helpers/v2/lib/functions.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: true
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require "functions/conflicting_dependency_resolver"
|
@@ -12,14 +13,14 @@ module Functions
|
|
12
13
|
|
13
14
|
def self.parsed_gemfile(**args)
|
14
15
|
set_bundler_flags_and_credentials(dir: args.fetch(:dir), credentials: [])
|
15
|
-
FileParser.new(lockfile_name: args.fetch(:lockfile_name))
|
16
|
-
|
16
|
+
FileParser.new(lockfile_name: args.fetch(:lockfile_name))
|
17
|
+
.parsed_gemfile(gemfile_name: args.fetch(:gemfile_name))
|
17
18
|
end
|
18
19
|
|
19
20
|
def self.parsed_gemspec(**args)
|
20
21
|
set_bundler_flags_and_credentials(dir: args.fetch(:dir), credentials: [])
|
21
|
-
FileParser.new(lockfile_name: args.fetch(:lockfile_name))
|
22
|
-
|
22
|
+
FileParser.new(lockfile_name: args.fetch(:lockfile_name))
|
23
|
+
.parsed_gemspec(gemspec_name: args.fetch(:gemspec_name))
|
23
24
|
end
|
24
25
|
|
25
26
|
def self.vendor_cache_dir(**args)
|
@@ -90,18 +91,18 @@ module Functions
|
|
90
91
|
# Set flags and credentials
|
91
92
|
set_bundler_flags_and_credentials(dir: args.fetch(:dir), credentials: args.fetch(:credentials))
|
92
93
|
|
93
|
-
Bundler::Definition.build(args.fetch(:gemfile_name), nil, {})
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
host
|
94
|
+
Bundler::Definition.build(args.fetch(:gemfile_name), nil, {})
|
95
|
+
.send(:sources)
|
96
|
+
.rubygems_remotes
|
97
|
+
.find { |uri| uri.host.include?("jfrog") }
|
98
|
+
&.host
|
98
99
|
end
|
99
100
|
|
100
101
|
def self.git_specs(**args)
|
101
102
|
set_bundler_flags_and_credentials(dir: args.fetch(:dir), credentials: args.fetch(:credentials))
|
102
103
|
|
103
|
-
git_specs = Bundler::Definition.build(args.fetch(:gemfile_name), nil, {}).dependencies
|
104
|
-
|
104
|
+
git_specs = Bundler::Definition.build(args.fetch(:gemfile_name), nil, {}).dependencies
|
105
|
+
.select do |spec|
|
105
106
|
spec.source.is_a?(Bundler::Source::Git)
|
106
107
|
end
|
107
108
|
git_specs.map do |spec|
|
@@ -161,12 +162,12 @@ module Functions
|
|
161
162
|
end
|
162
163
|
|
163
164
|
def self.private_registry_credentials(credentials)
|
164
|
-
credentials
|
165
|
-
select { |cred| cred["type"] == "rubygems_server" }
|
165
|
+
credentials
|
166
|
+
.select { |cred| cred["type"] == "rubygems_server" }
|
166
167
|
end
|
167
168
|
|
168
169
|
def self.git_source_credentials(credentials)
|
169
|
-
credentials
|
170
|
-
select { |cred| cred["type"] == "git_source" }
|
170
|
+
credentials
|
171
|
+
.select { |cred| cred["type"] == "git_source" }
|
171
172
|
end
|
172
173
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: true
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require "bundler/source"
|
@@ -40,8 +41,8 @@ module Bundler
|
|
40
41
|
|
41
42
|
def serialize_gemspecs_in(destination)
|
42
43
|
original_load_paths = $LOAD_PATH.dup
|
43
|
-
reduced_load_paths = original_load_paths
|
44
|
-
reject { |p| p.include?("/gems/") }
|
44
|
+
reduced_load_paths = original_load_paths
|
45
|
+
.reject { |p| p.include?("/gems/") }
|
45
46
|
|
46
47
|
$LOAD_PATH.shift until $LOAD_PATH.empty?
|
47
48
|
reduced_load_paths.each { |p| $LOAD_PATH << p }
|
data/helpers/v2/run.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: false
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require "native_spec_helper"
|
@@ -22,15 +23,15 @@ RSpec.describe Functions::DependencySource do
|
|
22
23
|
end
|
23
24
|
|
24
25
|
before do
|
25
|
-
stub_request(:get, registry_url + "versions")
|
26
|
-
with(basic_auth: ["SECRET_CODES", ""])
|
27
|
-
to_return(status: 404)
|
28
|
-
stub_request(:get, registry_url + "api/v1/dependencies")
|
29
|
-
with(basic_auth: ["SECRET_CODES", ""])
|
30
|
-
to_return(status: 200)
|
31
|
-
stub_request(:get, gemfury_business_url)
|
32
|
-
with(basic_auth: ["SECRET_CODES", ""])
|
33
|
-
to_return(status: 200, body: fixture("ruby", "gemfury_response"))
|
26
|
+
stub_request(:get, registry_url + "versions")
|
27
|
+
.with(basic_auth: ["SECRET_CODES", ""])
|
28
|
+
.to_return(status: 404)
|
29
|
+
stub_request(:get, registry_url + "api/v1/dependencies")
|
30
|
+
.with(basic_auth: ["SECRET_CODES", ""])
|
31
|
+
.to_return(status: 200)
|
32
|
+
stub_request(:get, gemfury_business_url)
|
33
|
+
.with(basic_auth: ["SECRET_CODES", ""])
|
34
|
+
.to_return(status: 200, body: fixture("ruby", "gemfury_response"))
|
34
35
|
end
|
35
36
|
|
36
37
|
describe "#private_registry_versions" do
|
@@ -60,21 +61,21 @@ RSpec.describe Functions::DependencySource do
|
|
60
61
|
|
61
62
|
context "that we don't have authentication details for" do
|
62
63
|
before do
|
63
|
-
stub_request(:get, registry_url + "versions")
|
64
|
-
with(basic_auth: ["SECRET_CODES", ""])
|
65
|
-
to_return(status: 401)
|
66
|
-
stub_request(:get, registry_url + "api/v1/dependencies")
|
67
|
-
with(basic_auth: ["SECRET_CODES", ""])
|
68
|
-
to_return(status: 401)
|
69
|
-
stub_request(:get, registry_url + "specs.4.8.gz")
|
70
|
-
with(basic_auth: ["SECRET_CODES", ""])
|
71
|
-
to_return(status: 401)
|
64
|
+
stub_request(:get, registry_url + "versions")
|
65
|
+
.with(basic_auth: ["SECRET_CODES", ""])
|
66
|
+
.to_return(status: 401)
|
67
|
+
stub_request(:get, registry_url + "api/v1/dependencies")
|
68
|
+
.with(basic_auth: ["SECRET_CODES", ""])
|
69
|
+
.to_return(status: 401)
|
70
|
+
stub_request(:get, registry_url + "specs.4.8.gz")
|
71
|
+
.with(basic_auth: ["SECRET_CODES", ""])
|
72
|
+
.to_return(status: 401)
|
72
73
|
end
|
73
74
|
|
74
75
|
it "blows up with a useful error" do
|
75
76
|
error_class = Bundler::Fetcher::BadAuthenticationError
|
76
|
-
expect { private_registry_versions }
|
77
|
-
to raise_error do |error|
|
77
|
+
expect { private_registry_versions }
|
78
|
+
.to raise_error do |error|
|
78
79
|
expect(error).to be_a(error_class)
|
79
80
|
expect(error.message).to include("Bad username or password for")
|
80
81
|
end
|
@@ -83,21 +84,21 @@ RSpec.describe Functions::DependencySource do
|
|
83
84
|
|
84
85
|
context "that we have bad authentication details for" do
|
85
86
|
before do
|
86
|
-
stub_request(:get, registry_url + "versions")
|
87
|
-
with(basic_auth: ["SECRET_CODES", ""])
|
88
|
-
to_return(status: 403)
|
89
|
-
stub_request(:get, registry_url + "api/v1/dependencies")
|
90
|
-
with(basic_auth: ["SECRET_CODES", ""])
|
91
|
-
to_return(status: 403)
|
92
|
-
stub_request(:get, registry_url + "specs.4.8.gz")
|
93
|
-
with(basic_auth: ["SECRET_CODES", ""])
|
94
|
-
to_return(status: 403)
|
87
|
+
stub_request(:get, registry_url + "versions")
|
88
|
+
.with(basic_auth: ["SECRET_CODES", ""])
|
89
|
+
.to_return(status: 403)
|
90
|
+
stub_request(:get, registry_url + "api/v1/dependencies")
|
91
|
+
.with(basic_auth: ["SECRET_CODES", ""])
|
92
|
+
.to_return(status: 403)
|
93
|
+
stub_request(:get, registry_url + "specs.4.8.gz")
|
94
|
+
.with(basic_auth: ["SECRET_CODES", ""])
|
95
|
+
.to_return(status: 403)
|
95
96
|
end
|
96
97
|
|
97
98
|
it "blows up with a useful error" do
|
98
99
|
error_class = Bundler::Fetcher::BadAuthenticationError
|
99
|
-
expect { private_registry_versions }
|
100
|
-
to raise_error do |error|
|
100
|
+
expect { private_registry_versions }
|
101
|
+
.to raise_error do |error|
|
101
102
|
expect(error).to be_a(error_class)
|
102
103
|
expect(error.message).to include("Bad username or password for")
|
103
104
|
end
|
@@ -106,44 +107,44 @@ RSpec.describe Functions::DependencySource do
|
|
106
107
|
|
107
108
|
context "that bad-requested, but was a private repo" do
|
108
109
|
before do
|
109
|
-
stub_request(:get, registry_url + "versions")
|
110
|
-
with(basic_auth: ["SECRET_CODES", ""])
|
111
|
-
to_return(status: 400)
|
112
|
-
stub_request(:get, registry_url + "api/v1/dependencies")
|
113
|
-
with(basic_auth: ["SECRET_CODES", ""])
|
114
|
-
to_return(status: 400)
|
115
|
-
stub_request(:get, registry_url + "specs.4.8.gz")
|
116
|
-
with(basic_auth: ["SECRET_CODES", ""])
|
117
|
-
to_return(status: 400)
|
118
|
-
stub_request(:get, registry_url + "info/business")
|
119
|
-
with(basic_auth: ["SECRET_CODES", ""])
|
120
|
-
to_return(status: 400)
|
110
|
+
stub_request(:get, registry_url + "versions")
|
111
|
+
.with(basic_auth: ["SECRET_CODES", ""])
|
112
|
+
.to_return(status: 400)
|
113
|
+
stub_request(:get, registry_url + "api/v1/dependencies")
|
114
|
+
.with(basic_auth: ["SECRET_CODES", ""])
|
115
|
+
.to_return(status: 400)
|
116
|
+
stub_request(:get, registry_url + "specs.4.8.gz")
|
117
|
+
.with(basic_auth: ["SECRET_CODES", ""])
|
118
|
+
.to_return(status: 400)
|
119
|
+
stub_request(:get, registry_url + "info/business")
|
120
|
+
.with(basic_auth: ["SECRET_CODES", ""])
|
121
|
+
.to_return(status: 400)
|
121
122
|
end
|
122
123
|
|
123
124
|
it "blows up with a useful error" do
|
124
|
-
expect { private_registry_versions }
|
125
|
-
to raise_error do |error|
|
125
|
+
expect { private_registry_versions }
|
126
|
+
.to raise_error do |error|
|
126
127
|
expect(error).to be_a(Bundler::HTTPError)
|
127
|
-
expect(error.message)
|
128
|
-
to include("Could not fetch specs from")
|
128
|
+
expect(error.message)
|
129
|
+
.to include("Could not fetch specs from")
|
129
130
|
end
|
130
131
|
end
|
131
132
|
end
|
132
133
|
|
133
134
|
context "that doesn't have details of the gem" do
|
134
135
|
before do
|
135
|
-
stub_request(:get, gemfury_business_url)
|
136
|
-
with(basic_auth: ["SECRET_CODES", ""])
|
137
|
-
to_return(status: 404)
|
136
|
+
stub_request(:get, gemfury_business_url)
|
137
|
+
.with(basic_auth: ["SECRET_CODES", ""])
|
138
|
+
.to_return(status: 404)
|
138
139
|
|
139
140
|
# Stub indexes to return details of other gems (but not this one)
|
140
|
-
stub_request(:get, registry_url + "specs.4.8.gz")
|
141
|
-
to_return(
|
141
|
+
stub_request(:get, registry_url + "specs.4.8.gz")
|
142
|
+
.to_return(
|
142
143
|
status: 200,
|
143
144
|
body: fixture("ruby", "contribsys_old_index_response")
|
144
145
|
)
|
145
|
-
stub_request(:get, registry_url + "prerelease_specs.4.8.gz")
|
146
|
-
to_return(
|
146
|
+
stub_request(:get, registry_url + "prerelease_specs.4.8.gz")
|
147
|
+
.to_return(
|
147
148
|
status: 200,
|
148
149
|
body: fixture("ruby", "contribsys_old_index_prerelease_response")
|
149
150
|
)
|
@@ -158,21 +159,21 @@ RSpec.describe Functions::DependencySource do
|
|
158
159
|
let(:registry_url) { "https://gems.contribsys.com/" }
|
159
160
|
|
160
161
|
before do
|
161
|
-
stub_request(:get, registry_url + "versions")
|
162
|
-
with(basic_auth: %w(username password))
|
163
|
-
to_return(status: 404)
|
164
|
-
stub_request(:get, registry_url + "api/v1/dependencies")
|
165
|
-
with(basic_auth: %w(username password))
|
166
|
-
to_return(status: 404)
|
167
|
-
stub_request(:get, registry_url + "specs.4.8.gz")
|
168
|
-
with(basic_auth: %w(username password))
|
169
|
-
to_return(
|
162
|
+
stub_request(:get, registry_url + "versions")
|
163
|
+
.with(basic_auth: %w(username password))
|
164
|
+
.to_return(status: 404)
|
165
|
+
stub_request(:get, registry_url + "api/v1/dependencies")
|
166
|
+
.with(basic_auth: %w(username password))
|
167
|
+
.to_return(status: 404)
|
168
|
+
stub_request(:get, registry_url + "specs.4.8.gz")
|
169
|
+
.with(basic_auth: %w(username password))
|
170
|
+
.to_return(
|
170
171
|
status: 200,
|
171
172
|
body: fixture("ruby", "contribsys_old_index_response")
|
172
173
|
)
|
173
|
-
stub_request(:get, registry_url + "prerelease_specs.4.8.gz")
|
174
|
-
with(basic_auth: %w(username password))
|
175
|
-
to_return(
|
174
|
+
stub_request(:get, registry_url + "prerelease_specs.4.8.gz")
|
175
|
+
.with(basic_auth: %w(username password))
|
176
|
+
.to_return(
|
176
177
|
status: 200,
|
177
178
|
body: fixture("ruby", "contribsys_old_index_prerelease_response")
|
178
179
|
)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: false
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require "native_spec_helper"
|
@@ -32,11 +33,11 @@ RSpec.describe Functions::VersionResolver do
|
|
32
33
|
let(:gemfury_url) { "https://repo.fury.io/greysteil/" }
|
33
34
|
|
34
35
|
before do
|
35
|
-
stub_request(:get, "https://rubygems.org/quick/Marshal.4.8/statesman-1.2.1.gemspec.rz")
|
36
|
-
to_return(status: 200, body: fixture("rubygems_responses", "statesman-1.2.1.gemspec.rz"))
|
36
|
+
stub_request(:get, "https://rubygems.org/quick/Marshal.4.8/statesman-1.2.1.gemspec.rz")
|
37
|
+
.to_return(status: 200, body: fixture("rubygems_responses", "statesman-1.2.1.gemspec.rz"))
|
37
38
|
|
38
|
-
stub_request(:get, %r{quick/Marshal.4.8/business-.*.gemspec.rz})
|
39
|
-
to_return(status: 200, body: fixture("rubygems_responses", "business-1.0.0.gemspec.rz"))
|
39
|
+
stub_request(:get, %r{quick/Marshal.4.8/business-.*.gemspec.rz})
|
40
|
+
.to_return(status: 200, body: fixture("rubygems_responses", "business-1.0.0.gemspec.rz"))
|
40
41
|
end
|
41
42
|
|
42
43
|
describe "#version_details" do
|
@@ -59,16 +60,16 @@ RSpec.describe Functions::VersionResolver do
|
|
59
60
|
before do
|
60
61
|
gemfury_deps_url = gemfury_url + "api/v1/dependencies"
|
61
62
|
|
62
|
-
stub_request(:get, gemfury_url + "versions")
|
63
|
-
to_return(status: 200, body: fixture("ruby", "gemfury-index"))
|
63
|
+
stub_request(:get, gemfury_url + "versions")
|
64
|
+
.to_return(status: 200, body: fixture("ruby", "gemfury-index"))
|
64
65
|
stub_request(:get, gemfury_url + "info/business").to_return(status: 404)
|
65
66
|
stub_request(:get, gemfury_deps_url).to_return(status: 200)
|
66
|
-
stub_request(:get, gemfury_deps_url + "?gems=business,statesman")
|
67
|
-
to_return(status: 200, body: fixture("ruby", "gemfury_response"))
|
68
|
-
stub_request(:get, gemfury_deps_url + "?gems=business")
|
69
|
-
to_return(status: 200, body: fixture("ruby", "gemfury_response"))
|
70
|
-
stub_request(:get, gemfury_deps_url + "?gems=statesman")
|
71
|
-
to_return(status: 200, body: fixture("ruby", "gemfury_response"))
|
67
|
+
stub_request(:get, gemfury_deps_url + "?gems=business,statesman")
|
68
|
+
.to_return(status: 200, body: fixture("ruby", "gemfury_response"))
|
69
|
+
stub_request(:get, gemfury_deps_url + "?gems=business")
|
70
|
+
.to_return(status: 200, body: fixture("ruby", "gemfury_response"))
|
71
|
+
stub_request(:get, gemfury_deps_url + "?gems=statesman")
|
72
|
+
.to_return(status: 200, body: fixture("ruby", "gemfury_response"))
|
72
73
|
end
|
73
74
|
|
74
75
|
its([:version]) { is_expected.to eq(Gem::Version.new("1.9.0")) }
|
@@ -84,13 +85,13 @@ RSpec.describe Functions::VersionResolver do
|
|
84
85
|
|
85
86
|
context "when Bundler's compact index is down" do
|
86
87
|
before do
|
87
|
-
stub_request(:get, "https://index.rubygems.org/versions")
|
88
|
-
to_return(status: 500, body: "We'll be back soon")
|
89
|
-
stub_request(:get, "https://index.rubygems.org/info/public_suffix")
|
90
|
-
to_return(status: 500, body: "We'll be back soon")
|
88
|
+
stub_request(:get, "https://index.rubygems.org/versions")
|
89
|
+
.to_return(status: 500, body: "We'll be back soon")
|
90
|
+
stub_request(:get, "https://index.rubygems.org/info/public_suffix")
|
91
|
+
.to_return(status: 500, body: "We'll be back soon")
|
91
92
|
stub_request(:get, old_index_url).to_return(status: 200)
|
92
|
-
stub_request(:get, old_index_url + "?gems=business,statesman")
|
93
|
-
to_return(
|
93
|
+
stub_request(:get, old_index_url + "?gems=business,statesman")
|
94
|
+
.to_return(
|
94
95
|
status: 200,
|
95
96
|
body: fixture("rubygems_responses",
|
96
97
|
"dependencies-default-gemfile")
|