From 5c165e8209be6de67fc399eb59b5e6f0e2a5a2ee Mon Sep 17 00:00:00 2001 From: Jillian Tullo Date: Mon, 11 Dec 2017 12:25:40 -0500 Subject: [PATCH] Add raw_connect!? method to ExtManagementSystem 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. --- app/models/ext_management_system.rb | 4 ++++ app/models/mixins/authentication_mixin.rb | 2 +- spec/models/ext_management_system_spec.rb | 9 +++++++++ spec/models/mixins/authentication_mixin_spec.rb | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/models/ext_management_system.rb b/app/models/ext_management_system.rb index da2405e20e00..a72dd2a40b17 100644 --- a/app/models/ext_management_system.rb +++ b/app/models/ext_management_system.rb @@ -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 diff --git a/app/models/mixins/authentication_mixin.rb b/app/models/mixins/authentication_mixin.rb index 15a2594ec9a4..2bb3afeba895 100644 --- a/app/models/mixins/authentication_mixin.rb +++ b/app/models/mixins/authentication_mixin.rb @@ -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 diff --git a/spec/models/ext_management_system_spec.rb b/spec/models/ext_management_system_spec.rb index 21ec0a945fc9..57fa8aa6c02f 100644 --- a/spec/models/ext_management_system_spec.rb +++ b/spec/models/ext_management_system_spec.rb @@ -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 diff --git a/spec/models/mixins/authentication_mixin_spec.rb b/spec/models/mixins/authentication_mixin_spec.rb index ab5d89834c38..a72b62221a7d 100644 --- a/spec/models/mixins/authentication_mixin_spec.rb +++ b/spec/models/mixins/authentication_mixin_spec.rb @@ -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'