From 5d5f8efabb0b3344f1895fdb4864c9f92cc817c5 Mon Sep 17 00:00:00 2001 From: lucasheim Date: Wed, 29 Aug 2018 23:43:00 -0300 Subject: [PATCH] Creating default encryption test to improve coverage --- test/api/unit/libs/password.test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/api/unit/libs/password.test.js b/test/api/unit/libs/password.test.js index a325538c5a..7c8c3fcd01 100644 --- a/test/api/unit/libs/password.test.js +++ b/test/api/unit/libs/password.test.js @@ -107,6 +107,25 @@ describe('Password Utilities', () => { } }); + it('defaults to SHA1 encryption if salt is provided', async () => { + let textPassword = 'mySecretPassword'; + let salt = sha1MakeSalt(); + let hashedPassword = sha1EncryptPassword(textPassword, salt); + + let user = { + auth: { + local: { + hashed_password: hashedPassword, + salt, + passwordHashMethod: '', + }, + }, + }; + + let isValidPassword = await compare(user, textPassword); + expect(isValidPassword).to.eql(true); + }); + it('throws an error if an invalid hashing method is used', async () => { try { await compare({