]> git.street.me.uk Git - andy/dehydrated.git/blobdiff - test.sh
updated docs/wellknown.md
[andy/dehydrated.git] / test.sh
diff --git a/test.sh b/test.sh
index 07166117d8843b4dd6c22adffa1c22d927bb3468..cda8be754a8e420ac13148f9415cb88bde3b6eae 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # Fail early
 set -eu -o pipefail
@@ -17,9 +17,6 @@ _SUBTEST() {
   echo -n " + ${1} "
 }
 _PASS() {
-  if [[ ! -z "$(cat errorlog)" ]]; then
-    _FAIL
-  fi
   echo -e "[\u001B[32mPASS\u001B[0m]"
 }
 _FAIL() {
@@ -143,6 +140,7 @@ _TEST "Run in cron mode again, this time adding third domain, should force renew
 ./letsencrypt.sh --cron --domain "${TMP_URL}" --domain "${TMP2_URL}" --domain "${TMP3_URL}" > tmplog 2> errorlog || _FAIL "Script execution failed"
 _CHECK_LOG "Domain name(s) are not matching!"
 _CHECK_LOG "Forcing renew."
+_CHECK_LOG "Generating private key"
 _CHECK_LOG "Requesting challenge for ${TMP_URL}"
 _CHECK_LOG "Requesting challenge for ${TMP2_URL}"
 _CHECK_LOG "Requesting challenge for ${TMP3_URL}"
@@ -151,14 +149,20 @@ _CHECK_LOG "Creating fullchain.pem"
 _CHECK_LOG "Done!"
 _CHECK_ERRORLOG
 
-# Add domain to domains.txt and run in cron mode again (should find a non-expiring certificate and do nothing)
+# Prepare domains.txt
+# Modify TMP3_URL to be uppercase to check for upper-lower-case mismatch bugs
+echo "${TMP_URL} ${TMP2_URL} $(tr 'a-z' 'A-Z' <<<"${TMP3_URL}")" >> domains.txt
+
+# Run in cron mode again (should find a non-expiring certificate and do nothing)
 _TEST "Run in cron mode again, this time with domain in domains.txt, should find non-expiring certificate"
-echo "${TMP_URL} ${TMP2_URL} ${TMP3_URL}" >> domains.txt
 ./letsencrypt.sh --cron > tmplog 2> errorlog || _FAIL "Script execution failed"
 _CHECK_LOG "Checking domain name(s) of existing cert... unchanged."
-_CHECK_LOG "Skipping!"
+_CHECK_LOG "Skipping renew"
 _CHECK_ERRORLOG
 
+# Disable private key renew
+echo 'PRIVATE_KEY_RENEW="no"' >> config.sh
+
 # Run in cron mode one last time, with domain in domains.txt and force-resign (should find certificate, resign anyway, and not generate private key)
 _TEST "Run in cron mode one last time, with domain in domains.txt and force-resign"
 ./letsencrypt.sh --cron --force > tmplog 2> errorlog || _FAIL "Script execution failed"
@@ -212,5 +216,13 @@ _CHECK_LOG "Done."
 _CHECK_FILE "certs/${TMP_URL}/${REAL_CERT}-revoked"
 _CHECK_ERRORLOG
 
+# Test cleanup command
+_TEST "Cleaning up certificates"
+./letsencrypt.sh --cleanup > tmplog 2> errorlog || _FAIL "Script execution failed"
+_CHECK_LOG "Moving unused file to archive directory: ${TMP_URL}/cert-"
+_CHECK_LOG "Moving unused file to archive directory: ${TMP_URL}/chain-"
+_CHECK_LOG "Moving unused file to archive directory: ${TMP_URL}/fullchain-"
+_CHECK_ERRORLOG
+
 # All done
 exit 0