codenuk_backend_mine/test-frontend-oauth.sh
2025-10-15 08:00:16 +05:30

86 lines
3.1 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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/"