| 1 | #!/bin/sh |
| 2 | |
| 3 | set -e |
| 4 | |
| 5 | # this helps with running the test outside of the autopkgtest environment |
| 6 | if [ -z "${AUTOPKGTEST_TMP:-}" ]; then |
| 7 | AUTOPKGTEST_TMP="$(mktemp -d --suffix=.autopkgtest)" |
| 8 | fi |
| 9 | if [ -z "${AUTOPKGTEST_ARTIFACTS:-}" ]; then |
| 10 | AUTOPKGTEST_ARTIFACTS=$AUTOPKGTEST_TMP |
| 11 | fi |
| 12 | |
| 13 | # certspotter uses these to override the default ~/.certspotter path. |
| 14 | # We use the environment variables (rather than -watchlist and -state_dir) |
| 15 | # in our systemd service, so it's better to test with these for parity |
| 16 | export CERTSPOTTER_CONFIG_DIR=$AUTOPKGTEST_TMP/certspotter-cfg |
| 17 | export CERTSPOTTER_STATE_DIR=$AUTOPKGTEST_TMP/certspotter |
| 18 | |
| 19 | mkdir $CERTSPOTTER_CONFIG_DIR $CERTSPOTTER_STATE_DIR |
| 20 | |
| 21 | # monitor all domains - this should always have traffic |
| 22 | echo '.' > $CERTSPOTTER_CONFIG_DIR/watchlist |
| 23 | |
| 24 | # start the log from the beginning, and fetch some lines of output, which |
| 25 | # should have plenty of certificates in it |
| 26 | certspotter -no_save -stdout | head -n 500 > $AUTOPKGTEST_ARTIFACTS/stdout |
| 27 | |
| 28 | # now check for at least one logged certificate |
| 29 | grep -q Pubkey $AUTOPKGTEST_ARTIFACTS/stdout |