Phase 3.1: Enhanced Chore Logging and Reporting System
This commit is contained in:
69
backend/test_passwords.py
Normal file
69
backend/test_passwords.py
Normal file
@@ -0,0 +1,69 @@
|
||||
"""Test password verification."""
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Add parent directory to path
|
||||
sys.path.insert(0, str(Path(__file__).parent))
|
||||
|
||||
from app.core.database import SessionLocal
|
||||
from app.models.user import User
|
||||
from app.core.security import verify_password
|
||||
|
||||
def test_login(username: str, password: str):
|
||||
"""Test if login credentials work."""
|
||||
db = SessionLocal()
|
||||
|
||||
try:
|
||||
# Find user
|
||||
user = db.query(User).filter(User.username == username).first()
|
||||
|
||||
if not user:
|
||||
print(f"❌ User '{username}' not found in database")
|
||||
print("\nAvailable users:")
|
||||
all_users = db.query(User).all()
|
||||
for u in all_users:
|
||||
print(f" - {u.username} ({u.full_name})")
|
||||
return False
|
||||
|
||||
print(f"✓ Found user: {user.username} ({user.full_name})")
|
||||
print(f" Email: {user.email}")
|
||||
print(f" Is Admin: {user.is_admin}")
|
||||
print(f" Is Active: {user.is_active}")
|
||||
print(f" Password Hash: {user.hashed_password[:60]}...")
|
||||
print()
|
||||
|
||||
# Verify password
|
||||
if verify_password(password, user.hashed_password):
|
||||
print(f"✅ Password verification SUCCESSFUL for '{username}'")
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Password verification FAILED for '{username}'")
|
||||
print(f" Tried password: '{password}'")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Error: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return False
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("="*50)
|
||||
print("Password Verification Test")
|
||||
print("="*50)
|
||||
print()
|
||||
|
||||
# Test all demo users
|
||||
test_users = [
|
||||
("jess", "password123"),
|
||||
("lou", "password123"),
|
||||
("william", "password123"),
|
||||
]
|
||||
|
||||
for username, password in test_users:
|
||||
print(f"\nTesting: {username} / {password}")
|
||||
print("-"*50)
|
||||
test_login(username, password)
|
||||
print()
|
||||
Reference in New Issue
Block a user