#!/bin/bash # Integration Test Script for LittleShop, TeleBot, and SilverPay # Tests production endpoints at admin.thebankofdebbie.giize.com and pay.thebankofdebbie.giize.com set -e # Exit on first error # Color codes for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Configuration LITTLESHOP_URL="https://admin.thebankofdebbie.giize.com" SILVERPAY_URL="https://pay.thebankofdebbie.giize.com" ADMIN_USERNAME="admin" ADMIN_PASSWORD="admin" # Variables to store session data COOKIE_JAR="/tmp/littleshop_cookies.txt" AUTH_TOKEN="" TEST_ORDER_ID="" TEST_PAYMENT_ID="" # Test results TESTS_PASSED=0 TESTS_FAILED=0 # Function to print test status print_test() { local test_name=$1 local status=$2 local message=$3 if [ "$status" = "PASS" ]; then echo -e "${GREEN}✓${NC} $test_name - ${GREEN}PASSED${NC}" [ ! -z "$message" ] && echo " └─ $message" ((TESTS_PASSED++)) else echo -e "${RED}✗${NC} $test_name - ${RED}FAILED${NC}" [ ! -z "$message" ] && echo " └─ ${RED}$message${NC}" ((TESTS_FAILED++)) fi } # Function to check HTTP response code check_response() { local response=$1 local expected=$2 local test_name=$3 local http_code=$(echo "$response" | tail -n 1) local body=$(echo "$response" | head -n -1) if [ "$http_code" = "$expected" ]; then print_test "$test_name" "PASS" "HTTP $http_code" echo "$body" else print_test "$test_name" "FAIL" "Expected HTTP $expected, got HTTP $http_code" echo "$body" | head -20 return 1 fi } echo "================================================" echo "Integration Test Suite" echo "================================================" echo "LittleShop: $LITTLESHOP_URL" echo "SilverPay: $SILVERPAY_URL" echo "================================================" echo "" # Clean up cookie jar rm -f "$COOKIE_JAR" # ============================================================ # TEST 1: LittleShop Admin Login # ============================================================ echo -e "${BLUE}[TEST GROUP 1]${NC} LittleShop Admin Login" echo "--------------------------------------------" echo "Testing admin login endpoint..." LOGIN_RESPONSE=$(curl -s -w "\n%{http_code}" \ -X POST "$LITTLESHOP_URL/Admin/Account/Login" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "Username=$ADMIN_USERNAME&Password=$ADMIN_PASSWORD" \ -c "$COOKIE_JAR" \ -L) HTTP_CODE=$(echo "$LOGIN_RESPONSE" | tail -n 1) # For login, we expect a 302 redirect on success if [ "$HTTP_CODE" = "302" ] || [ "$HTTP_CODE" = "200" ]; then # Verify we can access the dashboard DASHBOARD_RESPONSE=$(curl -s -w "\n%{http_code}" \ "$LITTLESHOP_URL/Admin/Dashboard" \ -b "$COOKIE_JAR") DASH_CODE=$(echo "$DASHBOARD_RESPONSE" | tail -n 1) if [ "$DASH_CODE" = "200" ]; then print_test "Admin Login" "PASS" "Successfully authenticated and accessed dashboard" else print_test "Admin Login" "FAIL" "Login succeeded but couldn't access dashboard (HTTP $DASH_CODE)" fi else print_test "Admin Login" "FAIL" "Login failed with HTTP $HTTP_CODE" fi echo "" # ============================================================ # TEST 2: TeleBot-LittleShop Communication # ============================================================ echo -e "${BLUE}[TEST GROUP 2]${NC} TeleBot-LittleShop Communication" echo "--------------------------------------------" # Test public API endpoint for categories echo "Testing categories API endpoint..." CATEGORIES_RESPONSE=$(curl -s -w "\n%{http_code}" \ "$LITTLESHOP_URL/api/catalog/categories" \ -H "Accept: application/json") CAT_CODE=$(echo "$CATEGORIES_RESPONSE" | tail -n 1) CAT_BODY=$(echo "$CATEGORIES_RESPONSE" | head -n -1) if [ "$CAT_CODE" = "200" ]; then # Check if we got valid JSON with categories if echo "$CAT_BODY" | grep -q '"id"' && echo "$CAT_BODY" | grep -q '"name"'; then CATEGORY_COUNT=$(echo "$CAT_BODY" | grep -o '"id"' | wc -l) print_test "Retrieve Categories" "PASS" "Retrieved $CATEGORY_COUNT categories" else print_test "Retrieve Categories" "FAIL" "Response doesn't contain valid category data" fi else print_test "Retrieve Categories" "FAIL" "Failed with HTTP $CAT_CODE" fi # Test products endpoint echo "Testing products API endpoint..." PRODUCTS_RESPONSE=$(curl -s -w "\n%{http_code}" \ "$LITTLESHOP_URL/api/catalog/products" \ -H "Accept: application/json") PROD_CODE=$(echo "$PRODUCTS_RESPONSE" | tail -n 1) PROD_BODY=$(echo "$PRODUCTS_RESPONSE" | head -n -1) if [ "$PROD_CODE" = "200" ]; then if echo "$PROD_BODY" | grep -q '"id"' && echo "$PROD_BODY" | grep -q '"name"'; then PRODUCT_COUNT=$(echo "$PROD_BODY" | grep -o '"id"' | wc -l) print_test "Retrieve Products" "PASS" "Retrieved $PRODUCT_COUNT products" else print_test "Retrieve Products" "FAIL" "Response doesn't contain valid product data" fi else print_test "Retrieve Products" "FAIL" "Failed with HTTP $PROD_CODE" fi echo "" # ============================================================ # TEST 3: SilverPay Wallet & Order Operations # ============================================================ echo -e "${BLUE}[TEST GROUP 3]${NC} SilverPay Operations" echo "--------------------------------------------" # Test wallet info endpoint echo "Testing SilverPay wallet info..." WALLET_RESPONSE=$(curl -s -w "\n%{http_code}" \ "$SILVERPAY_URL/api/wallets" \ -H "Accept: application/json") WALLET_CODE=$(echo "$WALLET_RESPONSE" | tail -n 1) WALLET_BODY=$(echo "$WALLET_RESPONSE" | head -n -1) if [ "$WALLET_CODE" = "200" ]; then if echo "$WALLET_BODY" | grep -q '"currency"' || echo "$WALLET_BODY" | grep -q '"address"'; then WALLET_COUNT=$(echo "$WALLET_BODY" | grep -o '"currency"' | wc -l) print_test "Get Wallet Info" "PASS" "Retrieved $WALLET_COUNT wallet(s)" else print_test "Get Wallet Info" "FAIL" "Response doesn't contain wallet data" fi else print_test "Get Wallet Info" "FAIL" "Failed with HTTP $WALLET_CODE" fi # Test list orders endpoint echo "Testing SilverPay list orders..." ORDERS_RESPONSE=$(curl -s -w "\n%{http_code}" \ "$SILVERPAY_URL/api/orders" \ -H "Accept: application/json") ORDERS_CODE=$(echo "$ORDERS_RESPONSE" | tail -n 1) ORDERS_BODY=$(echo "$ORDERS_RESPONSE" | head -n -1) if [ "$ORDERS_CODE" = "200" ]; then print_test "List Orders" "PASS" "Successfully retrieved orders list" else print_test "List Orders" "FAIL" "Failed with HTTP $ORDERS_CODE" fi # Test create order on testnet echo "Testing SilverPay create test order..." CREATE_ORDER_PAYLOAD=$(cat <