ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject [1/2] ambari git commit: AMBARI-11803. Kerberos: attempting to add service includes warning about admin creds (alexantonenko)
Date Tue, 09 Jun 2015 20:02:20 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 8461ff2e1 -> b94ba75e1


AMBARI-11803. Kerberos: attempting to add service includes warning about admin creds (alexantonenko)


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

Branch: refs/heads/branch-2.1
Commit: b94ba75e1ab58b2bd617ca3168fa8cc5d35a3877
Parents: 8336378
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Tue Jun 9 19:43:26 2015 +0300
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Tue Jun 9 23:02:15 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/assets/test/tests.js             |  1 +
 .../main/admin/kerberos/step4_controller.js     |  5 +-
 .../app/controllers/wizard/step7_controller.js  | 42 +-----------
 ambari-web/app/mixins.js                        |  1 +
 .../mixins/common/configs/toggle_isrequired.js  | 59 +++++++++++++++++
 .../test/controllers/wizard/step7_test.js       | 51 ---------------
 .../common/configs/toggle_isrequired_test.js    | 68 ++++++++++++++++++++
 7 files changed, 135 insertions(+), 92 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b94ba75e/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index e86647b..04903e6 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -135,6 +135,7 @@ var files = ['test/init_model_test',
   'test/mappers/configs/themes_mapper_test',
   'test/mixins/common/configs/enhanced_configs_test',
   'test/mixins/common/configs/configs_saver_test',
+  'test/mixins/common/configs/toggle_isrequired_test',
   'test/mixins/common/chart/storm_linear_time_test',
   'test/mixins/common/widgets/widget_section_test',
   'test/mixins/common/localStorage_test',

http://git-wip-us.apache.org/repos/asf/ambari/blob/b94ba75e/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js b/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js
index 32f1601..f5f232f 100644
--- a/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js
+++ b/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js
@@ -19,7 +19,7 @@
 var App = require('app');
 require('controllers/wizard/step7_controller');
 
-App.KerberosWizardStep4Controller = App.WizardStep7Controller.extend(App.AddSecurityConfigs,
{
+App.KerberosWizardStep4Controller = App.WizardStep7Controller.extend(App.AddSecurityConfigs,
App.ToggleIsRequiredMixin, {
   name: 'kerberosWizardStep4Controller',
 
   adminPropertyNames: [{name: 'admin_principal', displayName: 'Admin principal'}, {name:
'admin_password', displayName: 'Admin password'}],
@@ -40,6 +40,9 @@ App.KerberosWizardStep4Controller = App.WizardStep7Controller.extend(App.AddSecu
     this.getDescriptorConfigs().then(function(properties) {
       self.setStepConfigs(properties);
       self.set('isRecommendedLoaded', true);
+      self.get('stepConfigs').forEach(function(service) {
+        self.overrideConfigIsRequired(service);
+      })
     });
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/b94ba75e/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 c74bba2..fdc11c7 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -27,7 +27,7 @@ var App = require('app');
  *
  */
 
-App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.EnhancedConfigsMixin,
{
+App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.EnhancedConfigsMixin,
App.ToggleIsRequiredMixin, {
 
   name: 'wizardStep7Controller',
 
@@ -444,7 +444,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
     service.set('selectedConfigGroup', this.get('preSelectedConfigGroup'));
     this.loadComponentConfigs(service.get('configs'), serviceConfig, service);
     // override if a property isRequired or not
-    this._overrideConfigIsRequired(serviceName);
+    this.overrideConfigIsRequired(service);
     service.set('configs', serviceConfig.get('configs'));
   },
 
@@ -1445,43 +1445,5 @@ 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/b94ba75e/ambari-web/app/mixins.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins.js b/ambari-web/app/mixins.js
index 2ff5de8..838ace5 100644
--- a/ambari-web/app/mixins.js
+++ b/ambari-web/app/mixins.js
@@ -45,6 +45,7 @@ require('mixins/wizard/wizard_menu_view');
 require('mixins/wizard/assign_master_components');
 require('mixins/common/configs/enhanced_configs');
 require('mixins/common/configs/configs_saver');
+require('mixins/common/configs/toggle_isrequired');
 require('mixins/common/widgets/widget_mixin');
 require('mixins/common/widgets/widget_section');
 require('mixins/unit_convert/base_unit_convert_mixin');

http://git-wip-us.apache.org/repos/asf/ambari/blob/b94ba75e/ambari-web/app/mixins/common/configs/toggle_isrequired.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/configs/toggle_isrequired.js b/ambari-web/app/mixins/common/configs/toggle_isrequired.js
new file mode 100644
index 0000000..85d8f1d
--- /dev/null
+++ b/ambari-web/app/mixins/common/configs/toggle_isrequired.js
@@ -0,0 +1,59 @@
+/**
+ * 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');
+
+App.ToggleIsRequiredMixin = Em.Mixin.create({
+  /**
+   * Override isRequired property of the configurations in given situation
+   * @param serviceName - make changes only for properties from this service
+   */
+  overrideConfigIsRequired: function (serviceConfigs) {
+    var excludeProperties = [
+      {
+        name: 'KERBEROS',                                                               
// affected service
+        exclude: ['kdc_host', 'admin_server_host', 'admin_principal', 'admin_password'] //
affected properties
+      },
+      {
+        name: 'KERBEROS_GENERAL',                                                       
        // affected service
+        exclude: ['kdc_host', 'admin_server_host', 'admin_principal', 'admin_password'] //
affected properties
+      }
+    ];
+    var serviceName = serviceConfigs.get('serviceName'),
+      service = excludeProperties.findProperty('name', serviceName),
+      configs = serviceConfigs.get('configs');
+
+    if (service && !Em.isEmpty(configs)) {
+      service.exclude.forEach(function (property) {
+        var serviceProperty = configs.findProperty('name', property);
+        if (serviceProperty) {
+          var value = serviceProperty.get('isRequired');
+          Em.set(serviceProperty, "isRequired", !value);
+          if (value && 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();
+        }
+      });
+    }
+  }
+
+})
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/b94ba75e/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 0d69d36..64c3e70 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -2106,55 +2106,4 @@ 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;
-    });
-  });
-
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/b94ba75e/ambari-web/test/mixins/common/configs/toggle_isrequired_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/configs/toggle_isrequired_test.js b/ambari-web/test/mixins/common/configs/toggle_isrequired_test.js
new file mode 100644
index 0000000..c4bdd23
--- /dev/null
+++ b/ambari-web/test/mixins/common/configs/toggle_isrequired_test.js
@@ -0,0 +1,68 @@
+/**
+ * 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('#_overrideConfigIsRequired', function () {
+  var controller,
+    instanceObject,
+    configs,
+    serviceConfig;
+
+  beforeEach(function() {
+    var mixinObject = Em.Controller.extend(App.ToggleIsRequiredMixin, {});
+
+    instanceObject = mixinObject.create({});
+
+    configs = Em.A([
+      App.ServiceConfigProperty.create({ name: 'kdc_host', value: '', category: 'KDC', serviceName:
'KERBEROS', isRequired: true}),
+      App.ServiceConfigProperty.create({ name: 'admin_server_host', value: '', category:
'KDC', serviceName: 'KERBEROS', isRequired: true}),
+      App.ServiceConfigProperty.create({ name: 'admin_principal', value: '', category: 'KDC',
serviceName: 'KERBEROS', isRequired: true}),
+      App.ServiceConfigProperty.create({ name: 'admin_password', value: '', category: 'KDC',
serviceName: 'KERBEROS', isRequired: true})
+    ]);
+
+    configs.forEach(function(config) {
+      config.validate(); // make isRequired to trigger validation and to set every property's
error flag to true
+    });
+    serviceConfig = App.ServiceConfig.create({
+      'serviceName': 'KERBEROS',
+      'configs': configs
+    });
+
+  });
+
+  it('should make isRequired = false for kerberos properties', function () {
+    instanceObject.overrideConfigIsRequired(serviceConfig);
+    // toggle isRequired to false
+    configs.forEach(function(p) {
+      expect(p.isRequired).to.be.false;
+      expect(p.error).to.be.false;
+    });
+  });
+
+  it('should make isRequired = true for kerberos properties', function () {
+    // toggle to false
+    instanceObject.overrideConfigIsRequired(serviceConfig);
+    // toggle to true
+    instanceObject.overrideConfigIsRequired(serviceConfig);
+
+    configs.forEach(function(p) {
+      expect(p.isRequired).to.be.true;
+    });
+  });
+});
\ No newline at end of file


Mime
View raw message