Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #687 from SUSE/fix-ssl-error-message
Browse files Browse the repository at this point in the history
Change error message on openSSL's errors
  • Loading branch information
flavio committed Jan 26, 2016
2 parents 8685e95 + 61abca1 commit 6a1b206
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 4 additions & 6 deletions app/models/registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,10 @@ def reachable?
else
msg = "Error: not using SSL, but the given registry does use SSL."
end
rescue OpenSSL::SSL::SSLError
if use_ssl
msg = "Error: using SSL, but the given registry is not using SSL."
else
msg = "Error: there's something wrong with your SSL configuration."
end
rescue OpenSSL::SSL::SSLError => e
msg = "SSL error while communicating with the registry, check the server " \
"logs for more details."
logger.error(e)
rescue StandardError => e
# We don't know what went wrong :/
logger.info "Registry not reachable: #{e.inspect}"
Expand Down
6 changes: 4 additions & 2 deletions spec/models/registry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def client
end
end

# rubocop: disable Metrics/LineLength
describe "#reachable" do
it "returns the proper message for each scenario" do
[
Expand All @@ -116,15 +117,16 @@ def client
[Net::OpenTimeout, true, true, /connection timed out/],
[Net::HTTPBadResponse, true, true, /wrong with your SSL configuration/],
[Net::HTTPBadResponse, true, false, /Error: not using SSL/],
[OpenSSL::SSL::SSLError, true, true, /Error: using SSL/],
[OpenSSL::SSL::SSLError, true, false, /wrong with your SSL configuration/],
[OpenSSL::SSL::SSLError, true, true, /SSL error while communicating with the registry, check the server logs for more details./],
[OpenSSL::SSL::SSLError, true, false, /SSL error while communicating with the registry, check the server logs for more details./],
[StandardError, true, true, /something went wrong/]
].each do |cs|
rr = RegistryReachable.new(cs.first, cs[1], cs[2])
expect(rr.reachable?).to match(cs.last)
end
end
end
# rubocop: enable Metrics/LineLength

describe "#get_tag_from_manifest" do
it "returns a tag on success" do
Expand Down

0 comments on commit 6a1b206

Please sign in to comment.