update dependencies and devDependencies, address lint issues
[squeep-indie-auther] / test / src / db / integration.js
index d866af6678cf7bafc79b9bc1f8f6a912ca334ad4..c26e277878f344573481c8ae0b1196bc43b51a7a 100644 (file)
@@ -1,5 +1,4 @@
-/* eslint-env mocha */
-/* eslint-disable sonarjs/no-identical-functions */
+/* eslint-disable security/detect-object-injection */
 'use strict';
 
 /**
@@ -17,7 +16,7 @@
  */
 
 const assert = require('assert');
-const { step } = require('mocha-steps'); // eslint-disable-line node/no-unpublished-require
+const { step } = require('mocha-steps');
 const StubLogger = require('../../stub-logger');
 // const DBErrors = require('../../../src/db/errors');
 // const testData = require('../../test-data/db-integration');
@@ -137,9 +136,10 @@ describe('Database Integration', function () {
       }); // Resources
 
       describe('Users and Profiles and Scopes', function () {
-        let credential;
+        let credential, otpKey;
         beforeEach(function () {
           credential = '$plain$myPassword';
+          otpKey = '1234567890123456789012';
         });
         step('returns nothing when auth does not exist', async function () {
           await db.context(async (dbCtx) => {
@@ -170,11 +170,27 @@ describe('Database Integration', function () {
         step('update auth entry', async function () {
           await db.context(async (dbCtx) => {
             credential = '$plain$myNewPassword';
-            await db.authenticationUpsert(dbCtx, identifier, credential);
+            await db.authenticationUpsert(dbCtx, identifier, credential, otpKey);
+            const authInfo = await db.authenticationGet(dbCtx, identifier);
+            assert.strictEqual(authInfo.credential, credential);
+            assert.strictEqual(authInfo.otpKey, otpKey);
+          });
+        });
+        step('update auth credential', async function () {
+          await db.context(async (dbCtx) => {
+            credential = '$plain$anotherNewPassword';
+            await db.authenticationUpdateCredential(dbCtx, identifier, credential);
             const authInfo = await db.authenticationGet(dbCtx, identifier);
             assert.strictEqual(authInfo.credential, credential);
           });
         });
+        step('update auth otp', async function () {
+          await db.context(async (dbCtx) => {
+            await db.authenticationUpdateOTPKey(dbCtx, identifier, otpKey);
+            const authInfo = await db.authenticationGet(dbCtx, identifier);
+            assert.strictEqual(authInfo.otpKey, otpKey);
+          });
+        });
         step('profile is not valid', async function () {
           await db.context(async (dbCtx) => {
             const isValid = await db.profileIsValid(dbCtx, profile);