Skip to content

Commit

Permalink
Print out a more human readable error when selecting wrong security p…
Browse files Browse the repository at this point in the history
…rotocol

This change modifies the error message returned from nuage when selecting
the wrong security protocol. The old error message was: 'wrong status line:
"\x15\x03\x03\x00\x02\x02"' which was not informative to the end user.
Also added rspec test case to cover this exception.
  • Loading branch information
gasper-vrhovsek committed Dec 14, 2017
1 parent a1f64a1 commit 888f133
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/manageiq/providers/nuage/manager_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def translate_exception(err)
MiqException::MiqHostError.new("Socket error: #{err.message}")
when MiqException::MiqInvalidCredentialsError, MiqException::MiqHostError
err
when Net::HTTPBadResponse
MiqException::MiqEVMLoginError.new("Login failed due to a bad security protocol, hostname or port.")
else
MiqException::MiqEVMLoginError.new("Unexpected response returned from system: #{err.message}")
end
Expand Down
6 changes: 6 additions & 0 deletions spec/models/manageiq/providers/nuage/network_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@
allow(@ems).to receive(:with_provider_connection).and_raise(exception)
expect { @ems.verify_credentials }.to raise_error(MiqException::MiqHostError, /invalid host/)
end

it 'handles Net::HTTPBadResponse' do
exception = Net::HTTPBadResponse.new
allow(@ems).to receive(:with_provider_connection).and_raise(exception)
expect { @ems.verify_credentials }.to raise_error(MiqException::MiqEVMLoginError, /Login failed due to a bad security protocol, hostname or port./)
end
end

context '#authentications_to_validate' do
Expand Down

0 comments on commit 888f133

Please sign in to comment.