X-Git-Url: http://git.squeep.com/?p=squeep-indie-auther;a=blobdiff_plain;f=test%2Fsrc%2Fdb%2Fsqlite.js;fp=test%2Fsrc%2Fdb%2Fsqlite.js;h=f2d95461b439915005833267a8890d60f82ff94e;hp=e79e75fa421db1526db49f523de99bd9d18428ce;hb=fba42a499fe1af051b0982c1f3e8b3873c9ed2fb;hpb=e8dccf76ec2776f07eddd1ce2f1c4fc150a6f790 diff --git a/test/src/db/sqlite.js b/test/src/db/sqlite.js index e79e75f..f2d9546 100644 --- a/test/src/db/sqlite.js +++ b/test/src/db/sqlite.js @@ -309,6 +309,54 @@ describe('DatabaseSQLite', function () { }); }); // authenticationUpsert + describe('authenticationUpdateCredential', function () { + let identifier, credential; + beforeEach(function () { + identifier = 'username'; + credential = '$z$foo'; + }); + it('success', function() { + const dbResult = { + changes: 1, + lastInsertRowid: undefined, + }; + sinon.stub(db.statement.authenticationUpdateCredential, 'run').returns(dbResult); + db.authenticationUpdateCredential(dbCtx, identifier, credential); + }); + it('failure', function () { + const dbResult = { + changes: 0, + lastInsertRowid: undefined, + }; + sinon.stub(db.statement.authenticationUpdateCredential, 'run').returns(dbResult); + assert.throws(() => db.authenticationUpdateCredential(dbCtx, identifier, credential), DBErrors.UnexpectedResult); + }); + }); // authenticationUpdateCredential + + describe('authenticationUpdateOTPKey', function () { + let identifier, otpKey; + beforeEach(function () { + identifier = 'username'; + otpKey = '1234567890123456789012'; + }); + it('success', function() { + const dbResult = { + changes: 1, + lastInsertRowid: undefined, + }; + sinon.stub(db.statement.authenticationUpdateOtpKey, 'run').returns(dbResult); + db.authenticationUpdateOTPKey(dbCtx, identifier, otpKey); + }); + it('failure', function () { + const dbResult = { + changes: 0, + lastInsertRowid: undefined, + }; + sinon.stub(db.statement.authenticationUpdateOtpKey, 'run').returns(dbResult); + assert.throws(() => db.authenticationUpdateOTPKey(dbCtx, identifier, otpKey), DBErrors.UnexpectedResult); + }); + }); // authenticationUpdateOTPKey + describe('profileIdentifierInsert', function () { let profile, identifier; beforeEach(function () {