X-Git-Url: http://git.squeep.com/?p=squeep-indie-auther;a=blobdiff_plain;f=test%2Fsrc%2Fdb%2Fpostgres.js;fp=test%2Fsrc%2Fdb%2Fpostgres.js;h=c00daad11d7de666c3bd5f6ba19553cb5fc5272e;hp=3920d340f53e2471b4fe5df55a32d25546996153;hb=fba42a499fe1af051b0982c1f3e8b3873c9ed2fb;hpb=e8dccf76ec2776f07eddd1ce2f1c4fc150a6f790 diff --git a/test/src/db/postgres.js b/test/src/db/postgres.js index 3920d34..c00daad 100644 --- a/test/src/db/postgres.js +++ b/test/src/db/postgres.js @@ -349,7 +349,6 @@ describe('DatabasePostgres', function () { }); }); // almanacUpsert - describe('authenticationSuccess', function () { let identifier; beforeEach(function () { @@ -420,6 +419,60 @@ describe('DatabasePostgres', function () { }); }); // authenticationUpsert + describe('authenticationUpdateCredential', function () { + let identifier, credential; + beforeEach(function () { + identifier = 'username'; + credential = '$z$foo'; + }); + it('success', async function () { + const dbResult = { + rowCount: 1, + rows: undefined, + duration: 22, + }; + sinon.stub(db.db, 'result').resolves(dbResult); + await db.authenticationUpdateCredential(dbCtx, identifier, credential); + }); + it('failure', async function () { + credential = undefined; + const dbResult = { + rowCount: 0, + rows: undefined, + duration: 22, + }; + sinon.stub(db.db, 'result').resolves(dbResult); + await assert.rejects(() => db.authenticationUpdateCredential(dbCtx, identifier, credential), DBErrors.UnexpectedResult); + + }); + }); // authenticationUpdateCredential + + describe('authenticationUpdateOTPKey', function () { + let identifier, otpKey; + beforeEach(function () { + identifier = 'username'; + otpKey = '1234567890123456789012'; + }); + it('success', async function () { + const dbResult = { + rowCount: 1, + rows: undefined, + duration: 22, + }; + sinon.stub(db.db, 'result').resolves(dbResult); + await db.authenticationUpdateOTPKey(dbCtx, identifier, otpKey); + }); + it('failure', async function () { + const dbResult = { + rowCount: 0, + rows: undefined, + duration: 22, + }; + sinon.stub(db.db, 'result').resolves(dbResult); + await assert.rejects(() => db.authenticationUpdateOTPKey(dbCtx, identifier, otpKey), DBErrors.UnexpectedResult); + }); + }); // authenticationUpdateOTPKey + describe('profileIdentifierInsert', function () { let profile, identifier; beforeEach(function () {