Skip to content
2 changes: 2 additions & 0 deletions docker/lib/dependabot/docker/update_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ def tags_from_registry

retry
end
rescue DockerRegistry2::NotFound
raise DockerRegistry2::NotFound, "Image not found: https://#{registry_hostname}/#{docker_repo_name}"
rescue DockerRegistry2::RegistryAuthenticationException,
RestClient::Forbidden
raise PrivateSourceAuthenticationFailure, registry_hostname
Expand Down
38 changes: 38 additions & 0 deletions docker/spec/dependabot/docker/update_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,44 @@
it { is_expected.to eq("17.04") }
end

context "when image is not found" do
let(:tags_fixture_name) { "ubuntu_no_latest.json" }

context "with replaces-base set to true" do
let(:credentials) do
[{
"type" => "git_source",
"host" => "github.com",
"username" => "x-access-token",
"password" => "token"
}, {
"type" => "docker_registry",
"registry" => "registry-host.io:5000",
"username" => "grey",
"password" => "pa55word",
"replaces-base" => true
}]
end

before do
tags_url = "https://registry-host.io:5000/v2/ubuntu/tags/list"
stub_request(:get, tags_url).
and_return(
status: 404,
body: ""
)
end

it "raises a to DockerRegistry2::NotFound error" do
error_class = DockerRegistry2::NotFound
expect { checker.latest_version }.
to raise_error(error_class) do |error|
expect(error.message).to eq("Image not found: https://registry-host.io:5000/ubuntu")
end
end
end
end

context "when the dependency's version has a prefix" do
let(:version) { "artful-20170826" }
it { is_expected.to eq("artful-20170916") }
Expand Down