Ticket #25088: 25088-spacing-braces.patch
File 25088-spacing-braces.patch, 6.0 KB (added by , 11 years ago) |
---|
-
tests/qunit/wp-admin/js/password-strength-meter.js
1 jQuery( function() {2 module( 'password-strength-meter');1 jQuery( function() { 2 module( 'password-strength-meter' ); 3 3 4 test( 'mismatched passwords should return 5', function(){5 equal( passwordStrength( 'password1', 'username', 'password2' ) , 5, 'mismatched 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 characters should return 0', function(){9 equal( passwordStrength( 'abc', 'username', 'abc' ) , 0, 'short passwords return 0');8 test( 'passwords shorter than 4 characters should return 0', function() { 9 equal( passwordStrength( 'abc', 'username', 'abc' ), 0, 'short passwords return 0' ); 10 10 }); 11 11 12 test( 'long complicated passwords should return 4', function(){13 var password = function( length ) {12 test( 'long complicated passwords should return 4', function() { 13 var password = function( length ) { 14 14 var possibility = 'abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', 15 retVal = "";16 for ( var i = 0, n = possibility.length; i < length; ++i) {15 retVal = ''; 16 for ( var i = 0, n = possibility.length; i < length; i++ ) { 17 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 20 20 }, 21 21 twofifty = password( 250 ); 22 22 23 equal( passwordStrength( twofifty , 'username', twofifty ), 4, '250 charachter complicated password returns 4');23 equal( passwordStrength( twofifty, 'username', twofifty ), 4, '250 character complicated password returns 4' ); 24 24 }); 25 25 26 test( 'short uncomplicated passwords should return 0', function(){26 test( 'short uncomplicated passwords should return 0', function() { 27 27 var letters = 'aaaa', 28 28 numbers = '1111', 29 29 password = 'password', … … 32 32 equal( passwordStrength( numbers, 'username', numbers ), 0, 'password of `' + numbers + '` returns 0' ); 33 33 equal( passwordStrength( uppercase, 'username', uppercase ), 0, 'password of `' + uppercase + '` returns 0' ); 34 34 equal( passwordStrength( password, 'username', password ), 0, 'password of `' + password + '` returns 0' ); 35 }); 35 }); 36 36 37 test( 'zxcvbn password tests should return the score we expect', function(){37 test( 'zxcvbn password tests should return the score we expect', function() { 38 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 }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 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 );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 77 } 78 78 }); 79 79 … … 87 87 penalizedPasswordScore = passwordStrength( penalizedPassword, username, penalizedPassword ); 88 88 89 89 ok( penalizedPasswordScore < allowedPasswordScore, 'Penalized password scored ' + penalizedPasswordScore + '; allowed password scored: ' + allowedPasswordScore ); 90 } 90 }); 91 91 });