AMBARI-8200 Add Service wizard: Custom properties with empty values should not 
be be marked erroneous. (Buzhor Denys via ababiichuk)


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

Branch: refs/heads/trunk
Commit: b67ddc7c1fb94a13a2c10bb899d33f7cb5d86e44
Parents: a59bbb2
Author: aBabiichuk <ababiic...@cybervisiontech.com>
Authored: Fri Nov 7 14:49:18 2014 +0200
Committer: aBabiichuk <ababiic...@cybervisiontech.com>
Committed: Fri Nov 7 14:49:18 2014 +0200

----------------------------------------------------------------------
 .../app/controllers/wizard/step7_controller.js  | 34 ++++++++++++++++--
 ambari-web/app/data/HDP2/secure_mapping.js      |  3 +-
 .../test/controllers/wizard/step7_test.js       | 38 ++++++++++++++++++--
 3 files changed, 70 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b67ddc7c/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 28e9a87..f840ad1 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -51,7 +51,13 @@ App.WizardStep7Controller = 
Em.Controller.extend(App.ServerValidatorMixin, {
   /**
    * used in services_config.js view to mark a config with security icon
    */
-  secureConfigs: require('data/secure_mapping'),
+  secureConfigs: function() {
+    if (App.get('isHadoop2Stack')) {
+      return require('data/HDP2/secure_mapping');
+    } else {
+      return require('data/secure_mapping');
+    }
+  }.property('isHadoop2Stack'),
 
   /**
    * config categories with secure properties
@@ -818,7 +824,12 @@ App.WizardStep7Controller = 
Em.Controller.extend(App.ServerValidatorMixin, {
           this.addSecureConfigs(selectedService, serviceName) ;
         }
       }, this);
-
+      this.get('installedServiceNames').forEach(function(serviceName) {
+        var serviceConfigObj = serviceConfigs.findProperty('serviceName', 
serviceName);
+        if (this.get('securityEnabled')) {
+          this.setSecureConfigs(serviceConfigObj, serviceName);
+        }
+      }, this);
       // Remove SNameNode if HA is enabled
       if (App.get('isHaEnabled')) {
         var c = serviceConfigs.findProperty('serviceName', 'HDFS').configs;
@@ -834,6 +845,25 @@ App.WizardStep7Controller = 
Em.Controller.extend(App.ServerValidatorMixin, {
   },
 
   /**
+   * Set secure properties for installed services. Mark secure properties and 
+   * properties with default empty value as non required to pass validation.
+   *
+   * @param {Em.Object} serviceConfigObj
+   * @param {String} serviceName
+   */
+  setSecureConfigs: function(serviceConfigObj, serviceName) {
+    var configProperties = serviceConfigObj.get('configs');
+    if (!configProperties) return;
+    var secureConfigs = 
this.get('secureConfigs').filterProperty('serviceName', serviceName);
+    secureConfigs.forEach(function(secureConfig) {
+      var property = configProperties.findProperty('name', secureConfig.name);
+      if (property) {
+        property.set('isRequired', secureConfig.value != "");
+        if (!property.get('isRequired')) property.set('errorMessage', '');
+      }
+    });
+  },
+  /**
    *
    * @param selectedService
    * @param serviceName

http://git-wip-us.apache.org/repos/asf/ambari/blob/b67ddc7c/ambari-web/app/data/HDP2/secure_mapping.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/HDP2/secure_mapping.js 
b/ambari-web/app/data/HDP2/secure_mapping.js
index 6299bce..f4a17d9 100644
--- a/ambari-web/app/data/HDP2/secure_mapping.js
+++ b/ambari-web/app/data/HDP2/secure_mapping.js
@@ -16,6 +16,7 @@
  * limitations under the License.
  */
 
+var App = require('app');
 // All of the "name" properties have to coincide with how they will appear in 
the *-site.xml file
 // The "template" properties can come from the config properties in 
site_properties.js or secure_properties.js .
 var props = [
@@ -921,7 +922,7 @@ var yarn22Mapping = [
     "value": "",
     "templateName": [],
     "foreignKey": null,
-    "serviceName": "YARN",
+    "serviceName": "HDFS",
     "filename": "core-site.xml"
   },
   {

http://git-wip-us.apache.org/repos/asf/ambari/blob/b67ddc7c/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 c752bc0..4b100af 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -333,7 +333,7 @@ describe('App.InstallerStep7Controller', function () {
     it('should set property to false', function () {
       var allSelectedServiceNames = ['YARN'],
         configs = [
-          {name: 'hadoop.registry.rm.enabled', value: true, defaultValue: 
true},
+          {name: 'hadoop.registry.rm.enabled', value: true, defaultValue: true}
         ],
         expected = [
           {name: 'hadoop.registry.rm.enabled', value: false, defaultValue: 
false, forceUpdate: true}
@@ -346,7 +346,7 @@ describe('App.InstallerStep7Controller', function () {
     it('should skip setting property', function () {
       var allSelectedServiceNames = ['YARN', 'SLIDER'],
         configs = [
-          {name: 'hadoop.registry.rm.enabled', value: true, defaultValue: 
true},
+          {name: 'hadoop.registry.rm.enabled', value: true, defaultValue: true}
         ],
         expected = [
           {name: 'hadoop.registry.rm.enabled', value: true, defaultValue: true}
@@ -1238,4 +1238,38 @@ describe('App.InstallerStep7Controller', function () {
 
   });
 
+  describe('#setSecureConfigs', function() {
+    var serviceConfigObj = Em.Object.create({
+      serviceName: 'HDFS',
+      configs: [
+        Em.Object.create({ name: 
'hadoop.http.authentication.signature.secret.file' }),
+        Em.Object.create({ name: 'hadoop.security.authentication' })
+      ]
+    });
+    var tests = [
+      { name: 'hadoop.http.authentication.signature.secret.file', e: false },
+      { name: 'hadoop.security.authentication', e: true }
+    ];
+
+    sinon.stub(App, 'get', function(key) {
+      if (['isHadoop22Stack', 'isHadoop2Stack'].contains(key)) return true;
+      else App.get(key);
+    });
+    var controller = App.WizardStep7Controller.create({});
+    controller.get('secureConfigs').pushObjects([
+      {
+        name: 'hadoop.http.authentication.signature.secret.file',
+        serviceName: 'HDFS',
+        value: ''
+      }
+    ]);
+    controller.setSecureConfigs(serviceConfigObj, 'HDFS');
+    App.get.restore();
+    tests.forEach(function(test) {
+      it('{0} is {1}required'.format(test.name, !!test.e ? '' : 'non ' ), 
function() {
+        expect(serviceConfigObj.get('configs').findProperty('name', 
test.name).get('isRequired')).to.eql(test.e);
+      });
+    });
+  });
+
 });

Reply via email to