#!/bin/bash

BASE_URL="http://localhost:8000/api"

echo "======================================"
echo "Manual Auth Testing Script"
echo "======================================"

# Test 1: Register new user
echo ""
echo "[TEST 1] Register new user"
curl -X POST "${BASE_URL}/auth/register/" \
  -H "Content-Type: application/json" \
  -d '{
    "username": "testuser1",
    "email": "testuser1@test.com",
    "password": "TestPass123!",
    "password2": "TestPass123!"
  }' | python3 -m json.tool

# Test 2: Login with username
echo ""
echo "[TEST 2] Login with username"
curl -X POST "${BASE_URL}/auth/login/" \
  -H "Content-Type: application/json" \
  -d '{
    "username": "testuser1",
    "password": "TestPass123!"
  }' | python3 -m json.tool

# Test 3: Login with email
echo ""
echo "[TEST 3] Login with email"
curl -X POST "${BASE_URL}/auth/login/" \
  -H "Content-Type: application/json" \
  -d '{
    "username": "testuser1@test.com",
    "password": "TestPass123!"
  }' | python3 -m json.tool

# Test 4: Login with wrong password
echo ""
echo "[TEST 4] Login with wrong password"
curl -X POST "${BASE_URL}/auth/login/" \
  -H "Content-Type: application/json" \
  -d '{
    "username": "testuser1",
    "password": "WrongPassword"
  }' | python3 -m json.tool

# Test 5: Login with existing user (from create_regular_user.py)
echo ""
echo "[TEST 5] Login with existing user '\''user'\''"
curl -X POST "${BASE_URL}/auth/login/" \
  -H "Content-Type: application/json" \
  -d '{
    "username": "user",
    "password": "User123456!"
  }' | python3 -m json.tool

# Test 6: Login with existing user by email
echo ""
echo "[TEST 6] Login with existing user by email"
curl -X POST "${BASE_URL}/auth/login/" \
  -H "Content-Type: application/json" \
  -d '{
    "username": "user@daleeli.iq",
    "password": "User123456!"
  }' | python3 -m json.tool

echo ""
echo "======================================"
echo "Testing Complete"
echo "======================================"

