}
+ /**
+ * Update the authentication database with a new otp key.
+ * @param {*} dbCtx db context
+ * @param {string} identifier identifier
+ * @param {string=} otpKey otp key
+ */
+ async updateOTPKey(dbCtx, identifier, otpKey) {
+ const _scope = _fileScope('updateOTPKey');
+ try {
+ await this.db.authenticationUpdateOTPKey(dbCtx, identifier, otpKey);
+ this.logger.info(_scope, 'otp key updated');
+ } catch (e) {
+ this.logger.error(_scope, 'failed', { error: e, identifier });
+ }
+ }
+
+
/**
* Check for valid Basic auth, updates ctx with identifier if valid.
* @param {String} credentials
});
}); // 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 () {