diff --git a/app/assets/javascripts/controllers/ems_common/ems_common_form_controller.js b/app/assets/javascripts/controllers/ems_common/ems_common_form_controller.js index 932dfc39d6d..56b4ccf30d5 100644 --- a/app/assets/javascripts/controllers/ems_common/ems_common_form_controller.js +++ b/app/assets/javascripts/controllers/ems_common/ems_common_form_controller.js @@ -43,6 +43,7 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', ' ssh_keypair_userid: '', ssh_keypair_password: '', service_account: '', + default_service_account: '', emstype_vm: false, ems_common: true, azure_tenant_id: '', @@ -158,6 +159,7 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', ' $scope.emsCommonModel.ssh_keypair_userid = data.ssh_keypair_userid; $scope.emsCommonModel.service_account = data.service_account; + $scope.emsCommonModel.default_service_account = data.service_account; $scope.emsCommonModel.azure_tenant_id = data.azure_tenant_id; $scope.emsCommonModel.keystone_v3_domain_id = data.keystone_v3_domain_id; $scope.emsCommonModel.subscription = data.subscription; @@ -637,6 +639,7 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', ' default_userid: $scope.emsCommonModel.default_userid, default_password: default_password, default_url: $scope.emsCommonModel.default_url, + default_service_account: $scope.emsCommonModel.default_service_account, realm: $scope.emsCommonModel.realm, azure_tenant_id: $scope.emsCommonModel.azure_tenant_id, subscription: $scope.emsCommonModel.subscription, @@ -739,8 +742,6 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', ' $scope.updateAuthStatus = function(updatedValue) { $scope.angularForm[$scope.currentTab + '_auth_status'].$setViewValue(updatedValue); - $scope.angularForm.$valid = updatedValue; - $scope.angularForm.$invalid = !updatedValue; }; $scope.updateHostname = function(value) { diff --git a/app/controllers/mixins/ems_common/angular.rb b/app/controllers/mixins/ems_common/angular.rb index 4f237612db6..08396720378 100644 --- a/app/controllers/mixins/ems_common/angular.rb +++ b/app/controllers/mixins/ems_common/angular.rb @@ -145,7 +145,7 @@ def get_task_args(ems) ems.http_proxy_uri, true, uri, - :assume_role => params[:service_account].presence, + :assume_role => params[:default_service_account].presence, ] when 'ManageIQ::Providers::Azure::CloudManager' uri = URI.parse(WEBrick::HTTPUtils.escape(params[:default_url])) @@ -808,7 +808,7 @@ def build_credentials(ems, mode) creds[:smartstate_docker] = {:userid => params[:smartstate_docker_userid], :password => smartstate_docker_password, :save => true} end if ems.supports?(:assume_role) - (creds[:default] ||= {})[:service_account] = params[:service_account] + (creds[:default] ||= {})[:service_account] = params[:default_service_account] end if (ems.kind_of?(ManageIQ::Providers::Openstack::InfraManager) || ems.kind_of?(ManageIQ::Providers::Openstack::CloudManager) || diff --git a/app/views/layouts/angular-bootstrap/_auth_credentials_angular_bootstrap.html.haml b/app/views/layouts/angular-bootstrap/_auth_credentials_angular_bootstrap.html.haml index 072e959aee5..65c161ea133 100644 --- a/app/views/layouts/angular-bootstrap/_auth_credentials_angular_bootstrap.html.haml +++ b/app/views/layouts/angular-bootstrap/_auth_credentials_angular_bootstrap.html.haml @@ -17,30 +17,8 @@ - vm_scope ||= false - validate_button ||= true - main_scope = vm_scope ? "$parent.vm" : "$parent" -- ng_show_service_account ||= false -- service_account_label ||= _("Service account") %div{"ng-controller" => "CredentialsController as vm", "vm-scope" => "$parent.vm.model ? $parent.vm : $parent"} - - %div{"ng-show" => "#{ng_show} && #{ng_show_service_account}"} - .form-group{"ng-class" => "{'has-error': angularForm.service_account.$invalid}"} - %label.col-md-2.control-label{"for" => "#{prefix}_service_account"} - = service_account_label - .col-md-4 - - hash_for_service_account = {"type" => "text", - "id" => "#{prefix}_service_account", - "ng-required" => false, - "ng-disabled" => false, - "name" => "service_account", - "ng-model" => "#{main_scope}.#{ng_model}.service_account", - "checkchange" => "", - "ng-trim" => false, - "detect_spaces" => "", - "prefix" => "#{prefix}", - "main-scope" => "#{main_scope}", - "reset-validation-status" => "#{prefix}_auth_status"} - %input.form-control{hash_for_service_account} - %div{"ng-show" => "#{ng_show} && #{ng_show_userid}"} .form-group{"ng-class" => "{'has-error': angularForm.#{prefix}_userid.$invalid}"} %label.col-md-2.control-label{"for" => "#{prefix}_userid"} @@ -97,7 +75,6 @@ = change_stored_password %a{:href => "", "ng-show" => "vm.bChangeStoredPassword", "ng-click" => "vm.cancelPasswordChange()"} = cancel_password_change - %div{"ng-show" => "#{ng_show}", "ng-if" => "#{validate_button}"} .form-group %label.col-md-2 diff --git a/app/views/layouts/angular/_multi_auth_credentials.html.haml b/app/views/layouts/angular/_multi_auth_credentials.html.haml index da75ee2e778..8f62d85f6e6 100644 --- a/app/views/layouts/angular/_multi_auth_credentials.html.haml +++ b/app/views/layouts/angular/_multi_auth_credentials.html.haml @@ -67,24 +67,38 @@ .col-md-12{"ng-if" => "#{ng_model}" == "emsCommonModel" && "#{ng_model}.emstype == 'ec2'"} = render :partial => "layouts/angular-bootstrap/endpoints_for_url", :locals => {:prefix => "default", :ng_model => "#{ng_model}"} + %div + .form-group{"ng-class" => "{'has-error': angularForm.default_service_account.$invalid}"} + %label.col-md-2.control-label{"for" => "default_service_account"} + = _("Assume role ARN") + .col-md-4 + %input.form-control{"type" => "text", + "id" => "default_service_account", + "ng-required" => "false", + "ng-disabled" => "false", + "name" => "default_service_account", + "ng-model" => "#{main_scope}.#{ng_model}.default_service_account", + "checkchange" => "", + "ng-trim" => false, + "detect_spaces" => "", + "prefix" => "default", + "reset-validation-status" => "default_auth_status"} = render :partial => "layouts/angular-bootstrap/auth_credentials_angular_bootstrap", - :locals => {:ng_show => true, - :ng_model => "#{ng_model}", - :ng_reqd_userid => true, - :ng_reqd_password => true, - :validate_url => validate_url, - :userid_label => _("Access Key ID"), - :password_label => _("Secret Access Key"), - :verify_label => _("Confirm Secret Access Key"), - :passwd_mismatch => _("Secret Access Keys do not match"), - :change_stored_password => _("Change stored secret access key"), - :cancel_password_change => _("Cancel secret access key change"), - :ng_show_service_account => true, - :service_account_label => _("Assume role ARN"), - :id => record.id, - :prefix => "default", - :verify_title_off => _("Access Key ID and matching Secret Access Key fields are needed to perform verification of credentials"), - :basic_info_needed => true} + :locals => {:ng_show => true, + :ng_model => "#{ng_model}", + :ng_reqd_userid => true, + :ng_reqd_password => true, + :validate_url => validate_url, + :userid_label => _("Access Key ID"), + :password_label => _("Secret Access Key"), + :verify_label => _("Confirm Secret Access Key"), + :passwd_mismatch => _("Secret Access Keys do not match"), + :change_stored_password => _("Change stored secret access key"), + :cancel_password_change => _("Cancel secret access key change"), + :id => record.id, + :prefix => "default", + :verify_title_off => _("Access Key ID and matching Secret Access Key fields are needed to perform verification of credentials"), + :basic_info_needed => true} .col-md-12{"ng-if" => "#{ng_model}" == "emsCommonModel" && "#{ng_model}.emstype == 'gce'"} = render :partial => "layouts/angular/auth_service_account_angular", :locals => {:ng_show => true, diff --git a/spec/controllers/mixins/ems_common/angular_spec.rb b/spec/controllers/mixins/ems_common/angular_spec.rb index af78ba5c4b9..71feecff7ff 100644 --- a/spec/controllers/mixins/ems_common/angular_spec.rb +++ b/spec/controllers/mixins/ems_common/angular_spec.rb @@ -222,10 +222,10 @@ before do @ems_cloud_controller = EmsCloudController.new @params = { - :default_userid => "abc", - :default_password => "abc", - :default_url => "http://abc.test/mypath", - :service_account => "test_arn", + :default_userid => "abc", + :default_password => "abc", + :default_url => "http://abc.test/mypath", + :default_service_account => "test_arn", } @ems = FactoryBot.create(:ems_amazon) allow(@ems).to receive(:to_s).and_return('ManageIQ::Providers::Amazon::CloudManager')