handle undefined credential more gracefully
[squeep-authentication-module] / test / lib / authenticator.js
index 067d0cae7a889a1eded72506527e29f08d1bc161..5da64397118439ff57cff5e414a83c8bfb3d6da7 100644 (file)
@@ -18,7 +18,7 @@ describe('Authenticator', function () {
     if (!a.authn[m]) { // eslint-disable-line security/detect-object-injection
       this.skip();
     }
-  };
+  }
 
   beforeEach(function () {
     options = Config('test');
@@ -117,6 +117,12 @@ describe('Authenticator', function () {
       assert.strictEqual(result, false);
       assert.strictEqual(ctx.authenticationId, undefined);
     });
+    it('covers non-string credential', async function () {
+      credential = '$argon2id$v=19$m=4096,t=3,p=1$SbAlHo5x2HM0PvMAWYHqww$gNn/o+B6+IWsnrVupPkTAiiK9tvwV+eM/HoXG41bnzM';
+      const result = await authenticator.isValidIdentifierCredential(identifier, undefined, ctx);
+      assert.strictEqual(result, false);
+      assert.strictEqual(ctx.authenticationId, undefined);
+    });
     it('covers unknown password hash', async function () {
       authenticator.db.authenticationGet.resolves({
         identifier,