X-Git-Url: http://git.squeep.com/?p=squeep-indie-auther;a=blobdiff_plain;f=test%2Fsrc%2Fdb%2Fintegration.js;fp=test%2Fsrc%2Fdb%2Fintegration.js;h=10e88dfc06c40c84d7e65d48b0d27109fc6b44e7;hp=d866af6678cf7bafc79b9bc1f8f6a912ca334ad4;hb=fba42a499fe1af051b0982c1f3e8b3873c9ed2fb;hpb=e8dccf76ec2776f07eddd1ce2f1c4fc150a6f790 diff --git a/test/src/db/integration.js b/test/src/db/integration.js index d866af6..10e88df 100644 --- a/test/src/db/integration.js +++ b/test/src/db/integration.js @@ -137,9 +137,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 +171,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);