From e92aa4c59498118e50c63e78a9de1733f80ce5d1 Mon Sep 17 00:00:00 2001 From: Martin Hradil Date: Wed, 25 Sep 2019 14:33:28 +0000 Subject: [PATCH] Provider validate - don't attempt to directly connect from the UI validation via the queue was added in https://github.com/ManageIQ/manageiq-ui-classic/issues/1580, but explicitly left some cases to try connecting directly. This is not really desirable as the UiWorker is not guaranteed to be able to do that in general. --- app/controllers/mixins/ems_common/angular.rb | 11 +---------- spec/controllers/ems_cloud_controller_spec.rb | 5 +++-- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/app/controllers/mixins/ems_common/angular.rb b/app/controllers/mixins/ems_common/angular.rb index cb4d0627bc1..ee67d5d0478 100644 --- a/app/controllers/mixins/ems_common/angular.rb +++ b/app/controllers/mixins/ems_common/angular.rb @@ -80,19 +80,10 @@ def realtime_authentication_check(verify_ems = nil) verify_ems.authentication_check(params[:cred_type], :save => false, :database => params[:metrics_database_name]) end - def realtime_raw_connect(ems_type) - ems_type.raw_connect(*get_task_args(ems_type)) - true - rescue => err - [false, err.message] - end - def create_ems_button_validate @in_a_form = true ems_type = model.model_from_emstype(params[:emstype]) - result, details = if %w[ems_cloud ems_infra].include?(params[:controller]) && session[:selected_roles].try(:include?, 'user_interface') - realtime_raw_connect(ems_type) - elsif %w[ems_cloud ems_infra].include?(params[:controller]) + result, details = if %w[ems_cloud ems_infra].include?(params[:controller]) ems_type.validate_credentials_task(get_task_args(ems_type), session[:userid], params[:zone]) else realtime_authentication_check(ems_type.new) diff --git a/spec/controllers/ems_cloud_controller_spec.rb b/spec/controllers/ems_cloud_controller_spec.rb index 6739e0437ac..900842831fe 100644 --- a/spec/controllers/ems_cloud_controller_spec.rb +++ b/spec/controllers/ems_cloud_controller_spec.rb @@ -326,10 +326,11 @@ controller.send(:create_ems_button_validate) end - it "does not queue the authentication check if it is a cloud provider with a ui role" do + it "does queue the authentication check even if it is a cloud provider with a ui role" do session[:selected_roles] = ['user_interface'] - expect(mocked_class).to receive(:raw_connect) + expect(mocked_class).not_to receive(:raw_connect) + expect(mocked_class).to receive(:validate_credentials_task) controller.send(:create_ems_button_validate) end