Skip to content

Commit

Permalink
nuget: handle RepositoryDetails without BaseAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
thepwagner committed Jun 23, 2021
1 parent 3ebeb11 commit 83c02a8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
9 changes: 4 additions & 5 deletions nuget/lib/dependabot/nuget/update_checker/version_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,16 @@ def available_v3_versions
listing.
fetch("versions", []).
map do |v|
nuspec_url =
listing.fetch("listing_details").
fetch(:versions_url).
listing_details = listing.fetch("listing_details")
nuspec_url = listing_details.
fetch(:versions_url, nil)&.
gsub(/index\.json$/, "#{v}/#{sanitized_name}.nuspec")

{
version: version_class.new(v),
nuspec_url: nuspec_url,
source_url: nil,
repo_url:
listing.fetch("listing_details").fetch(:repository_url)
repo_url: listing_details.fetch(:repository_url)
}
end
end
Expand Down
24 changes: 21 additions & 3 deletions nuget/spec/dependabot/nuget/update_checker/version_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@
let(:custom_repo_url) do
"https://www.myget.org/F/exceptionless/api/v3/index.json"
end
let(:custom_nuget_search_url) do
"https://www.myget.org/F/exceptionless/api/v3/"\
"query?q=microsoft.extensions.dependencymodel&prerelease=true"
end
before do
stub_request(:get, nuget_versions_url).to_return(status: 404)
stub_request(:get, nuget_search_url).to_return(status: 404)
Expand All @@ -323,9 +327,6 @@
custom_nuget_versions_url =
"https://www.myget.org/F/exceptionless/api/v3/flatcontainer/"\
"microsoft.extensions.dependencymodel/index.json"
custom_nuget_search_url =
"https://www.myget.org/F/exceptionless/api/v3/"\
"query?q=microsoft.extensions.dependencymodel&prerelease=true"
stub_request(:get, custom_nuget_versions_url).to_return(status: 404)
stub_request(:get, custom_nuget_versions_url).
with(basic_auth: %w(my passw0rd)).
Expand All @@ -337,6 +338,23 @@
end

its([:version]) { is_expected.to eq(version_class.new("2.1.0")) }

context "that does not return PackageBaseAddress" do
let(:custom_repo_url) { "http://localhost:8082/artifactory/api/nuget/v3/nuget-local" }
let(:custom_nuget_search_url) do
"http://localhost:8082/artifactory/api/nuget/v3/nuget-local/"\
"query?prerelease=true&q=microsoft.extensions.dependencymodel"
end
before do
stub_request(:get, custom_repo_url).
to_return(
status: 200,
body: fixture("nuget_responses", "artifactory_base.json")
)
end

its([:version]) { is_expected.to eq(version_class.new("2.1.0")) }
end
end

context "with a version range specified" do
Expand Down

0 comments on commit 83c02a8

Please sign in to comment.