Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Human readable error when selecting wrong security protocol #43

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problematic error that you mention in the commit msg is returned from the else part otherwise? I am reluctant to use this when case here as it relies on a generic http error message.

Furthermore, do you need to return HTTPBadResponse? In case we need this specific error message, I would still use the same error type as in the else part.

@juliancheal I’ve looked some other providers but couldn’t find any similar error oath - do you think it is necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gberginc yes, the problematic error is otherwise returned in the last else statement. And because the error message in the HTTPBadResponse is so poorly written, it has very little meaning showing it to the user through a dashboard error notification.

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
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