#!/bin/bash echo "🌐 Testing Frontend OAuth Integration" echo "=====================================" echo "" # Test 1: Check if frontend is running echo "1️⃣ Checking Frontend Status:" echo "----------------------------" if curl -s http://localhost:3001 > /dev/null; then echo "✅ Frontend is running at http://localhost:3001" else echo "❌ Frontend not running - please start it with: cd /home/tech4biz/Desktop/prakash/codenuk/fronend/codenuk_frontend_mine && npm run dev" exit 1 fi # Test 2: Check API Gateway echo "" echo "2️⃣ Testing API Gateway:" echo "----------------------" echo "Testing direct backend access:" curl -s -X GET "http://localhost:8000/api/vcs/github/auth/start?user_id=test123" | jq -r '.success' 2>/dev/null || echo "Backend not accessible" # Test 3: Test all provider OAuth URLs through frontend echo "" echo "3️⃣ Testing All Provider OAuth URLs:" echo "-----------------------------------" providers=("github" "gitlab" "bitbucket" "gitea") for provider in "${providers[@]}"; do echo "" echo "Testing $provider OAuth:" response=$(curl -s -X GET "http://localhost:8000/api/vcs/$provider/auth/start?user_id=test123") success=$(echo "$response" | jq -r '.success' 2>/dev/null) auth_url=$(echo "$response" | jq -r '.auth_url' 2>/dev/null) if [ "$success" = "true" ]; then echo "✅ $provider OAuth URL generated successfully" echo " URL: $(echo "$auth_url" | head -c 80)..." else echo "❌ $provider OAuth failed: $(echo "$response" | jq -r '.message' 2>/dev/null)" fi done # Test 4: Test repository attachment for all providers echo "" echo "4️⃣ Testing Repository Attachment:" echo "--------------------------------" for provider in "${providers[@]}"; do echo "" echo "Testing $provider repository attachment:" response=$(curl -s -X POST "http://localhost:8000/api/vcs/$provider/attach-repository" \ -H "Content-Type: application/json" \ -d "{\"repository_url\": \"https://$provider.com/private-repo/test\"}") success=$(echo "$response" | jq -r '.success' 2>/dev/null) message=$(echo "$response" | jq -r '.message' 2>/dev/null) if [ "$success" = "false" ] && [[ "$message" == *"authentication required"* ]]; then echo "✅ $provider correctly requires authentication" else echo "❌ $provider attachment issue: $message" fi done echo "" echo "🎯 Frontend Testing Complete!" echo "=============================" echo "" echo "📋 Next Steps to Test in Browser:" echo "1. Open http://localhost:3001 in your browser" echo "2. Click 'Create Template' button" echo "3. Select any provider (GitHub, GitLab, Bitbucket, Gitea)" echo "4. Enter a private repository URL" echo "5. Click the authentication button" echo "6. You should be redirected to the correct OAuth page" echo "7. After OAuth, files will be downloaded locally" echo "" echo "🔍 Debug Information:" echo "- Frontend: http://localhost:3001" echo "- Backend API: http://localhost:8000" echo "- Git Integration: http://localhost:8012" echo "- Local file storage: /home/tech4biz/Desktop/today work/git-repo/"