Skip to content
Open
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
5 changes: 4 additions & 1 deletion python/lib/dependabot/python/file_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ def pip_compile_index_urls
if credentials.any?(&:replaces_base?)
credentials.select(&:replaces_base?).map { |cred| AuthedUrlBuilder.authed_url(credential: cred) }
else
urls = credentials.map { |cred| AuthedUrlBuilder.authed_url(credential: cred) }
# A credential without an index-url (such as the github.com git_source
# credential every job carries) gives "". Leave it out: package_hashes_for
# would otherwise look up hashes at "/pypi/<name>/json" and fail.
urls = credentials.map { |cred| AuthedUrlBuilder.authed_url(credential: cred) }.reject(&:empty?)
# If there are no credentials that replace the base, we need to
# ensure that the base URL is included in the list of extra-index-urls.
[nil, *urls]
Expand Down
29 changes: 29 additions & 0 deletions python/spec/dependabot/python/file_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,35 @@
expect(instance.send(:pip_compile_index_urls)).to eq([nil, "authed_url"])
end
end

context "when a credential has no index-url" do
let(:credentials) do
[
Dependabot::Credential.new(
{
"type" => "git_source",
"host" => "github.com",
"username" => "x-access-token",
"password" => "token"
}
),
Dependabot::Credential.new(
{
"type" => "python_index",
"index-url" => "https://pypi.example.com/simple"
}
)
]
end

before do
allow(Dependabot::Python::AuthedUrlBuilder).to receive(:authed_url).and_call_original
end

it "leaves it out, so no hash lookup gets an empty index URL" do
expect(instance.send(:pip_compile_index_urls)).to eq([nil, "https://pypi.example.com/simple"])
end
end
end
end
end
5 changes: 4 additions & 1 deletion uv/lib/dependabot/uv/file_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ def pip_compile_index_urls
if credentials.any?(&:replaces_base?)
credentials.select(&:replaces_base?).map { |cred| AuthedUrlBuilder.authed_url(credential: cred) }
else
urls = credentials.map { |cred| AuthedUrlBuilder.authed_url(credential: cred) }
# A credential without an index-url (such as the github.com git_source
# credential every job carries) gives "". Leave it out: package_hashes_for
# would otherwise look up hashes at "/pypi/<name>/json" and fail.
urls = credentials.map { |cred| AuthedUrlBuilder.authed_url(credential: cred) }.reject(&:empty?)
# If there are no credentials that replace the base, we need to
# ensure that the base URL is included in the list of extra-index-urls.
[nil, *urls]
Expand Down
29 changes: 29 additions & 0 deletions uv/spec/dependabot/uv/file_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,35 @@
expect(instance.send(:pip_compile_index_urls)).to eq([nil, "authed_url"])
end
end

context "when a credential has no index-url" do
let(:credentials) do
[
Dependabot::Credential.new(
{
"type" => "git_source",
"host" => "github.com",
"username" => "x-access-token",
"password" => "token"
}
),
Dependabot::Credential.new(
{
"type" => "python_index",
"index-url" => "https://pypi.example.com/simple"
}
)
]
end

before do
allow(Dependabot::Uv::AuthedUrlBuilder).to receive(:authed_url).and_call_original
end

it "leaves it out, so no hash lookup gets an empty index URL" do
expect(instance.send(:pip_compile_index_urls)).to eq([nil, "https://pypi.example.com/simple"])
end
end
end
end
end
Loading