#!/usr/bin/env python3 """ Test Login Functionality This script tests the login authentication for the ParentZone API. """ import asyncio import sys import os # Add the current directory to the path so we can import auth_manager sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from auth_manager import AuthManager async def test_login(): """Test the login functionality.""" print("=" * 60) print("ParentZone Login Test") print("=" * 60) auth_manager = AuthManager() # Test credentials email = "tudor.sitaru@gmail.com" password = "mTVq8uNUvY7R39EPGVAm@" print(f"Testing login for: {email}") try: success = await auth_manager.login(email, password) if success: print("✅ Login successful!") print(f"User: {auth_manager.user_name}") print(f"Provider: {auth_manager.provider_name}") print(f"User ID: {auth_manager.user_id}") print( f"API Key: {auth_manager.api_key[:20]}..." if auth_manager.api_key else "No API key found" ) # Test getting auth headers headers = auth_manager.get_auth_headers() print(f"Auth headers: {list(headers.keys())}") if "x-api-key" in headers: print(f"✅ x-api-key header present: {headers['x-api-key'][:20]}...") if "x-api-product" in headers: print(f"✅ x-api-product header: {headers['x-api-product']}") # Test if authenticated if auth_manager.is_authenticated(): print("✅ Authentication status: Authenticated") else: print("❌ Authentication status: Not authenticated") else: print("❌ Login failed!") return False except Exception as e: print(f"❌ Login error: {e}") return False print("\n" + "=" * 60) print("LOGIN TEST COMPLETE") print("=" * 60) return success if __name__ == "__main__": success = asyncio.run(test_login()) sys.exit(0 if success else 1)