Changeset 25175
- Timestamp:
- 08/29/2013 10:28:32 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/qunit/wp-admin/js/password-strength-meter.js
r25167 r25175 2 2 module('password-strength-meter'); 3 3 4 test('mis smached passwords should return 5', function(){5 equal( passwordStrength( 'password1', 'username', 'password2' ) , 5, 'mis smatched passwords return 5');4 test('mismatched passwords should return 5', function(){ 5 equal( passwordStrength( 'password1', 'username', 'password2' ) , 5, 'mismatched passwords return 5'); 6 6 }); 7 7 8 test('passwords shorter than 4 charac hters should return 0', function(){8 test('passwords shorter than 4 characters should return 0', function(){ 9 9 equal( passwordStrength( 'abc', 'username', 'abc' ) , 0, 'short passwords return 0'); 10 10 }); … … 12 12 test('long complicated passwords should return 4', function(){ 13 13 var password = function( length ){ 14 var poss ability = 'abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',14 var possibility = 'abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', 15 15 retVal = ""; 16 for ( var i = 0, n = possability.length; i < length; ++i) {17 retVal += poss ability.charAt( Math.floor( Math.random() * n ) );16 for (var i = 0, n = possibility.length; i < length; ++i) { 17 retVal += possibility.charAt( Math.floor( Math.random() * n ) ); 18 18 } 19 19 return retVal + 'aB2'; // add a lower case, uppercase and number just to make sure we always have one of each … … 27 27 var letters = 'aaaa', 28 28 numbers = '1111', 29 29 password = 'password', 30 30 uppercase = 'AAAA'; 31 31 equal( passwordStrength( letters, 'username', letters ), 0, 'password of `' + letters + '` returns 0' ); … … 35 35 }); 36 36 37 test('zxcvbn passward tests should return the score we expect', function(){38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 37 test('zxcvbn password tests should return the score we expect', function(){ 38 var passwords = [ 39 { pw: 'zxcvbn', score: 0}, 40 { pw: 'qwER43@!', score: 1}, 41 { pw: 'Tr0ub4dour&3', score: 2}, 42 { pw: 'correcthorsebatterystaple', score: 4}, 43 { pw: 'coRrecth0rseba++ery9.23.2007staple$', score: 4}, 44 { pw: 'D0g..................', score: 0}, 45 { pw: 'abcdefghijk987654321', score: 0}, 46 { pw: 'neverforget13/3/1997', score: 2}, 47 { pw: '1qaz2wsx3edc', score: 0}, 48 { pw: 'temppass22', score: 1}, 49 { pw: 'briansmith', score: 0}, 50 { pw: 'briansmith4mayor', score: 0}, 51 { pw: 'password1', score: 0}, 52 { pw: 'viking', score: 0}, 53 { pw: 'thx1138', score: 0}, 54 { pw: 'ScoRpi0ns', score: 0}, 55 { pw: 'do you know', score: 0}, 56 { pw: 'ryanhunter2000', score: 0}, 57 { pw: 'rianhunter2000', score: 1}, 58 { pw: 'asdfghju7654rewq', score: 2}, 59 { pw: 'AOEUIDHG&*()LS_', score: 2}, 60 { pw: '12345678', score: 0}, 61 { pw: 'defghi6789', score: 0}, 62 { pw: 'rosebud', score: 0}, 63 { pw: 'Rosebud', score: 0}, 64 { pw: 'ROSEBUD', score: 0}, 65 { pw: 'rosebuD', score: 0}, 66 { pw: 'ros3bud99', score: 0}, 67 { pw: 'r0s3bud99', score: 0}, 68 { pw: 'R0$38uD99', score: 1}, 69 { pw: 'verlineVANDERMARK', score: 1}, 70 { pw: 'eheuczkqyq', score: 4}, 71 { pw: 'rWibMFACxAUGZmxhVncy', score: 4}, 72 { pw: 'Ba9ZyWABu99[BK#6MBgbH88Tofv)vs$w', score: 4} 73 ]; 74 74 75 for(var i=0; i < passwords.length; i++) { 76 equal( passwordStrength( passwords[i].pw, 'username', passwords[i].pw ), passwords[i].score, 'password of `' + passwords[i].pw + '` returns '+passwords[i].score ); 77 } 78 }); 75 for (var i=0; i < passwords.length; i++) { 76 equal( passwordStrength( passwords[i].pw, 'username', passwords[i].pw ), passwords[i].score, 'password of `' + passwords[i].pw + '` returns '+passwords[i].score ); 77 } 78 }); 79 80 test( 'username in password should be penalized', function() { 81 var allowedPasswordScore, penalizedPasswordScore, 82 allowedPassword = 'a[janedoe]4', 83 penalizedPassword = 'a[johndoe]4', 84 username = 'johndoe'; 85 86 allowedPasswordScore = passwordStrength( allowedPassword, username, allowedPassword ); 87 penalizedPasswordScore = passwordStrength( penalizedPassword, username, penalizedPassword ); 88 89 ok( penalizedPasswordScore < allowedPasswordScore, 'Penalized password scored ' + penalizedPasswordScore + '; allowed password scored: ' + allowedPasswordScore ); 90 } ); 79 91 });
Note: See TracChangeset
for help on using the changeset viewer.