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:02:06 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk e423a65e5 -> 1bfffc0c8


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/1bfffc0c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1bfffc0c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1bfffc0c

Branch: refs/heads/trunk
Commit: 1bfffc0c8f231b583dc259c4d4e3fd91079aec0b
Parents: e423a65
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 12:36:40 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/1bfffc0c/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index e9d117a..a1b67e5 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -3206,6 +3206,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/1bfffc0c/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index cd09e14..d0dbb69 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -615,6 +615,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':
@@ -632,9 +637,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/1bfffc0c/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 ef0bd61..728141b 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
@@ -322,4 +322,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