#!/usr/bin/env python3 import json import requests import time def test_production_login(): """Test login endpoint on production server""" base_url = "http://192.168.0.103:8000" # Test cases that might be coming from mobile app test_cases = [ { "name": "Empty request (like from emulator)", "data": {} }, { "name": "Only password", "data": {"password": "testpass123"} }, { "name": "Email with extra spaces", "data": { "email": " testuser@example.com ", "password": "SecurePass123" } }, { "name": "Valid login data", "data": { "email": "testuser@example.com", "password": "SecurePass123" } }, { "name": "Username login", "data": { "username": "testuser123", "password": "SecurePass123" } }, { "name": "Invalid JSON structure (common mobile app error)", "data": '{"email":"test@example.com","password":"test123"', "raw": True } ] headers = { "Content-Type": "application/json", "Accept": "application/json", "User-Agent": "MobileApp/1.0" } for test_case in test_cases: print(f"\n๐Ÿงช Testing: {test_case['name']}") print("=" * 60) try: if test_case.get("raw"): data = test_case["data"] print(f"Raw data: {data}") else: data = json.dumps(test_case["data"]) print(f"JSON data: {data}") response = requests.post( f"{base_url}/api/v1/auth/login", data=data, headers=headers, timeout=10 ) print(f"Status: {response.status_code}") print(f"Response: {response.text[:200]}...") if response.status_code == 422: print("๐Ÿ” This is a validation error - checking details...") try: error_details = response.json() if "detail" in error_details: detail = error_details["detail"] if isinstance(detail, list): for error in detail: field = error.get("loc", [])[-1] if error.get("loc") else "unknown" msg = error.get("msg", "Unknown error") print(f" Field '{field}': {msg}") else: print(f" Error: {detail}") except: pass except Exception as e: print(f"Request error: {str(e)}") time.sleep(1) if __name__ == "__main__": print("๐Ÿ” Testing login endpoint on production server 192.168.0.103") test_production_login()