X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Flib%2Fauthenticator.js;h=71420810f3e878edc841c7c243976fc19e24b677;hb=9c8e775e5ab96a1788f535760bfa72205c430d15;hp=534fd02df14165d8029582ab6c3a816b24fbfe9a;hpb=54ca04e330d14a12344ddc2b161c1d9b55bfd7d7;p=squeep-authentication-module diff --git a/test/lib/authenticator.js b/test/lib/authenticator.js index 534fd02..7142081 100644 --- a/test/lib/authenticator.js +++ b/test/lib/authenticator.js @@ -1,8 +1,10 @@ /* eslint-env mocha */ +/* eslint-disable sonarjs/no-duplicate-string */ +/* eslint-disable jsdoc/require-jsdoc */ 'use strict'; const assert = require('assert'); -const sinon = require('sinon'); // eslint-disable-line node/no-unpublished-require +const sinon = require('sinon'); const Authenticator = require('../../lib/authenticator'); const stubLogger = require('../stub-logger'); const stubDb = require('../stub-db'); @@ -73,7 +75,7 @@ describe('Authenticator', function () { assert.deepStrictEqual(e, expected); assert(authenticator.db.authenticationUpsert.called); assert(authenticator.logger.error.called); - } + } }); }); // createIdentifier @@ -383,6 +385,22 @@ describe('Authenticator', function () { }); }); // checkOTP + describe('updateOTPKey', function () { + let dbCtx, otpKey; + beforeEach(function () { + dbCtx = {}; + otpKey = 'CDBGB3U3B2ILECQORMINGGSZN7LXY565'; + }); + it('covers success', async function () { + await authenticator.updateOTPKey(dbCtx, identifier, otpKey); + assert(authenticator.db.authenticationUpdateOTPKey.called); + }); + it('covers failure', async function () { + authenticator.db.authenticationUpdateOTPKey.rejects(); + assert.rejects(authenticator.updateOTPKey(dbCtx, identifier, otpKey)); + }); + }); // updateOTPKey + describe('sessionCheck', function () { let req, res, loginPath, required, profilesAllowed; beforeEach(function () {