update depedencies, changes to support updated authentication-module
[squeep-indie-auther] / test / src / db / sqlite.js
index e79e75fa421db1526db49f523de99bd9d18428ce..f2d95461b439915005833267a8890d60f82ff94e 100644 (file)
@@ -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 () {