Skip to content

Commit cc6e284

Browse files
committed
feat: add tests using real hashes
1 parent b65f206 commit cc6e284

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

test/unit/node/util.test.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ describe("isHashMatch", () => {
167167
const _hash = hash(password)
168168
expect(isHashMatch("otherPassword123", _hash)).toBe(false)
169169
})
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)
174+
})
170175
})
171176

172177
describe("hashLegacy", () => {
@@ -177,7 +182,7 @@ describe("hashLegacy", () => {
177182
})
178183
})
179184

180-
describe("isHashLegacyMatchh", () => {
185+
describe("isHashLegacyMatch", () => {
181186
it("should return true if is match", () => {
182187
const password = "password123"
183188
const _hash = hashLegacy(password)
@@ -188,4 +193,10 @@ describe("isHashLegacyMatchh", () => {
188193
const _hash = hashLegacy(password)
189194
expect(isHashLegacyMatch("otherPassword123", _hash)).toBe(false)
190195
})
196+
it("should return true if hashed from command line", () => {
197+
const password = "password123"
198+
// Hashed using printf "password123" | sha256sum | cut -d' ' -f1
199+
const _hash = "ef92b778bafe771e89245b89ecbc08a44a4e166c06659911881f383d4473e94f"
200+
expect(isHashLegacyMatch(password, _hash)).toBe(true)
201+
})
191202
})

0 commit comments

Comments
 (0)