feat: add additional test for passwords > 73 chars

This commit is contained in:
Julian Lam
2020-11-03 11:34:15 -05:00
parent ad66a1af4b
commit b235f3b15c

View File

@@ -13,7 +13,9 @@ describe('Password', () => {
});
});
describe('.compare()', () => {
describe('.compare()', async () => {
const salt = await bcrypt.genSalt(12);
it('should correctly compare a password and a hash', async () => {
const hash = await password.hash(12, 'test');
const match = await password.compare('test', hash, true);
@@ -21,9 +23,19 @@ describe('Password', () => {
});
it('should correctly handle comparison with no sha wrapping of the input (backwards compatibility)', async () => {
const hash = await bcrypt.hash('test', await bcrypt.genSalt(12));
const hash = await bcrypt.hash('test', salt);
const match = await password.compare('test', hash, false);
assert(match);
});
it('should continue to function even with passwords > 73 characters', async () => {
const arr = [];
arr.length = 100;
const hash = await password.hash(12, arr.join('a'));
arr.length = 150;
const match = await password.compare(arr.join('a'), hash, true);
assert.strictEqual(match, false);
});
});
});