Unit Tests for Password Hashing and Validation Utilities ========================================================= Test 1: Email Validation Valid email test@example.com: PASS Valid email user.name@domain.co.id: PASS Valid email admin+tag@site.org: PASS Invalid email "invalid": PASS Invalid email "@example.com": PASS Invalid email "user@": PASS Invalid email "user @example.com": PASS Invalid empty email: PASS Test 2: Password Validation (minimum 8 characters) Valid password "password123" (11 chars): PASS Valid password "12345678" (8 chars): PASS Valid password "MyP@ssw0rd!" (11 chars): PASS Valid password "abcdefgh" (8 chars): PASS Invalid password "short" (5 chars): PASS Invalid password "1234567" (7 chars): PASS Invalid empty password: PASS Invalid password "abc" (3 chars): PASS Test 3: Password Hashing Hash is not empty: PASS Hash is different from password: PASS Hash starts with $2y$ (bcrypt): PASS Hash length > 50 characters: PASS Sample hash: $2y$12$aEfP0ZzQfIV.nLt6VfyliOziIBFl6pdqz... Test 4: Password Verification Verify correct password: PASS Reject wrong password: PASS Reject empty password: PASS Test 5: Password Hash Uniqueness Same password produces different hashes (salt): PASS Both hashes verify correctly: PASS Test 6: Additional Validator Methods Required field validation - non-empty string: PASS Required field validation - empty string: PASS Required field validation - whitespace only: PASS Phone number validation - valid: PASS Phone number validation - with spaces: PASS Phone number validation - with dashes: PASS Phone number validation - international: PASS Phone number validation - too short: PASS String length validation - within range: PASS String length validation - too short: PASS String length validation - too long: PASS Test 7: Input Sanitization XSS script tags are escaped: PASS Sanitized output contains <: PASS Sanitized output does not contain Sanitized: <script>alert("XSS")</script> ========================================================= Test Summary: PASSED: 39 FAILED: 0 TOTAL: 39 ✓ All tests passed!