import urllib.request
import urllib.error

origins = [
    'http://localhost:5173',
    'http://127.0.0.1:5173',
    'http://localhost:3000',
    'http://localhost:5174'
]

for origin in origins:
    print(f"\n--- Testing Origin: {origin} ---")
    req = urllib.request.Request(
        'http://localhost:8080/api/v1/auth/login',
        data=b'{"username":"admin@tescorisecarrental.com","password":"admin123"}',
        headers={
            'Content-Type': 'application/json',
            'Origin': origin
        }
    )
    try:
        with urllib.request.urlopen(req) as resp:
            print('Status:', resp.getcode())
            print('Access-Control-Allow-Origin:', resp.headers.get('Access-Control-Allow-Origin'))
            print('Access-Control-Allow-Credentials:', resp.headers.get('Access-Control-Allow-Credentials'))
    except urllib.error.HTTPError as e:
        print('HTTP Error:', e.code)
        print('Body:', e.read().decode())
