2013-10-30 15:38:37 +01:00
/* global passwordStrength, wp, jQuery */
2013-09-06 12:56:01 +02:00
jQuery ( function ( ) {
2020-03-27 01:16:58 +01:00
QUnit . module ( 'password-strength-meter' ) ;
2013-08-29 20:44:36 +02:00
2020-03-27 01:16:58 +01:00
QUnit . test ( 'mismatched passwords should return 5' , function ( assert ) {
assert . equal ( passwordStrength ( 'password1' , 'username' , 'password2' ) , 5 , 'mismatched passwords return 5' ) ;
2013-08-29 20:44:36 +02:00
} ) ;
2020-03-27 01:16:58 +01:00
QUnit . test ( 'passwords shorter than 4 characters should return 0' , function ( assert ) {
assert . equal ( passwordStrength ( 'abc' , 'username' , 'abc' ) , 0 , 'short passwords return 0' ) ;
2013-08-29 20:44:36 +02:00
} ) ;
2020-03-27 01:16:58 +01:00
QUnit . test ( 'long complicated passwords should return 4' , function ( assert ) {
2013-09-06 12:56:01 +02:00
var password = function ( length ) {
2013-11-07 21:40:12 +01:00
var i , n , retVal = '' ,
possibility = 'abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' ;
for ( i = 0 , n = possibility . length ; i < length ; i ++ ) {
2013-08-30 00:28:32 +02:00
retVal += possibility . charAt ( Math . floor ( Math . random ( ) * n ) ) ;
2013-08-29 20:44:36 +02:00
}
2020-01-29 01:43:23 +01:00
return retVal + 'aB2' ; // Add a lower case, uppercase and number just to make sure we always have one of each.
2013-08-29 20:44:36 +02:00
} ,
twofifty = password ( 250 ) ;
2020-03-27 01:16:58 +01:00
assert . equal ( passwordStrength ( twofifty , 'username' , twofifty ) , 4 , '250 character complicated password returns 4' ) ;
2013-08-29 20:44:36 +02:00
} ) ;
2020-03-27 01:16:58 +01:00
QUnit . test ( 'short uncomplicated passwords should return 0' , function ( assert ) {
2013-08-29 20:44:36 +02:00
var letters = 'aaaa' ,
numbers = '1111' ,
2013-08-30 00:28:32 +02:00
password = 'password' ,
2013-08-29 20:44:36 +02:00
uppercase = 'AAAA' ;
2020-03-27 01:16:58 +01:00
assert . equal ( passwordStrength ( letters , 'username' , letters ) , 0 , 'password of `' + letters + '` returns 0' ) ;
assert . equal ( passwordStrength ( numbers , 'username' , numbers ) , 0 , 'password of `' + numbers + '` returns 0' ) ;
assert . equal ( passwordStrength ( uppercase , 'username' , uppercase ) , 0 , 'password of `' + uppercase + '` returns 0' ) ;
assert . equal ( passwordStrength ( password , 'username' , password ) , 0 , 'password of `' + password + '` returns 0' ) ;
2013-09-06 12:56:01 +02:00
} ) ;
2013-08-29 20:44:36 +02:00
2020-03-27 01:16:58 +01:00
QUnit . test ( 'zxcvbn password tests should return the score we expect' , function ( assert ) {
2013-11-07 21:40:12 +01:00
var passwords , i ;
passwords = [
2013-09-06 12:56:01 +02:00
{ pw : 'zxcvbn' , score : 0 } ,
2016-12-13 12:22:28 +01:00
{ pw : 'qwER43@!' , score : 2 } ,
2013-09-06 12:56:01 +02:00
{ pw : 'Tr0ub4dour&3' , score : 2 } ,
{ pw : 'correcthorsebatterystaple' , score : 4 } ,
{ pw : 'coRrecth0rseba++ery9.23.2007staple$' , score : 4 } ,
2016-12-13 12:22:28 +01:00
{ pw : 'D0g..................' , score : 1 } ,
{ pw : 'abcdefghijk987654321' , score : 1 } ,
{ pw : 'neverforget13/3/1997' , score : 3 } ,
2013-09-06 12:56:01 +02:00
{ pw : '1qaz2wsx3edc' , score : 0 } ,
{ pw : 'temppass22' , score : 1 } ,
2016-12-13 12:22:28 +01:00
{ pw : 'briansmith' , score : 1 } ,
{ pw : 'briansmith4mayor' , score : 4 } ,
2013-09-06 12:56:01 +02:00
{ pw : 'password1' , score : 0 } ,
{ pw : 'viking' , score : 0 } ,
{ pw : 'thx1138' , score : 0 } ,
2016-12-13 12:22:28 +01:00
{ pw : 'ScoRpi0ns' , score : 1 } ,
{ pw : 'do you know' , score : 3 } ,
{ pw : 'ryanhunter2000' , score : 3 } ,
{ pw : 'rianhunter2000' , score : 3 } ,
{ pw : 'asdfghju7654rewq' , score : 3 } ,
{ pw : 'AOEUIDHG&*()LS_' , score : 3 } ,
2013-09-06 12:56:01 +02:00
{ pw : '12345678' , score : 0 } ,
2016-12-13 12:22:28 +01:00
{ pw : 'defghi6789' , score : 1 } ,
2013-09-06 12:56:01 +02:00
{ pw : 'rosebud' , score : 0 } ,
{ pw : 'Rosebud' , score : 0 } ,
{ pw : 'ROSEBUD' , score : 0 } ,
{ pw : 'rosebuD' , score : 0 } ,
2016-12-13 12:22:28 +01:00
{ pw : 'ros3bud99' , score : 1 } ,
{ pw : 'r0s3bud99' , score : 1 } ,
{ pw : 'R0$38uD99' , score : 2 } ,
{ pw : 'verlineVANDERMARK' , score : 4 } ,
{ pw : 'eheuczkqyq' , score : 3 } ,
2013-09-06 12:56:01 +02:00
{ pw : 'rWibMFACxAUGZmxhVncy' , score : 4 } ,
2016-12-13 12:22:28 +01:00
{ pw : 'Ba9ZyWABu99[BK#6MBgbH88Tofv)vs$w' , score : 4 } ,
{ pw : 'foo foo foo foo' , score : 2 }
2013-08-30 00:28:32 +02:00
] ;
2013-08-29 20:44:36 +02:00
2013-11-07 21:40:12 +01:00
for ( i = 0 ; i < passwords . length ; i ++ ) {
2020-03-27 01:16:58 +01:00
assert . equal ( passwordStrength ( passwords [ i ] . pw , 'username' , passwords [ i ] . pw ) , passwords [ i ] . score , 'password of `' + passwords [ i ] . pw + '` returns ' + passwords [ i ] . score ) ;
2013-08-30 00:28:32 +02:00
}
} ) ;
General: Remove “whitelist” and “blacklist” in favor of more clear and inclusive language.
“The WordPress open source community cares about diversity. We strive to maintain a welcoming environment where everyone can feel included.”
With this commit, all occurrences of “whitelist” and “blacklist” (with the single exception of the `$new_whitelist_options` global variable) are removed. A new ticket has been opened to explore renaming the `$new_whitelist_options` variable (#50434).
Changing to more specific names or rewording sentences containing these terms not only makes the code more inclusive, but also helps provide clarity. These terms are often ambiguous. What is being blocked or allowed is not always immediately clear. This can make it more difficult for non-native English speakers to read through the codebase.
Words matter. If one contributor feels more welcome because these terms are removed, this was worth the effort.
Props strangerstudios, jorbin, desrosj, joemcgill, timothyblynjacobs, ocean90, ayeshrajans, davidbaumwald, earnjam.
See #48900, #50434.
Fixes #50413.
git-svn-id: https://develop.svn.wordpress.org/trunk@48121 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-22 19:24:34 +02:00
QUnit . test ( 'disallowed words in password should be penalized' , function ( assert ) {
2013-08-30 00:28:32 +02:00
var allowedPasswordScore , penalizedPasswordScore ,
2016-12-13 12:22:28 +01:00
allowedPassword = 'a[janedoefoe]4' ,
penalizedPassword = 'a[johndoefoe]4' ,
General: Remove “whitelist” and “blacklist” in favor of more clear and inclusive language.
“The WordPress open source community cares about diversity. We strive to maintain a welcoming environment where everyone can feel included.”
With this commit, all occurrences of “whitelist” and “blacklist” (with the single exception of the `$new_whitelist_options` global variable) are removed. A new ticket has been opened to explore renaming the `$new_whitelist_options` variable (#50434).
Changing to more specific names or rewording sentences containing these terms not only makes the code more inclusive, but also helps provide clarity. These terms are often ambiguous. What is being blocked or allowed is not always immediately clear. This can make it more difficult for non-native English speakers to read through the codebase.
Words matter. If one contributor feels more welcome because these terms are removed, this was worth the effort.
Props strangerstudios, jorbin, desrosj, joemcgill, timothyblynjacobs, ocean90, ayeshrajans, davidbaumwald, earnjam.
See #48900, #50434.
Fixes #50413.
git-svn-id: https://develop.svn.wordpress.org/trunk@48121 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-22 19:24:34 +02:00
disallowedList = [ 'extra' , 'johndoefoe' , 'superfluous' ] ;
2013-08-30 00:28:32 +02:00
General: Remove “whitelist” and “blacklist” in favor of more clear and inclusive language.
“The WordPress open source community cares about diversity. We strive to maintain a welcoming environment where everyone can feel included.”
With this commit, all occurrences of “whitelist” and “blacklist” (with the single exception of the `$new_whitelist_options` global variable) are removed. A new ticket has been opened to explore renaming the `$new_whitelist_options` variable (#50434).
Changing to more specific names or rewording sentences containing these terms not only makes the code more inclusive, but also helps provide clarity. These terms are often ambiguous. What is being blocked or allowed is not always immediately clear. This can make it more difficult for non-native English speakers to read through the codebase.
Words matter. If one contributor feels more welcome because these terms are removed, this was worth the effort.
Props strangerstudios, jorbin, desrosj, joemcgill, timothyblynjacobs, ocean90, ayeshrajans, davidbaumwald, earnjam.
See #48900, #50434.
Fixes #50413.
git-svn-id: https://develop.svn.wordpress.org/trunk@48121 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-22 19:24:34 +02:00
allowedPasswordScore = passwordStrength ( allowedPassword , disallowedList , allowedPassword ) ;
penalizedPasswordScore = passwordStrength ( penalizedPassword , disallowedList , penalizedPassword ) ;
2013-08-30 00:28:32 +02:00
2020-03-27 01:16:58 +01:00
assert . ok ( penalizedPasswordScore < allowedPasswordScore , 'Penalized password scored ' + penalizedPasswordScore + '; allowed password scored: ' + allowedPasswordScore ) ;
2013-09-06 12:56:01 +02:00
} ) ;
2013-09-28 08:46:29 +02:00
General: Remove “whitelist” and “blacklist” in favor of more clear and inclusive language.
“The WordPress open source community cares about diversity. We strive to maintain a welcoming environment where everyone can feel included.”
With this commit, all occurrences of “whitelist” and “blacklist” (with the single exception of the `$new_whitelist_options` global variable) are removed. A new ticket has been opened to explore renaming the `$new_whitelist_options` variable (#50434).
Changing to more specific names or rewording sentences containing these terms not only makes the code more inclusive, but also helps provide clarity. These terms are often ambiguous. What is being blocked or allowed is not always immediately clear. This can make it more difficult for non-native English speakers to read through the codebase.
Words matter. If one contributor feels more welcome because these terms are removed, this was worth the effort.
Props strangerstudios, jorbin, desrosj, joemcgill, timothyblynjacobs, ocean90, ayeshrajans, davidbaumwald, earnjam.
See #48900, #50434.
Fixes #50413.
git-svn-id: https://develop.svn.wordpress.org/trunk@48121 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-22 19:24:34 +02:00
QUnit . test ( 'user input disallowed list array should contain expected words' , function ( assert ) {
var disallowedList = wp . passwordStrength . userInputDisallowedList ( ) ;
2013-09-28 08:46:29 +02:00
General: Remove “whitelist” and “blacklist” in favor of more clear and inclusive language.
“The WordPress open source community cares about diversity. We strive to maintain a welcoming environment where everyone can feel included.”
With this commit, all occurrences of “whitelist” and “blacklist” (with the single exception of the `$new_whitelist_options` global variable) are removed. A new ticket has been opened to explore renaming the `$new_whitelist_options` variable (#50434).
Changing to more specific names or rewording sentences containing these terms not only makes the code more inclusive, but also helps provide clarity. These terms are often ambiguous. What is being blocked or allowed is not always immediately clear. This can make it more difficult for non-native English speakers to read through the codebase.
Words matter. If one contributor feels more welcome because these terms are removed, this was worth the effort.
Props strangerstudios, jorbin, desrosj, joemcgill, timothyblynjacobs, ocean90, ayeshrajans, davidbaumwald, earnjam.
See #48900, #50434.
Fixes #50413.
git-svn-id: https://develop.svn.wordpress.org/trunk@48121 602fd350-edb4-49c9-b593-d223f7449a82
2020-06-22 19:24:34 +02:00
assert . ok ( jQuery . isArray ( disallowedList ) , 'disallowed list is an array' ) ;
assert . ok ( jQuery . inArray ( 'WordPress' , disallowedList ) > - 1 , 'disallowed list contains "WordPress" from page title' ) ;
assert . ok ( jQuery . inArray ( 'tests' , disallowedList ) > - 1 , 'disallowed list contains "tests" from site URL' ) ;
2013-09-28 08:46:29 +02:00
} ) ;
2013-08-29 20:44:36 +02:00
} ) ;