CI/CD

How to use mocks in a CI/CD pipeline

Integrate httpdrop into GitHub Actions, Docker and automated tests without depending on external APIs

The problem: flaky integration tests

Tests that depend on external APIs — Stripe, payment gateways, internal staging services — are the first to break the build for reasons completely outside your control: rate limits, sandbox instability, contract changes without notice.

The solution is to replace these dependencies with stable mocks in CI. httpdrop offers three ways: API Tokens for programmatic endpoint management, CLI for script automation and the GitHub Action for native workflows.

Option 1 — Via API Token

curl -X POST https://httpdrop.com/api/endpoints \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "ci-payments-mock"}'

Option 2 — Via CLI in pipeline

- name: Install httpdrop CLI
  run: npm install -g @httpdrop/cli

- name: Configure mock endpoints
  env:
    HTTPDROP_TOKEN: ${{ secrets.HTTPDROP_TOKEN }}
  run: httpdrop import stripe-mock.yaml ${{ secrets.STRIPE_MOCK_EP_ID }}

- name: Run integration tests
  env:
    STRIPE_BASE_URL: https://httpdrop.com/mock/${{ secrets.STRIPE_MOCK_EP_ID }}
  run: npm run test:integration

Option 3 — GitHub Action

- name: Run Chaos Experiment
  uses: httpdrop/action@v1
  with:
    token: ${{ secrets.HTTPDROP_TOKEN }}
    endpoint-id: ${{ secrets.API_ENDPOINT_ID }}
    chaos-rate: 30
    chaos-status: 503
    duration: 60
💡
Security tip: Use API Tokens with restricted scope and 90-day expiration for pipelines. Never commit tokens to code — use GitHub Secrets or your CI environment variables.
Ready to implement? Check the full technical documentation with API reference, code examples and detailed parameters.
View docs →