FEATURE: don't allow username and password to be the same

This commit is contained in:
Neil Lalonde
2015-02-25 11:59:57 -05:00
parent bcb0346595
commit cf81b3f86d
6 changed files with 42 additions and 0 deletions

View File

@ -22,3 +22,27 @@ test('basicUsernameValidation', function() {
equal(controller.get('basicUsernameValidation.ok'), true, 'Prefilled username is valid');
equal(controller.get('basicUsernameValidation.reason'), I18n.t('user.username.prefilled'), 'Prefilled username is valid');
});
test('passwordValidation', function() {
var subject = this.subject;
var controller = subject();
controller.set('passwordRequired', true);
controller.set('accountUsername', 'porkchops');
controller.set('prefilledUsername', 'porkchops');
controller.set('accountPassword', 'b4fcdae11f9167');
equal(controller.get('passwordValidation.ok'), true, 'Password is ok');
equal(controller.get('passwordValidation.reason'), I18n.t('user.password.ok'), 'Password is valid');
var testInvalidPassword = function(password, expectedReason) {
var controller = subject();
controller.set('accountPassword', password);
equal(controller.get('passwordValidation.failed'), true, 'password should be invalid: ' + password);
equal(controller.get('passwordValidation.reason'), expectedReason, 'password validation reason: ' + password + ', ' + expectedReason);
};
testInvalidPassword('', undefined);
testInvalidPassword('x', I18n.t('user.password.too_short'));
testInvalidPassword('porkchops', I18n.t('user.password.same_as_username'));
});