Browse Source

AMBARI-8634. Kerberos wizard->Configure Identities page: Invalidated properties should show error count and disable next button (alexantonenko)

Alex Antonenko 10 years ago
parent
commit
da44fafcc9

+ 1 - 0
ambari-web/app/assets/test/tests.js

@@ -51,6 +51,7 @@ var files = ['test/init_model_test',
   'test/controllers/main/alerts/alert_instances_controller_test',
   'test/controllers/main/alerts/alert_instances_controller_test',
   'test/controllers/main/alerts/add_alert_definition/step1_controller_test',
   'test/controllers/main/alerts/add_alert_definition/step1_controller_test',
   'test/controllers/main/alerts/manage_alert_notifications_controller_test',
   'test/controllers/main/alerts/manage_alert_notifications_controller_test',
+  'test/controllers/main/admin/kerberos/step4_controller_test',
   'test/controllers/main/admin/stack_and_upgrade_controller_test',
   'test/controllers/main/admin/stack_and_upgrade_controller_test',
   'test/controllers/main/admin/stack_version/stack_version_details_controller_test',
   'test/controllers/main/admin/stack_version/stack_version_details_controller_test',
   'test/controllers/main/admin/stack_version/repo_versions_controller_test',
   'test/controllers/main/admin/stack_version/repo_versions_controller_test',

+ 9 - 6
ambari-web/app/controllers/main/admin/kerberos/step4_controller.js

@@ -16,11 +16,8 @@
  * limitations under the License.
  * limitations under the License.
  */
  */
 
 
-App.KerberosWizardStep4Controller = Em.Controller.extend(App.AddSecurityConfigs, {
+App.KerberosWizardStep4Controller = App.WizardStep7Controller.extend(App.AddSecurityConfigs, {
   name: 'kerberosWizardStep4Controller',
   name: 'kerberosWizardStep4Controller',
-  stepConfigs: [],
-  selectedService: null,
-  isRecommendedLoaded: false,
   
   
   clearStep: function() {
   clearStep: function() {
     this.set('isRecommendedLoaded', false);
     this.set('isRecommendedLoaded', false);
@@ -45,7 +42,7 @@ App.KerberosWizardStep4Controller = Em.Controller.extend(App.AddSecurityConfigs,
    * @returns {Em.Object} 
    * @returns {Em.Object} 
    */
    */
   createServiceConfig: function(configCategories, configs) {
   createServiceConfig: function(configCategories, configs) {
-    return Em.Object.create({
+    return App.ServiceConfig.create({
       displayName: 'Kerberos Descriptor',
       displayName: 'Kerberos Descriptor',
       name: 'KERBEROS',
       name: 'KERBEROS',
       serviceName: 'KERBEROS',
       serviceName: 'KERBEROS',
@@ -107,7 +104,13 @@ App.KerberosWizardStep4Controller = Em.Controller.extend(App.AddSecurityConfigs,
   },
   },
 
 
   submit: function() {
   submit: function() {
+    this.saveConfigurations();
     App.router.send('next');
     App.router.send('next');
-  }
+  },
   
   
+  saveConfigurations: function() {
+    var configs = this.get('stepConfigs')[0].get('configs');
+    this.get('wizardController').setDBProperty('kerberosDescriptorConfigs', configs);
+    this.set('wizardController.content.kerberosDescriptorConfigs', configs);
+  }
 });
 });

+ 1 - 0
ambari-web/app/controllers/main/admin/kerberos/wizard_controller.js

@@ -41,6 +41,7 @@ App.KerberosWizardController = App.WizardController.extend({
     services: null,
     services: null,
     advancedServiceConfig: null,
     advancedServiceConfig: null,
     serviceConfigProperties: [],
     serviceConfigProperties: [],
+    kerberosDescriptorConfigs: null,
     failedTask: null
     failedTask: null
   }),
   }),
 
 

+ 2 - 2
ambari-web/app/templates/main/admin/kerberos/step4.hbs

@@ -24,7 +24,7 @@
   {{view App.ServicesConfigView}}
   {{view App.ServicesConfigView}}
 
 
   <div class="btn-area">
   <div class="btn-area">
-    <a id="submit-kerberos-step4" class="btn btn-success pull-right" {{bindAttr disabled="isSubmitDisabled"}}
-       {{action submit target="controller"}}>{{t common.next}} &rarr;</a>
+    <button id="submit-kerberos-step4" class="btn btn-success pull-right" {{bindAttr disabled="isSubmitDisabled"}}
+       {{action submit target="controller"}}>{{t common.next}} &rarr;</button>
   </div>
   </div>
 </div>
 </div>

+ 53 - 0
ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js

@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+describe('App.KerberosWizardStep4Controller', function() {
+  
+  describe('#isSubmitDisabled', function() {
+    var controller = App.KerberosWizardStep4Controller.create({});
+    var configCategories = Em.A([
+      App.ServiceConfigCategory.create({ name: 'Advanced', displayName: 'Advanced'})
+    ]);
+    var configs = Em.A([
+      App.ServiceConfigProperty.create({ name: 'prop1', value: 'someVal1', category: 'Advanced'})
+    ]);
+    controller.set('stepConfigs', [controller.createServiceConfig(configCategories, configs)]);
+    
+    it('configuration errors are absent, submit should be not disabled', function() {
+      expect(controller.get('stepConfigs')[0].get('errorCount')).to.be.eql(0);
+      expect(controller.get('isSubmitDisabled')).to.be.false;
+    });
+
+    it('config has invalid value, submit should be disabled', function() {
+      var serviceConfig = controller.get('stepConfigs')[0];
+      serviceConfig.get('configs').findProperty('name', 'prop1').set('value', '');
+      expect(serviceConfig.get('errorCount')).to.be.eql(1);
+      expect(controller.get('isSubmitDisabled')).to.be.true;
+    });  
+  });
+
+  describe('#createServiceConfig', function() {
+    var controller = App.KerberosWizardStep4Controller.create({});
+    it('should create instance of App.ServiceConfig', function() {
+      expect(controller.createServiceConfig([], [])).be.instanceof(App.ServiceConfig);
+    });
+  });
+});
+