Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions test/unit/util/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const streamTest = require('streamtest').v2;
const crypto = require(appRoot + '/lib/util/crypto');

describe('util/crypto', () => {
describe('hashPassword/verifyPassword', () => {
const { hashPassword, verifyPassword } = crypto;
describe('hashPassword()', () => {
const { hashPassword } = crypto;

// we do not actually verify the hashing itself, as:
// 1. it is entirely performed by bcrypt, which has is own tests.
Expand All @@ -17,11 +17,18 @@ describe('util/crypto', () => {
it('should always return a Promise', () => {
hashPassword('').should.be.a.Promise();
hashPassword('password').should.be.a.Promise();
hashPassword('password', 'hashhash').should.be.a.Promise();
});

it('should reject given a blank plaintext', () =>
hashPassword('').should.be.rejectedWith('The password or passphrase provided does not meet the required length.'));
});

describe('verifyPassword()', () => {
const { verifyPassword } = crypto;

it('should always return a Promise', () => {
verifyPassword('password', 'hashhash').should.be.a.Promise();
});

it('should not attempt to verify empty plaintext', (done) => {
verifyPassword('', '$2a$12$hCRUXz/7Hx2iKPLCduvrWugC5Q/j5e3bX9KvaYvaIvg/uvFYEpzSy').then((result) => {
Expand Down