| 12345678910111213141516171819202122232425262728293031323334353637 |
- #!/usr/bin/env python3
- """Test script to verify user authentication"""
- import asyncio
- import sys
- from app.database import async_session
- from app.auth import authenticate_user
- async def test_login(username: str, password: str):
- """Test user login"""
- async with async_session() as db:
- user = await authenticate_user(db, username, password)
- if user:
- print(f"✓ Authentication successful!")
- print(f" User ID: {user.id}")
- print(f" Username: {user.username}")
- print(f" Email: {user.email}")
- print(f" Active: {user.is_active}")
- else:
- print(f"✗ Authentication failed for username: {username}")
- print(f" Possible issues:")
- print(f" - Username doesn't exist")
- print(f" - Password is incorrect")
- print(f" - User account is inactive")
- if __name__ == "__main__":
- if len(sys.argv) != 3:
- print("Usage: ./test-auth.py <username> <password>")
- print("Example: ./test-auth.py Blance mypassword")
- sys.exit(1)
- username = sys.argv[1]
- password = sys.argv[2]
- print(f"Testing authentication for user: {username}")
- print("-" * 50)
- asyncio.run(test_login(username, password))
|