This commit is contained in:
2026-01-23 20:35:40 +03:00
parent cf3b0e48ec
commit 66c151653e
137 changed files with 41495 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
import { describe, it, expect } from "vitest";
import bcrypt from "bcryptjs";
// Test the actual bcrypt functionality without importing our modules
describe("Authentication Integration", () => {
describe("Password Hashing Integration", () => {
it("should hash and verify passwords using bcrypt", async () => {
const password = "testpassword123";
// Hash the password
const hashedPassword = await bcrypt.hash(password, 12);
expect(hashedPassword).toBeDefined();
expect(hashedPassword).not.toBe(password);
expect(hashedPassword.length).toBeGreaterThan(0);
// Verify correct password
const isValidPassword = await bcrypt.compare(password, hashedPassword);
expect(isValidPassword).toBe(true);
// Verify incorrect password
const isInvalidPassword = await bcrypt.compare("wrongpassword", hashedPassword);
expect(isInvalidPassword).toBe(false);
});
it("should generate different hashes for the same password", async () => {
const password = "testpassword123";
const hash1 = await bcrypt.hash(password, 12);
const hash2 = await bcrypt.hash(password, 12);
expect(hash1).not.toBe(hash2);
// But both should verify correctly
expect(await bcrypt.compare(password, hash1)).toBe(true);
expect(await bcrypt.compare(password, hash2)).toBe(true);
});
});
});