Dashboard-Automatizase/tmp/test-n8n-schema.sh
Luis Erlacher 0152a2fda0 feat: add n8n API testing script for Google OAuth2 schema and existing credentials
- Implemented a bash script to test n8n API and retrieve credential schemas.
- Added types for API responses, Google Calendar, and WhatsApp instances.
- Configured Vitest for testing with React and added setup for testing-library.
2025-10-10 14:29:02 -03:00

48 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# Script para testar n8n API e descobrir schema correto
# Baseado no tutorial fornecido
echo "=== Teste n8n API - Google OAuth2 Schema ==="
echo ""
# Carregar variáveis do .env.local
export $(grep -v '^#' .env.local | xargs)
echo "1. Listando todos os schemas de credenciais disponíveis..."
echo "URL: ${N8N_API_URL}/credentials/schema"
echo ""
curl -s -H "X-N8N-API-KEY: ${N8N_API_KEY}" \
"${N8N_API_URL}/credentials/schema" | jq '.' > tmp/all-schemas.json
echo "✅ Schemas salvos em: tmp/all-schemas.json"
echo ""
echo "2. Buscando schema específico de googleOAuth2Api..."
echo "URL: ${N8N_API_URL}/credentials/schema/googleOAuth2Api"
echo ""
curl -s -H "X-N8N-API-KEY: ${N8N_API_KEY}" \
"${N8N_API_URL}/credentials/schema/googleOAuth2Api" | jq '.' > tmp/google-oauth2-schema.json
echo "✅ Schema do Google OAuth2 salvo em: tmp/google-oauth2-schema.json"
echo ""
echo "3. Listando credenciais existentes..."
echo "URL: ${N8N_API_URL}/credentials"
echo ""
curl -s -H "X-N8N-API-KEY: ${N8N_API_KEY}" \
"${N8N_API_URL}/credentials" | jq '.' > tmp/existing-credentials.json
echo "✅ Credenciais existentes salvas em: tmp/existing-credentials.json"
echo ""
echo "=== Resumo dos arquivos gerados ==="
echo "- tmp/all-schemas.json - Todos os schemas disponíveis"
echo "- tmp/google-oauth2-schema.json - Schema específico do Google OAuth2"
echo "- tmp/existing-credentials.json - Credenciais já criadas"
echo ""
echo "Use 'cat tmp/google-oauth2-schema.json | jq' para ver o schema detalhado"