You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2015/05/31 22:08:46 UTC

[2/3] ambari git commit: AMBARI-11574. Kerberos: ignore some properties in stack advisor for manually enabled Kerberos. (alexantonenko)

AMBARI-11574. Kerberos: ignore some properties in stack advisor for manually enabled Kerberos. (alexantonenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/2ea32f88
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/2ea32f88
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/2ea32f88

Branch: refs/heads/trunk
Commit: 2ea32f886d06f30acb1ba03449447894cbbe5492
Parents: f4631d7
Author: Alex Antonenko <hi...@gmail.com>
Authored: Sun May 31 21:50:43 2015 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Sun May 31 23:06:29 2015 +0300

----------------------------------------------------------------------
 .../app/controllers/wizard/step7_controller.js  | 40 ++++++++++++++++
 .../test/controllers/wizard/step7_test.js       | 50 ++++++++++++++++++++
 2 files changed, 90 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2ea32f88/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index 3cc31f0..8550932 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -443,6 +443,8 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
     var serviceConfig = App.config.createServiceConfig(serviceName);
     service.set('selectedConfigGroup', this.get('preSelectedConfigGroup'));
     this.loadComponentConfigs(service.get('configs'), serviceConfig, service);
+    // override if a property isRequired or not
+    this._overrideConfigIsRequired(serviceName);
     service.set('configs', serviceConfig.get('configs'));
   },
 
@@ -1437,5 +1439,43 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
         $('a[href="#' + service.serviceName + '"]').tab('show');
       }
     }
+  },
+
+  /**
+   * Override isRequired property of the configurations in given situation
+   * @param serviceName - make changes only for properties from this service
+   * @private
+   */
+  _overrideConfigIsRequired: function (serviceName) {
+    var excludeProperties = [
+      {
+        name: 'KERBEROS',                                                                // affected service
+        exclude: ['kdc_host', 'admin_server_host', 'admin_principal', 'admin_password'], // affected properties
+        condition: 'false',                                                              // check this condition
+        conditionalProperty: 'manage_identities'                                         // against this property
+      }
+    ];
+
+    var configs = this.get('stepConfigs'),
+      service = excludeProperties.findProperty('name', serviceName),
+      serviceConfigs = configs.findProperty('serviceName', serviceName);
+    if (service && !Em.isEmpty(serviceConfigs.configs)) {
+      var conditionProperty = serviceConfigs.configs.findProperty('name', service.conditionalProperty);
+      if (conditionProperty && conditionProperty.get('savedValue') === service.condition) {
+        service.exclude.forEach(function(property) {
+          var serviceProperty = serviceConfigs.configs.findProperty('name', property);
+          if (serviceProperty) {
+            Em.set(serviceProperty, "isRequired", false);
+            if (serviceProperty.get('value')==='') {
+              // clear validation errors because validation does not clear isRequired validations
+              Em.set(serviceProperty, "error", false);
+              Em.set(serviceProperty, "errorMessage", '');
+            }
+            // validate property
+            serviceProperty.validate();
+          }
+        })
+      };
+    }
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/2ea32f88/ambari-web/test/controllers/wizard/step7_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js
index 72e2753..0d69d36 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -2107,4 +2107,54 @@ describe('App.InstallerStep7Controller', function () {
 
   });
 
+  describe('#_overrideConfigIsRequired', function () {
+    var controller;
+    beforeEach(function() {
+      controller = App.WizardStep7Controller.create({});
+      var configs = Em.A([
+        App.ServiceConfigProperty.create({ name: 'manage_identities', value: 'true', savedValue: 'true', category: 'KDC', serviceName: 'KERBEROS'}),
+        App.ServiceConfigProperty.create({ name: 'kdc_host', value: '', category: 'KDC', serviceName: 'KERBEROS'}),
+        App.ServiceConfigProperty.create({ name: 'admin_server_host', value: '', category: 'KDC', serviceName: 'KERBEROS'}),
+        App.ServiceConfigProperty.create({ name: 'admin_principal', value: '', category: 'KDC', serviceName: 'KERBEROS'}),
+        App.ServiceConfigProperty.create({ name: 'admin_password', value: '', category: 'KDC', serviceName: 'KERBEROS'})
+      ]);
+      configs.forEach(function(config) {
+        config.validate(); // make isRequired to trigger validation and to set every property's error flag to true
+      });
+      var serviceConfigs = Em.A([
+        App.ServiceConfig.create({
+          'serviceName': 'KERBEROS',
+          'configs': configs
+        })
+      ]);
+      controller.set('stepConfigs', serviceConfigs);
+    });
+
+
+    it('manage_identities = true should warn user that fields are required', function () {
+      controller._overrideConfigIsRequired("KERBEROS");
+
+      var allTrue = true;
+      controller.get('stepConfigs')[0].configs.forEach(function(p) {
+        allTrue = allTrue && !p.error;
+      });
+      // should have error
+      expect(allTrue).to.be.false;
+    });
+
+    it('manage_identities = false should NOT warn user that fields are required', function () {
+      // manage_identities = false
+      Em.set(controller.get('stepConfigs')[0].configs.findProperty('name','manage_identities'), 'savedValue', 'false');
+
+      controller._overrideConfigIsRequired("KERBEROS");
+
+      var allTrue = true;
+      controller.get('stepConfigs')[0].configs.forEach(function(p) {
+        allTrue = allTrue && !p.error;
+      });
+
+      expect(allTrue).to.be.true;
+    });
+  });
+
 });