curl · bash · CI/CD

Gerador de CNH via curl

API REST do FakeForge gera CNH mod-11 DENATRAN. Zero SDK, só curl e jq. Snippets pra bash, GitHub Actions, GitLab CI.

curl "https://fakeforge.com.br/api/generate?type=cnh&quantity=100"

GitHub Actions — teste validador CNH

# .github/workflows/test-cnh.yml
name: Test validador CNH DENATRAN

on: [pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Gera 100 CNHs válidas
        run: |
          curl -s "https://fakeforge.com.br/api/generate?type=cnh&quantity=100" \
            | jq -r '.data[]' > cnhs.txt

      - name: Testa validador
        run: |
          while read cnh; do
            if ! ./scripts/validar-cnh.sh "$cnh"; then
              echo "❌ FALHOU pra CNH: $cnh"
              exit 1
            fi
          done < cnhs.txt

Bash — seed app de mobilidade

#!/bin/bash
# seed-motoristas.sh

set -euo pipefail

# 500 motoristas com CPF + nome + endereço correlacionado
curl -s "https://fakeforge.com.br/api/generate?preset=customer&quantity=500" \
  > customers.json

# 500 CNHs
curl -s "https://fakeforge.com.br/api/generate?type=cnh&quantity=500" \
  | jq -r '.data[]' > cnhs.txt

# Combina e insere no Postgres
paste <(jq -r '.data[] | [.cpf, .nome] | @tsv' customers.json) cnhs.txt \
  | while IFS=$'\t' read cpf nome cnh; do
      psql -d myapp -c "INSERT INTO motoristas(cpf, nome, cnh) VALUES ('$cpf', '$nome', '$cnh');"
    done

Formatos de resposta

# JSON default
curl "https://fakeforge.com.br/api/generate?type=cnh&quantity=3"
# {"type":"cnh","quantity":3,"data":["12345678900","98765432100","..."]}

# CSV
curl "https://fakeforge.com.br/api/generate?type=cnh&quantity=100&format=csv"

# SQL
curl "https://fakeforge.com.br/api/generate?type=cnh&quantity=100&format=sql"