curl · bash · CI/CD

Gerador de Cartão para Testes via curl

API REST do FakeForge gera números sintéticos de cartão com Luhn válido. Zero SDK, só curl e jq. Snippets pra bash puro, GitHub Actions, GitLab CI, Jenkins. Ambiente de desenvolvimento apenas.

TL;DR

# 10 cartões sintéticos (Luhn válido)
curl -H "X-API-Key: $FAKEFORGE_API_KEY" "https://fakeforge.com.br/api/generate?type=creditCard&quantity=10"

# Só o número (com jq)
curl -H "X-API-Key: $FAKEFORGE_API_KEY" -s "https://fakeforge.com.br/api/generate?type=creditCard&quantity=10" | jq -r '.data[].number'

GitHub Actions — teste E2E com Playwright

# .github/workflows/e2e-checkout.yml
name: E2E checkout com cartão sintético

on: [pull_request]

jobs:
  e2e:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Gera 5 cartões pra testar
        run: |
          curl -H "X-API-Key: $FAKEFORGE_API_KEY" -s "https://fakeforge.com.br/api/generate?type=creditCard&quantity=5" \
            | jq '.data' > tests/fixtures/cartoes.json

      - name: Instala Playwright
        run: npm ci && npx playwright install --with-deps

      - name: Roda testes E2E
        run: npx playwright test tests/checkout.spec.ts

Bash script (populate staging)

#!/bin/bash
# seed-cartoes-staging.sh - só rodar em staging

set -euo pipefail

if [ "$ENV" != "staging" ] && [ "$ENV" != "dev" ]; then
  echo "Ambiente inválido pra seed de cartão. Aborting."
  exit 1
fi

# Gera 100 cartões e formata como SQL INSERT
curl -sH "X-API-Key: $FF_KEY" \
  "https://fakeforge.com.br/api/generate?type=creditCard&quantity=100&format=sql" \
  | psql "$STAGING_DB_URL"

echo "100 cartões sintéticos inseridos em staging"

Filtro por bandeira

# Só Visa
curl -H "X-API-Key: $FAKEFORGE_API_KEY" "https://fakeforge.com.br/api/generate?type=creditCardVisa&quantity=20"

# Só Mastercard
curl -H "X-API-Key: $FAKEFORGE_API_KEY" "https://fakeforge.com.br/api/generate?type=creditCardMastercard&quantity=20"

# Elo
curl -H "X-API-Key: $FAKEFORGE_API_KEY" "https://fakeforge.com.br/api/generate?type=creditCardElo&quantity=20"

# Amex
curl -H "X-API-Key: $FAKEFORGE_API_KEY" "https://fakeforge.com.br/api/generate?type=creditCardAmex&quantity=20"

# Aleatório (default: qualquer bandeira)
curl -H "X-API-Key: $FAKEFORGE_API_KEY" "https://fakeforge.com.br/api/generate?type=creditCard&quantity=20"

Formatos de resposta

# JSON default
curl -H "X-API-Key: $FAKEFORGE_API_KEY" "https://fakeforge.com.br/api/generate?type=creditCard&quantity=1"
# {"type":"creditCard","quantity":1,"data":[{"number":"4532...","brand":"visa",...}]}

# CSV
curl -H "X-API-Key: sua_chave" "https://fakeforge.com.br/api/generate?type=creditCard&quantity=100&format=csv"

# SQL INSERT
curl -H "X-API-Key: sua_chave" "https://fakeforge.com.br/api/generate?type=creditCard&quantity=100&format=sql"

Números sintéticos passam Luhn mas gateway real (Stripe/Mercado Pago/PagSeguro/Cielo) rejeita em transação real. Pra testar aprovação/recusa em sandbox de gateway, use os cartões oficiais publicados por eles. Ver guia Stripe + BR gateways.