Commit e26a30e5 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Improve error message when `include` is blocked

parent 380f63bf
......@@ -31,14 +31,12 @@ module Gitlab
errors.push("Remote file `#{location}` could not be fetched because of a timeout error!")
rescue Gitlab::HTTP::Error
errors.push("Remote file `#{location}` could not be fetched because of HTTP error!")
rescue Gitlab::HTTP::BlockedUrlError
errors.push("Remote file `#{location}` could not be fetched because the URL is blocked!")
rescue Gitlab::HTTP::BlockedUrlError => e
errors.push("Remote file could not be fetched because #{e}!")
end
if response&.code.to_i >= 400
errors.push <<~ERROR
Remote file `#{location}` could not be fetched because of HTTP code `#{response.code}` error!
ERROR
errors.push("Remote file `#{location}` could not be fetched because of HTTP code `#{response.code}` error!")
end
response.to_s if errors.none?
......
......@@ -144,5 +144,14 @@ describe Gitlab::Ci::Config::External::File::Remote do
expect(subject).to match /could not be fetched because of HTTP code `404` error!/
end
end
context 'when the URL is blocked' do
let(:location) { 'http://127.0.0.1/some/path/to/config.yaml' }
it 'should include details about blocked URL' do
expect(subject).to eq "Remote file could not be fetched because URL '#{location}' " \
'is blocked: Requests to localhost are not allowed!'
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment