update devDependencies, fix lint issues
[squeep-authentication-module] / test / lib / authenticator.js
index 534fd02df14165d8029582ab6c3a816b24fbfe9a..71420810f3e878edc841c7c243976fc19e24b677 100644 (file)
@@ -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 () {