mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-06 04:17:03 +02:00
feat: add additional test for passwords > 73 chars
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user