From 0f7fc276635fb13ef88ab122344b05c1f39cd8a0 Mon Sep 17 00:00:00 2001 From: Lucas Heim Date: Thu, 30 Aug 2018 16:48:56 -0300 Subject: [PATCH] Creating default encryption test to improve coverage (#10651) --- 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({