Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No public url call when public registry is disabled #5948

Merged
merged 4 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions nuget/lib/dependabot/nuget/metadata_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,7 @@ def dependency_nuspec_url
source = dependency.requirements.
find { |r| r&.fetch(:source) }&.fetch(:source)

if source&.key?(:nuspec_url)
source.fetch(:nuspec_url) ||
"https://api.nuget.org/v3-flatcontainer/" \
"#{dependency.name.downcase}/#{dependency.version}/" \
"#{dependency.name.downcase}.nuspec"
elsif source&.key?(:nuspec_url)
source.fetch("nuspec_url") ||
"https://api.nuget.org/v3-flatcontainer/" \
"#{dependency.name.downcase}/#{dependency.version}/" \
"#{dependency.name.downcase}.nuspec"
else
"https://api.nuget.org/v3-flatcontainer/" \
"#{dependency.name.downcase}/#{dependency.version}/" \
"#{dependency.name.downcase}.nuspec"
end
return source.fetch(:nuspec_url) if source&.key?(:nuspec_url)
end

def dependency_source_url
Expand Down
19 changes: 2 additions & 17 deletions nuget/spec/dependabot/nuget/metadata_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,6 @@
)
end

context "with a github link in the nuspec" do
it { is_expected.to eq("https://github.com/dotnet/core-setup") }

it "caches the call to nuget" do
2.times { source_url }
expect(WebMock).to have_requested(:get, nuget_url).once
end
end

context "with a source" do
let(:source) do
{
Expand All @@ -94,7 +85,7 @@
expect(WebMock).to have_requested(:get, nuget_url).once
end

context "that has a source_url" do
context "that has a source_url only" do
let(:source) do
{
type: "nuget_repo",
Expand All @@ -117,13 +108,7 @@
}
end

let(:nuget_url) do
"https://api.nuget.org/v3-flatcontainer/" \
"microsoft.extensions.dependencymodel/2.1.0/" \
"microsoft.extensions.dependencymodel.nuspec"
end

it { is_expected.to eq("https://github.com/dotnet/core-setup") }
it { is_expected.to eq(nil) }
end

context "with details in the credentials (but no token)" do
Expand Down