Skip to content

Commit

Permalink
Add raw_connect!? method to ExtManagementSystem
Browse files Browse the repository at this point in the history
When validating credentials on the queue, existing raw_connect methods return the actual connection, which is then being placed into the logs on callback. It should not be present in the logs. The credential validation only cares about a success or failure, not the connection, so this raw_connect? wrapper method will return a true value on successful validation, rather than the connection itself.
  • Loading branch information
Jillian Tullo committed Dec 12, 2017
1 parent 5729359 commit 5c165e8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/models/ext_management_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ def self.create_discovered_ems(ost)
end
end

def self.raw_connect?(*params)
!!raw_connect(*params)
end

def self.model_name_from_emstype(emstype)
model_from_emstype(emstype).try(:name)
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/mixins/authentication_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def self.validate_credentials_task(args, user_id, zone)
queue_opts = {
:args => [*args],
:class_name => self,
:method_name => "raw_connect",
:method_name => "raw_connect?",
:queue_name => "generic",
:role => "ems_operations",
:zone => zone
Expand Down
9 changes: 9 additions & 0 deletions spec/models/ext_management_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -434,4 +434,13 @@
expect(ems.supports_cloud_object_store_container_create).to eq(true)
end
end

describe ".raw_connect?" do
it "returns true if validation was successful" do
connection = double
allow(ManageIQ::Providers::Amazon::CloudManager).to receive(:raw_connect).and_return(connection)

expect(ManageIQ::Providers::Amazon::CloudManager.raw_connect?).to eq(true)
end
end
end
2 changes: 1 addition & 1 deletion spec/models/mixins/authentication_mixin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def self.name; "TestClass"; end
{
:args => [*args],
:class_name => ExtManagementSystem,
:method_name => "raw_connect",
:method_name => "raw_connect?",
:queue_name => "generic",
:role => "ems_operations",
:zone => 'zone'
Expand Down

0 comments on commit 5c165e8

Please sign in to comment.