#!/bin/bash # Quick E2E Testing Script for LittleShop API_URL="http://localhost:8080/api" echo "=========================================" echo " LittleShop Quick E2E Test" echo "=========================================" echo "" # 1. Health Check echo "1. Testing Health Check..." curl -s http://localhost:8080/health > /dev/null 2>&1 if [ $? -eq 0 ]; then echo " ✓ Health check passed" else echo " ✗ Health check failed" fi # 2. Authentication echo "2. Testing Authentication..." TOKEN=$(curl -s -X POST "$API_URL/auth/login" \ -H "Content-Type: application/json" \ -d '{"username":"admin","password":"admin"}' | \ grep -o '"token":"[^"]*' | sed 's/"token":"//') if [ ! -z "$TOKEN" ]; then echo " ✓ Authentication successful" AUTH="Authorization: Bearer $TOKEN" else echo " ✗ Authentication failed" exit 1 fi # 3. Get Users echo "3. Testing User Management..." USERS=$(curl -s -H "$AUTH" "$API_URL/users") if echo "$USERS" | grep -q "Id"; then echo " ✓ Get users successful" else echo " ✗ Get users failed" fi # 4. Get Products echo "4. Testing Product Catalog..." PRODUCTS=$(curl -s "$API_URL/catalog/products") if echo "$PRODUCTS" | grep -q "items"; then echo " ✓ Get products successful" else echo " ✗ Get products failed" fi # 5. Create Order echo "5. Testing Order Creation..." ORDER=$(curl -s -X POST "$API_URL/orders" \ -H "Content-Type: application/json" \ -d '{ "identityReference": "test_customer_123", "shippingInfo": "123 Test St", "items": [] }') ORDER_ID=$(echo "$ORDER" | grep -o '"id":"[^"]*' | sed 's/"id":"//') if [ ! -z "$ORDER_ID" ]; then echo " ✓ Order created: $ORDER_ID" else echo " ✗ Order creation failed" fi # 6. Create Payment with SilverPAY if [ ! -z "$ORDER_ID" ]; then echo "6. Testing SilverPAY Payment..." PAYMENT=$(curl -s -X POST "$API_URL/orders/$ORDER_ID/payments" \ -H "Content-Type: application/json" \ -d '{ "cryptocurrency": "BTC", "amount": 10.00 }') if echo "$PAYMENT" | grep -q "walletAddress"; then echo " ✓ Payment created with SilverPAY" echo "$PAYMENT" | grep -o '"walletAddress":"[^"]*' | sed 's/"walletAddress":"/ Wallet: /' echo "$PAYMENT" | grep -o '"cryptoAmount":[^,}]*' | sed 's/"cryptoAmount":/ Amount: /' else echo " ✗ Payment creation failed" echo " Response: $PAYMENT" fi fi # 7. Test Categories echo "7. Testing Categories..." CATEGORIES=$(curl -s "$API_URL/catalog/categories") if [ "$?" -eq 0 ]; then echo " ✓ Categories endpoint working" else echo " ✗ Categories endpoint failed" fi # 8. Test Admin Panel echo "8. Testing Admin Panel..." ADMIN_PAGE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/Admin/Account/Login) if [ "$ADMIN_PAGE" == "200" ]; then echo " ✓ Admin panel accessible" else echo " ✗ Admin panel not accessible" fi echo "" echo "=========================================" echo " Quick Test Complete" echo "========================================="