@@ -149,28 +149,31 @@ describe("getEnvPaths", () => {
149
149
} )
150
150
151
151
describe ( "hash" , ( ) => {
152
- it ( "should return a hash of the string passed in" , ( ) => {
152
+ it ( "should return a hash of the string passed in" , async ( ) => {
153
153
const plainTextPassword = "mySecretPassword123"
154
- const hashed = hash ( plainTextPassword )
154
+ const hashed = await hash ( plainTextPassword )
155
155
expect ( hashed ) . not . toBe ( plainTextPassword )
156
156
} )
157
157
} )
158
158
159
159
describe ( "isHashMatch" , ( ) => {
160
- it ( "should return true if the password matches the hash" , ( ) => {
161
- const password = "password123"
162
- const _hash = hash ( password )
163
- expect ( isHashMatch ( password , _hash ) ) . toBe ( true )
160
+ it ( "should return true if the password matches the hash" , async ( ) => {
161
+ const password = "codeserver1234"
162
+ const _hash = await hash ( password )
163
+ const actual = await isHashMatch ( password , _hash )
164
+ expect ( actual ) . toBe ( true )
164
165
} )
165
- it ( "should return false if the password does not match the hash" , ( ) => {
166
+ it ( "should return false if the password does not match the hash" , async ( ) => {
166
167
const password = "password123"
167
- const _hash = hash ( password )
168
- expect ( isHashMatch ( "otherPassword123" , _hash ) ) . toBe ( false )
168
+ const _hash = await hash ( password )
169
+ const actual = await isHashMatch ( "otherPassword123" , _hash )
170
+ expect ( actual ) . toBe ( false )
169
171
} )
170
- it ( "should return true with actual hash" , ( ) => {
171
- const password = "password"
172
- const _hash = "$2b$10$GA/eZnlboeV9eW8LnntPqe1dZE7tQ/./wCdc7NgJhMRB.xhaJfmG."
173
- expect ( isHashMatch ( password , _hash ) ) . toBe ( true )
172
+ it ( "should return true with actual hash" , async ( ) => {
173
+ const password = "password123"
174
+ const _hash = "$argon2i$v=19$m=4096,t=3,p=1$EAoczTxVki21JDfIZpTUxg$rkXgyrW4RDGoDYrxBFD4H2DlSMEhP4h+Api1hXnGnFY"
175
+ const actual = await isHashMatch ( password , _hash )
176
+ expect ( actual ) . toBe ( true )
174
177
} )
175
178
} )
176
179
0 commit comments