WordPress.org

Make WordPress Core

Ticket #25088: 25088.6.diff

File 25088.6.diff, 1.1 KB (added by iandunn, 8 months ago)

Adds 'username in password should be penalized' test

  • tests/qunit/wp-admin/js/password-strength-meter.js

     
    7676                    equal( passwordStrength( passwords[i].pw, 'username', passwords[i].pw ), passwords[i].score, 'password of `' + passwords[i].pw + '` returns '+passwords[i].score  ); 
    7777        } 
    7878    }); 
     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        } ); 
    7991});