@@ -149,28 +149,31 @@ describe("getEnvPaths", () => {
149149} )
150150
151151describe ( "hash" , ( ) => {
152- it ( "should return a hash of the string passed in" , ( ) => {
152+ it ( "should return a hash of the string passed in" , async ( ) => {
153153 const plainTextPassword = "mySecretPassword123"
154- const hashed = hash ( plainTextPassword )
154+ const hashed = await hash ( plainTextPassword )
155155 expect ( hashed ) . not . toBe ( plainTextPassword )
156156 } )
157157} )
158158
159159describe ( "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 )
164165 } )
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 ( ) => {
166167 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 )
169171 } )
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 )
174177 } )
175178} )
176179
0 commit comments