| 1 |
# How to test acme-tiny |
| 2 |
|
| 3 |
Testing acme-tiny requires a bit of setup since it needs to interact with a local Let's Encrypt CA test server. This readme explains how to set up your local environment so you can run `acme-tiny` tests yourself. |
| 4 |
|
| 5 |
## Setup instructions (default) |
| 6 |
|
| 7 |
In the default test setup, we use [pebble](https://github.com/letsencrypt/pebble) as the mock Let's Encrypt CA server on your local computer. So you need to install that before running the test suite. |
| 8 |
|
| 9 |
1. Install the Let's Encrypt test server: `pebble` (instructions below are for Ubuntu 24.04 AMD64, adjust as needed) |
| 10 |
* `wget https://github.com/letsencrypt/pebble/releases/latest/download/pebble-linux-amd64.tar.gz` |
| 11 |
* `tar -xvzf pebble-linux-amd64.tar.gz -C /tmp` |
| 12 |
* `chmod 744 /tmp/pebble-linux-amd64/linux/amd64/pebble` |
| 13 |
* `/tmp/pebble-linux-amd64/linux/amd64/pebble -h` (should print out pebble usage help) |
| 14 |
* `export ACME_TINY_PEBBLE_BIN="/tmp/pebble-linux-amd64/linux/amd64/pebble"` |
| 15 |
2. Setup a virtual environment for python: |
| 16 |
* `python3 -m venv /tmp/venv` (creates the virtualenv) |
| 17 |
* `source /tmp/venv/bin/activate` (starts using the virtualenv) |
| 18 |
3. Install `acme-tiny` test dependencies: |
| 19 |
* `cd /path/to/acme-tiny` |
| 20 |
* `pip install -U -r tests/requirements.txt` |
| 21 |
4. Run the test suite on your local. |
| 22 |
* `cd /path/to/acme-tiny` |
| 23 |
* `unset ACME_TINY_USE_STAGING` (optional, if set previously to use staging) |
| 24 |
* `unset ACME_TINY_DOMAIN` (optional, if set previously to use staging) |
| 25 |
* `export ACME_TINY_PEBBLE_BIN="/tmp/pebble-linux-amd64/linux/amd64/pebble"` (optional, if not set previously) |
| 26 |
* `coverage erase` (removes any previous coverage data files) |
| 27 |
* `coverage run --source . --omit ./setup.py -m unittest tests` (runs the test suite) |
| 28 |
* `coverage report -m` (optional, prints out coverage summary in console) |
| 29 |
* `coverage html` (optional, generates html coverage report you can browse at `htmlcov/index.html`) |
| 30 |
|
| 31 |
## Setup instructions (staging) |
| 32 |
|
| 33 |
We also allow running the test suite against the official Let's Encrypt [staging](https://letsencrypt.org/docs/staging-environment/) server. Since the staging server is run by Let's Encrypt, you need to actually host a real domain an serve real challenge files. The simplest way to do this is to mount your remote server's static challenge file directory (see example instructions below). |
| 34 |
|
| 35 |
1. Run a static server with a real domain (e.g. `test.mydomain.com`) with a challenge directory (instructions below are for Ubuntu 24.04, adjust as needed). |
| 36 |
* `ssh [email protected]` (log into your server) |
| 37 |
* `mkdir -p /tmp/testfiles/.well-known/acme-challenge` (make the ACME challenge file directory) |
| 38 |
* `cd /tmp/testfiles` (go to the test file base directory) |
| 39 |
* `sudo python3 -m http.server 80 --bind 0.0.0.0` (start listening on port 80, NOTE: needs to run as root) |
| 40 |
* Alternatively, if you are already have a web server running on port 80, adjust that server's config to serve files statically from your test directory. |
| 41 |
2. Mount your server's challenge directory on your local system (instructions below are for Ubuntu 24.04, adjust as needed). |
| 42 |
* `sudo apt install sshfs` (if not already done, install sshfs) |
| 43 |
* `sshfs [email protected]:/tmp/testfiles/.well-known/acme-challenge /tmp/challenge-files` |
| 44 |
3. Setup a virtual environment for python: |
| 45 |
* `virtualenv -p python3 /tmp/venv` (creates the virtualenv) |
| 46 |
* `source /tmp/venv/bin/activate` (starts using the virtualenv) |
| 47 |
4. Install `acme-tiny` test dependencies: |
| 48 |
* `cd /path/to/acme-tiny` |
| 49 |
* `pip install -U -r tests/requirements.txt` |
| 50 |
5. Run the test suite on your local. |
| 51 |
* `cd /path/to/acme-tiny` |
| 52 |
* `export ACME_TINY_USE_STAGING="1"` |
| 53 |
* `export ACME_TINY_DOMAIN="test.mydomain.com"` |
| 54 |
* `export ACME_TINY_SSHFS_CHALLENGE_DIR="/tmp/challenge-files"` |
| 55 |
* `coverage erase` (removes any previous coverage data files) |
| 56 |
* `coverage run --source . --omit ./setup.py -m unittest tests` (runs the test suite) |
| 57 |
* `coverage report -m` (optional, prints out coverage summary in console) |
| 58 |
* `coverage html` (optional, generates html coverage report you can browse at `htmlcov/index.html`) |
| 59 |
6. When done, unmount the remote directory |
| 60 |
* `umount /tmp/challenge-files` |
| 61 |
|