Repository: ambari
Updated Branches:
  refs/heads/trunk c0bbddb2d -> ec9684763


AMBARI-11020 UI does not mask password fields with default value. (ababiichuk)


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

Branch: refs/heads/trunk
Commit: ec9684763a516f8c3f13a00228071ae4e4ef6a62
Parents: c0bbddb
Author: aBabiichuk <ababiic...@cybervisiontech.com>
Authored: Fri May 8 13:51:30 2015 +0300
Committer: aBabiichuk <ababiic...@cybervisiontech.com>
Committed: Fri May 8 14:55:15 2015 +0300

----------------------------------------------------------------------
 .../configs/stack_config_properties_mapper.js   | 21 ++--------
 .../stack_config_properties_mapper_test.js      | 43 ++++++++++++++++++--
 2 files changed, 44 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ec968476/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/configs/stack_config_properties_mapper.js 
b/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
index 16d0abb..3d24df8 100644
--- a/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
+++ b/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
@@ -61,7 +61,7 @@ App.stackConfigPropertiesMapper = App.QuickDataMapper.create({
               config.StackConfigurations.property_depended_by.push({
                 type : dep.StackConfigurationDependency.dependency_type,
                 name : dep.StackConfigurationDependency.dependency_name
-              })
+              });
             });
           }
           /**
@@ -81,20 +81,6 @@ App.stackConfigPropertiesMapper = 
App.QuickDataMapper.create({
   /******************* METHODS TO MERGE STACK PROPERTIES WITH STORED ON UI 
(NOT USED FOR NOW)*********************************/
 
   /**
-   * configs that are stored on UI
-   * @type {Object[]};
-   */
-  preDefinedSiteProperties: function () {
-    if (App.get('isHadoop23Stack')) {
-      return require('data/HDP2.3/site_properties').configProperties;
-    }
-    if (App.get('isHadoop22Stack')) {
-      return require('data/HDP2.2/site_properties').configProperties;
-    }
-    return require('data/HDP2/site_properties').configProperties;
-  }.property('App.isHadoop22Stack', 'App.isHadoop23Stack'),
-
-  /**
    * find UI config with current name and fileName
    * if there is such property - adds some info to config object
    * @param {Object} config
@@ -102,11 +88,12 @@ App.stackConfigPropertiesMapper = 
App.QuickDataMapper.create({
    */
   mergeWithUI: function(config) {
     var uiConfigProperty = 
this.getUIConfig(config.StackConfigurations.property_name, 
config.StackConfigurations.type);
+    var displayType = 
App.permit(App.config.advancedConfigIdentityData(config.StackConfigurations), 
'displayType').displayType || 'string';
     if (!config.StackConfigurations.property_display_name) {
       config.StackConfigurations.property_display_name = uiConfigProperty && 
uiConfigProperty.displayName ? uiConfigProperty.displayName : 
config.StackConfigurations.property_name;
     }
     config.category = uiConfigProperty ? uiConfigProperty.category : 'Advanced 
' + App.config.getConfigTagFromFileName(config.StackConfigurations.type);
-    config.display_type = uiConfigProperty ? uiConfigProperty.displayType : 
'string';
+    config.display_type = uiConfigProperty ? uiConfigProperty.displayType || 
displayType : displayType;
   },
 
   /**
@@ -118,6 +105,6 @@ App.stackConfigPropertiesMapper = 
App.QuickDataMapper.create({
    * @method getUIConfig
    */
   getUIConfig: function(propertyName, siteName) {
-    return this.get('preDefinedSiteProperties').filterProperty('filename', 
siteName).findProperty('name', propertyName);
+    return 
App.config.get('preDefinedSiteProperties').filterProperty('filename', 
siteName).findProperty('name', propertyName);
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/ec968476/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js 
b/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js
index 2a1aa4b..416a14f 100644
--- a/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js
+++ b/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js
@@ -120,6 +120,34 @@ describe('App.stackConfigPropertiesMapper', function () {
               "stack_version" : "2.2",
               "type" : "site3.xml"
             }
+          },
+          {
+            "StackConfigurations" : {
+              "final" : "false",
+              "property_description" : "desc4",
+              "property_name" : "p4",
+              "property_display_name" : "P4",
+              "property_type" : [ "PASSWORD" ],
+              "property_value" : "v4",
+              "service_name" : "s2",
+              "stack_name" : "HDP",
+              "stack_version" : "2.2",
+              "type" : "site3.xml"
+            }
+          },
+          {
+            "StackConfigurations" : {
+              "final" : "false",
+              "property_description" : "desc5",
+              "property_name" : "p5",
+              "property_display_name" : "P5",
+              "property_type" : [ "USER" ],
+              "property_value" : "v4",
+              "service_name" : "s2",
+              "stack_name" : "HDP",
+              "stack_version" : "2.2",
+              "type" : "site3.xml"
+            }
           }
         ]
       }
@@ -140,8 +168,8 @@ describe('App.stackConfigPropertiesMapper', function () {
 
     it('should load data to model', function() {
       App.stackConfigPropertiesMapper.map(json);
-      expect(App.StackConfigProperty.find().get('length')).to.equal(3);
-      
expect(App.StackConfigProperty.find().mapProperty('id')).to.eql(['p1_site1','p2_site2','p3_site3']);
+      expect(App.StackConfigProperty.find().get('length')).to.equal(5);
+      
expect(App.StackConfigProperty.find().mapProperty('id')).to.eql(['p1_site1','p2_site2','p3_site3',
 'p4_site3', 'p5_site3']);
 
       
expect(App.StackConfigProperty.find('p1_site1').get('name')).to.eql('p1');
       
expect(App.StackConfigProperty.find('p1_site1').get('displayName')).to.eql('P1');
@@ -151,7 +179,7 @@ describe('App.stackConfigPropertiesMapper', function () {
       
expect(App.StackConfigProperty.find('p1_site1').get('serviceName')).to.eql('s1');
       
expect(App.StackConfigProperty.find('p1_site1').get('stackName')).to.eql('HDP');
       
expect(App.StackConfigProperty.find('p1_site1').get('stackVersion')).to.eql('2.2');
-      expect(App.StackConfigProperty.find('p1_site1').get('type')).to.eql([]);
+      
expect(App.StackConfigProperty.find('p1_site1').get('type').toArray()).to.eql([]);
       
expect(App.StackConfigProperty.find('p1_site1').get('fileName')).to.eql('site1.xml');
       
expect(App.StackConfigProperty.find('p1_site1').get('propertyDependedBy')).to.eql([
         {
@@ -167,6 +195,15 @@ describe('App.stackConfigPropertiesMapper', function () {
       });
       
expect(App.StackConfigProperty.find('p1_site1').get('supportsFinal')).to.be.true;
     });
+
+    it('should set "displayType" by "property_type" attribute', function() {
+      App.stackConfigPropertiesMapper.map(json);
+      var prop = App.StackConfigProperty.find().findProperty('name', 'p4');
+      var prop2 = App.StackConfigProperty.find().findProperty('name', 'p5');
+      expect(prop).to.be.ok;
+      expect(prop.get('displayType')).to.be.eql('password');
+      expect(prop2.get('displayType')).to.be.eql('user');
+    });
   });
 
 });

Reply via email to