summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-10-22 11:57:55 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-10-22 11:57:55 +0200
commite26a30e5cef35b3ba7c920b941498c2ed16c54ee (patch)
tree989ab9cd0f772a9baeadc8ad3e0f05cbb4cfd311
parent380f63bf8d9b7f568c3958f6d0caeb0c05e712ac (diff)
downloadgitlab-ce-e26a30e5cef35b3ba7c920b941498c2ed16c54ee.tar.gz
Improve error message when `include` is blocked
-rw-r--r--lib/gitlab/ci/config/external/file/remote.rb8
-rw-r--r--spec/lib/gitlab/ci/config/external/file/remote_spec.rb9
2 files changed, 12 insertions, 5 deletions
diff --git a/lib/gitlab/ci/config/external/file/remote.rb b/lib/gitlab/ci/config/external/file/remote.rb
index 23dfc5d9d44..86fa5ad8800 100644
--- a/lib/gitlab/ci/config/external/file/remote.rb
+++ b/lib/gitlab/ci/config/external/file/remote.rb
@@ -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?
diff --git a/spec/lib/gitlab/ci/config/external/file/remote_spec.rb b/spec/lib/gitlab/ci/config/external/file/remote_spec.rb
index f65a5a1c727..7c1a1c38736 100644
--- a/spec/lib/gitlab/ci/config/external/file/remote_spec.rb
+++ b/spec/lib/gitlab/ci/config/external/file/remote_spec.rb
@@ -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