HUB
Sign inSign up

ninthtest/mock-services

By ninthtest

•Updated 3 months ago

Expose mock services over HTTP(S). Includes a prefab PKI.

Image
Integration & delivery
API management
Developer tools
0

473

ninthtest/mock-services repository overview

Expose mock services over HTTP(S). Includes a prefab PKI.

See: https://github.com/mzipay/n7t-python-docker/tree/main/apps/mock-services⁠

VOLUME /var/app

Mount service apps under /app/lib.

Override the prefab PKI by mounting an alternative under /etc/mock-pki.

Try out the example HTTP service:

$ podman run --rm -t -p 127.0.0.1:8999:8999 mock-services example
$ curl "http://localhost:8999/ping"

Or over HTTPS:

$ podman run --rm -t -p 127.0.0.1:8999:8999 mock-services --tls example
$ curl "https://localhost:8999/ping"```

Advanced TLS use cases are also possible. For example, here the mock service is run requiring mutual TLS using cross-signed certificates (i.e., the root CA is an RSA certificate while the server and client certificates are ECC):

$ podman run --name mocksvc --cap-drop=all --rm -it -p 127.0.0.1:8999:8999 --mount type=tmpfs,dst=/tmp,tmpfs-mode=1777 mock-services --tls --cafile cacert-rsa.pem --certfile servercombined-ecc-x-rsa.pem --verify-mode=CERT_REQUIRED example
$ podman exec -it mocksvc cat /etc/mock-pki/serverchain-ecc-x-rsa.pem > serverchain-ecc-x-rsa.pem
$ podman exec -it mocksvc cat /etc/mock-pki/clientcombined-ecc-x-rsa.pem > clientcombined-ecc-x-rsa.pem
$ curl -v --cacert serverchain-ecc-x-rsa.pem --cert clientcombined-ecc-x-rsa.pem "https://localhost:8999/ping"

Full usage/help:

$ podman run --rm -t mock-services --help
usage: entrypoint [-h] [-b HOST] [-p PORT] [--debug] [-q REQUEST_QUEUE_SIZE] [-m MOUNT_PATH] [--tls] [-v MINIMUM_VERSION] [-V MAXIMUM_VERSION] [--certfile CERTFILE]
                  [--keyfile KEYFILE] [--cafile CAFILE] [--verify-mode {CERT_NONE,CERT_OPTIONAL,CERT_REQUIRED}]
                  module_name [module_name ...]

Expose mock services over HTTP(S)

positional arguments:
  module_name           a mock service Bottle app (<module_name>.py MUST exist under /var/app/modules)

options:
  -h, --help            show this help message and exit
  -b, --host HOST       bind to host (default '0.0.0.0')
  -p, --port PORT       bind to port (default 8999)
  --debug               enable Bottle debug mode
  -q, --request-queue-size REQUEST_QUEUE_SIZE
                        maximum number of queued requests (default 128)
  -m, --mount-path MOUNT_PATH
                        mount path of root Bottle app (default '/')

TLS:
  --tls                 enable TLS
  -v, --minimum-version MINIMUM_VERSION
                        minimum TLS version (default 'TLSv1_2')
  -V, --maximum-version MAXIMUM_VERSION
                        maximum TLS version (default 'TLSv1_3')
  --certfile CERTFILE   server certificate chain (MAY contain private key) (default servercombined-ecc.pem)
  --keyfile KEYFILE     server private key (only if NOT contained in --certfile)

TLS client (mutual) authentication:
  --cafile CAFILE       trusted client CA certificate(s) (default cacert-ecc.pem)
  --verify-mode {CERT_NONE,CERT_OPTIONAL,CERT_REQUIRED}
                        control client certificate request/verification (default 'CERT_NONE')

All certificate and private key files MUST exist under /etc/mock-pki. Any files containing a private key protected by a passphrase MUST have an accompanying file named '.{filename}.passphrase' containing the passphrase and which MUST NOT have a terminating EOL marker.

Tag summary

Content type

Image

Digest

sha256:9e1938173…

Size

23.8 MB

Last updated

3 months ago

docker pull ninthtest/mock-services