diff --git a/test/password.js b/test/password.js index 7e6d8225f2..cc02be3bc2 100644 --- a/test/password.js +++ b/test/password.js @@ -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); + }); }); });