X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fsrc%2Fdb%2Fintegration.js;h=c26e277878f344573481c8ae0b1196bc43b51a7a;hb=f0bf29c75b0fd405ff92fa76f058e61162b87e43;hp=d866af6678cf7bafc79b9bc1f8f6a912ca334ad4;hpb=726cd980f0ed5588cfe8cbb2d994d5e4aef6e292;p=squeep-indie-auther diff --git a/test/src/db/integration.js b/test/src/db/integration.js index d866af6..c26e277 100644 --- a/test/src/db/integration.js +++ b/test/src/db/integration.js @@ -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);