Skip to content

Commit

Permalink
test: add dummy emailer hook in authentication test
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlam committed Feb 13, 2023
1 parent 40e7b86 commit 1b29dbb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@ const db = require('./mocks/databasemock');
const user = require('../src/user');
const utils = require('../src/utils');
const meta = require('../src/meta');
const plugins = require('../src/plugins');
const privileges = require('../src/privileges');
const helpers = require('./helpers');

describe('authentication', () => {
const jar = request.jar();
let regularUid;
const dummyEmailerHook = async (data) => {};

before((done) => {
// Attach an emailer hook so related requests do not error
plugins.hooks.register('authentication-test', {
hook: 'filter:email.send',
method: dummyEmailerHook,
});

user.create({ username: 'regular', password: 'regularpwd', email: 'regular@nodebb.org' }, (err, uid) => {
assert.ifError(err);
regularUid = uid;
Expand All @@ -27,6 +36,10 @@ describe('authentication', () => {
});
});

after(() => {
plugins.hooks.unregister('authentication-test', 'filter:email.send');
});

it('should allow login with email for uid 1', async () => {
const oldValue = meta.config.allowLoginWith;
meta.config.allowLoginWith = 'username-email';
Expand Down

0 comments on commit 1b29dbb

Please sign in to comment.