pysergio/stubborn

By pysergio

Updated about 6 hours ago

Because sometimes the real API just won't cut it

Image
Developer Tools

10K+

logo

GitHubbuilddocker hubdocker image archdocker image sizelicense

Overview

Stubborn is the ultimate tool for the frontend development and testing and debugging of your APIs. With Stubborn, you can easily create mock responses to simulate different scenarios, proxy requests to other servers, and call webhooks to test your integration. Plus, Stubborn comes with full request and response logging, so you can see exactly what's happening behind the scenes. Best of all, Stubborn is open-source and self-hosted, so you can use it on your infrastructure and customize it to meet your specific needs.

Features

  • Customizable mocking web resources.
  • Customizable response timeout support.
  • Full "Service-In-The-Middle" functionality allows proxy requests to third-party resources, fully capturing all interactions between the application under test and the third-party service (including the ability to selectively mock endpoints).
  • Calling the webhook of the integrated application at any moment of its interaction with the Stubborn.
  • JSON, XML, and Text response body formats support.
  • Exhaustive events log containing requests & response data with GUI.

Prerequisite

Stubborn is shipped as a Docker image. To use it, you need a Docker Engine installed on your machine. In addition, Docker Compose is highly recommended.

Supported platforms:

  • linux/amd64
  • linux/arm64
  • linux/arm32/v7 (Yes! You can run it on your Raspberry Pi!)

Quick Start

Here is a real-world example:

  1. Create the file docker-compose.yml in any directory of your choice:
version: '3'

services:
  postgres:
    image: postgres:14-alpine
    restart: unless-stopped
    volumes:
      - pg_data:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: stubborn
      POSTGRES_USER: stubborn
      POSTGRES_PASSWORD: notsecret

  stubborn:
    image: pysergio/stubborn:latest
    restart: unless-stopped
    environment:
      DATABASE_URL: postgres://stubborn:notsecret@postgres:5432/stubborn
      ADMIN_EMAIL: admin@example.com
      ADMIN_PASSWORD: admin
      ADMIN_USERNAME: admin
      SECRET_KEY: 'stubborn-not-secure!k%6kqx6a)-a6d7j8*n(!154#t+^5f)#^z5mjvlrf#u!'
      UWSGI_THREADS: 3
    ports:
      - "8000:8000"
    depends_on:
      - postgres

volumes:
  pg_data:

In the example above, we have a couple of the environment variables that are very important for setting up our application:

  • DATABASE_URL(required): a URL containing database connection data.
  • SECRET_KEY(required): a secret key that provides cryptographic signing and should be set to a unique, unpredictable value.
  • ADMIN_USERNAME(required for the first run only): a username for an administrative account.
  • ADMIN_PASSWORD(required for the first run only): a password for an administrative account.
  • ADMIN_EMAIL(required for the very first run only): an email for an administrative account.
  • DOMAIN_DISPLAY(optional): a protocol and domain where your application instance is hosted, i.e. https://mysite.com, http://192.168.1.150:8000. The default value is http://127.0.0.1:8000.
  • UWSGI_THREADS(optional): number of threads per uWSGI worker (does not connect directly with the Stubborn).
  1. Then run the command:
docker-compose up -d

Please, note that the parameter -d in the command example will tell Docker Compose to run the apps defined in docker-compose.yml in the background.

The site should now be running at http://0.0.0.0:8000. To access the service admin panel visit http://localhost:8000/admin/ and log in as a superuser.


For more examples please visit the GitHub repository.

Docker Pull Command

docker pull pysergio/stubborn