ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject ambari git commit: AMBARI-19307. UI should validate Ranger user password be more than 8 chars (onechiporenko)
Date Wed, 28 Dec 2016 13:00:59 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 c0f9621f2 -> cf28b98aa


AMBARI-19307. UI should validate Ranger user password be more than 8 chars (onechiporenko)


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

Branch: refs/heads/branch-2.5
Commit: cf28b98aab7522796ecde08051533a8d38f28369
Parents: c0f9621
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Wed Dec 28 12:36:40 2016 +0200
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Wed Dec 28 15:00:51 2016 +0200

----------------------------------------------------------------------
 ambari-web/app/messages.js                      |  1 +
 ambari-web/app/utils/config.js                  |  8 +++++--
 .../objects/service_config_property_test.js     | 25 ++++++++++++++++++++
 3 files changed, 32 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/cf28b98a/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index bb433a2..cd984c5 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -3172,6 +3172,7 @@ Em.I18n.translations = {
   'errorMessage.config.user': 'Value is not valid',
   'errorMessage.config.ldapUrl': 'Must be a valid LDAP url',
   'errorMessage.config.password': 'Passwords do not match',
+  'errorMessage.config.password.length': 'Password should contain at least {0} symbols',
   'errorMessage.config.directory.heterogeneous': 'dir format is wrong, can be "[{storage
type}]/{dir name}"',
   'errorMessage.config.directory.default': 'Must be a slash or drive at the start, and must
not contain white spaces',
   'errorMessage.config.directory.allowed': 'Can\'t start with "home(s)"',

http://git-wip-us.apache.org/repos/asf/ambari/blob/cf28b98a/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index e9c9e24..ffd0e49 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -632,6 +632,11 @@ App.config = Em.Object.create({
         };
       case 'password':
         return function (value, name, retypedPassword) {
+          if (name === 'ranger_admin_password') {
+            if (String(value).length < 9) {
+              return Em.I18n.t('errorMessage.config.password.length').format(9);
+            }
+          }
           return value !== retypedPassword ? Em.I18n.t('errorMessage.config.password') :
'';
         };
       case 'user':
@@ -649,9 +654,8 @@ App.config = Em.Object.create({
           if (['javax.jdo.option.ConnectionURL', 'oozie.service.JPAService.jdbc.url'].contains(name)
             && !validator.isConfigValueLink(value) && validator.isConfigValueLink(value))
{
             return Em.I18n.t('errorMessage.config.spaces.trim');
-          } else {
-            return validator.isNotTrimmedRight(value) ? Em.I18n.t('errorMessage.config.spaces.trailing')
: '';
           }
+          return validator.isNotTrimmedRight(value) ? Em.I18n.t('errorMessage.config.spaces.trailing')
: '';
         };
     }
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/cf28b98a/ambari-web/test/models/configs/objects/service_config_property_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/objects/service_config_property_test.js b/ambari-web/test/models/configs/objects/service_config_property_test.js
index 49613a44..dab133d 100644
--- a/ambari-web/test/models/configs/objects/service_config_property_test.js
+++ b/ambari-web/test/models/configs/objects/service_config_property_test.js
@@ -331,4 +331,29 @@ describe('App.ServiceConfigProperty', function () {
     });
   });
 
+  describe('custom validation for `ranger_admin_password`', function () {
+
+    beforeEach(function () {
+      this.config = App.ServiceConfigProperty.create({
+        name: 'ranger_admin_password',
+        displayType: 'password'
+      });
+    });
+
+    it('value less than 9 symbols is invalid', function () {
+      this.config.set('value', 12345678);
+      this.config.set('retypedPassword', 12345678);
+      expect(this.config.get('isValid')).to.be.false;
+      expect(this.config.get('errorMessage')).to.be.equal(Em.I18n.t('errorMessage.config.password.length').format(9));
+    });
+
+    it('value with 9 symbols is valid', function () {
+      this.config.set('value', 123456789);
+      this.config.set('retypedPassword', 123456789);
+      expect(this.config.get('isValid')).to.be.true;
+      expect(this.config.get('errorMessage')).to.be.equal('');
+    });
+
+  });
+
 });


Mime
View raw message