diff --git a/resources/static/common/js/validation.js b/resources/static/common/js/validation.js index d49f823719240f0d686f4711406fc7f529b0a821..d64d916cf2748123bbe3ef8bae915e0e5eeec874 100644 --- a/resources/static/common/js/validation.js +++ b/resources/static/common/js/validation.js @@ -61,7 +61,7 @@ BrowserID.Validation = (function() { } function passwordLength(password) { - var valid = password && (password.length >= 8 && password.length <= 80); + var valid = password && (password.length >= bid.PASSWORD_MIN_LENGTH && password.length <= bid.PASSWORD_MAX_LENGTH); if(!valid) { tooltip.showTooltip("#password_length"); diff --git a/resources/static/pages/js/manage_account.js b/resources/static/pages/js/manage_account.js index 2e650f6a16e9297d2b7fa08a9a681eb45487ac92..0ff49a7d14c8e23adbde50bf902c20526ff81989 100644 --- a/resources/static/pages/js/manage_account.js +++ b/resources/static/pages/js/manage_account.js @@ -147,7 +147,7 @@ BrowserID.manageAccount = (function() { tooltip.showTooltip("#tooltipPasswordsSame"); complete(false); } - else if(newPassword.length < 8 || 80 < newPassword.length) { + else if(newPassword.length < bid.PASSWORD_MIN_LENGTH || bid.PASSWORD_MAX_LENGTH < newPassword.length) { tooltip.showTooltip("#tooltipPasswordLength"); complete(false); } diff --git a/resources/static/test/cases/common/js/validation.js b/resources/static/test/cases/common/js/validation.js index 228c61fc38d7cb7c61b18f4787d4bdddb7ac57d3..271d6b5285c3bd20347628ae17f47354f75ed95b 100644 --- a/resources/static/test/cases/common/js/validation.js +++ b/resources/static/test/cases/common/js/validation.js @@ -8,6 +8,7 @@ var bid = BrowserID, validation = bid.Validation, + testHelpers = bid.TestHelpers, tooltipShown, origShowTooltip; @@ -205,21 +206,19 @@ test("passwordAndValidationPassword with too short password", function() { - var valid = validation.passwordAndValidationPassword("pass", "password"); + var tooShort = testHelpers.generateString(bid.PASSWORD_MIN_LENGTH - 1); + var valid = validation.passwordAndValidationPassword(tooShort, tooShort); equal(valid, false, "too short password is invalid"); equal(tooltipShown, true, "too short password shows tooltip"); }); test("passwordAndValidationPassword with too long password", function() { - var tooLong = ""; - for(var i = 0; i < 81; i++) { - tooLong += (i % 10); - } + var tooLong = testHelpers.generateString(bid.PASSWORD_MAX_LENGTH + 1); var valid = validation.passwordAndValidationPassword(tooLong, tooLong); - equal(valid, false, "too short password is invalid"); - equal(tooltipShown, true, "too short password shows tooltip"); + equal(valid, false, "too long password is invalid"); + equal(tooltipShown, true, "too long password shows tooltip"); }); test("passwordAndValidationPassword with empty validation password", function() { diff --git a/resources/static/test/cases/pages/js/forgot.js b/resources/static/test/cases/pages/js/forgot.js index 67746a327b96ea7296f790c9af9c4ff0ed51e8b3..d6179186f4f6b1eb5cf421e2ad56e4d6ec12e09b 100644 --- a/resources/static/test/cases/pages/js/forgot.js +++ b/resources/static/test/cases/pages/js/forgot.js @@ -72,14 +72,14 @@ asyncTest("requestPasswordReset with too short of a password", function() { $("#email").val("unregistered@testuser.com"); - $("#password,#vpassword").val("fail"); + $("#password,#vpassword").val(testHelpers.generateString(bid.PASSWORD_MIN_LENGTH - 1)); testEmailNotSent(); }); asyncTest("requestPasswordReset with too long of a password", function() { $("#email").val("unregistered@testuser.com"); - $("#password,#vpassword").val(testHelpers.generateString(81)); + $("#password,#vpassword").val(testHelpers.generateString(bid.PASSWORD_MAX_LENGTH + 1)); testEmailNotSent(); }); diff --git a/resources/static/test/cases/pages/js/manage_account.js b/resources/static/test/cases/pages/js/manage_account.js index a7c5518668640fcadd735a2b3d204e258bbfd654..61b83965746fc475bc596ec0f38b158ccd898930 100644 --- a/resources/static/test/cases/pages/js/manage_account.js +++ b/resources/static/test/cases/pages/js/manage_account.js @@ -96,7 +96,7 @@ }); }); }); - + asyncTest("removeEmail doesn't cancel the account when removing a non-existent e-mail", function() { bid.manageAccount(mocks, function() { bid.manageAccount.removeEmail("non@existent.com", function() { @@ -105,7 +105,7 @@ }); }); }); - + asyncTest("removeEmail doesn't cancel the account when out of sync with the server", function() { bid.manageAccount(mocks, function() { xhr.useResult("multiple"); @@ -206,7 +206,7 @@ asyncTest("changePassword with too short of a password - tooltip", function() { bid.manageAccount(mocks, function() { $("#old_password").val("oldpassword"); - $("#new_password").val("pass"); + $("#new_password").val(testHelpers.generateString(bid.PASSWORD_MIN_LENGTH - 1)); bid.manageAccount.changePassword(function(status) { equal(status, false, "on too short of a password, status is false"); @@ -219,7 +219,7 @@ asyncTest("changePassword with too long of a password - tooltip", function() { bid.manageAccount(mocks, function() { $("#old_password").val("oldpassword"); - $("#new_password").val(testHelpers.generateString(81)); + $("#new_password").val(testHelpers.generateString(bid.PASSWORD_MAX_LENGTH + 1)); bid.manageAccount.changePassword(function(status) { equal(status, false, "on too long of a password, status is false");