Skip to content

Commit

Permalink
Merge pull request #6237 from himdel/validate
Browse files Browse the repository at this point in the history
Provider validate - don't attempt to directly connect from the UI
  • Loading branch information
mzazrivec authored Oct 2, 2019
2 parents cef5246 + e92aa4c commit e034387
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
11 changes: 1 addition & 10 deletions app/controllers/mixins/ems_common/angular.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions spec/controllers/ems_cloud_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e034387

Please sign in to comment.