X-Git-Url: https://git.street.me.uk/andy/dehydrated.git/blobdiff_plain/af2bc7a94f1ca4534a2b0ff860adc616b94256ac..bd9cc5b0c4788d1638e53e71749c4387078dbfb2:/test.sh diff --git a/test.sh b/test.sh index 2e633c9..0d81d69 100755 --- a/test.sh +++ b/test.sh @@ -96,10 +96,10 @@ mkdir -p .acme-challenges/.well-known/acme-challenge ) & # Generate config and create empty domains.txt -echo 'CA="https://testca.kurz.pw/directory"' > config.sh -echo 'LICENSE="https://testca.kurz.pw/terms/v1"' >> config.sh -echo 'WELLKNOWN=".acme-challenges/.well-known/acme-challenge"' >> config.sh -echo 'RENEW_DAYS="14"' >> config.sh +echo 'CA="https://testca.kurz.pw/directory"' > config +echo 'LICENSE="https://testca.kurz.pw/terms/v1"' >> config +echo 'WELLKNOWN=".acme-challenges/.well-known/acme-challenge"' >> config +echo 'RENEW_DAYS="14"' >> config touch domains.txt # Check if help command is working @@ -114,13 +114,13 @@ _CHECK_ERRORLOG _TEST "First run in cron mode, checking if private key is generated and registered" ./letsencrypt.sh --cron > tmplog 2> errorlog || _FAIL "Script execution failed" _CHECK_LOG "Registering account key" -_CHECK_FILE "private_key.pem" +_CHECK_FILE accounts/*/account_key.pem _CHECK_ERRORLOG # Temporarily move config out of the way and try signing certificate by using temporary config location _TEST "Try signing using temporary config location and with domain as command line parameter" -mv config.sh tmp_config.sh -./letsencrypt.sh --cron --domain "${TMP_URL}" --domain "${TMP2_URL}" -f tmp_config.sh > tmplog 2> errorlog || _FAIL "Script execution failed" +mv config tmp_config +./letsencrypt.sh --cron --domain "${TMP_URL}" --domain "${TMP2_URL}" -f tmp_config > tmplog 2> errorlog || _FAIL "Script execution failed" _CHECK_NOT_LOG "Checking domain name(s) of existing cert" _CHECK_LOG "Generating private key" _CHECK_LOG "Requesting challenge for ${TMP_URL}" @@ -129,17 +129,14 @@ _CHECK_LOG "Challenge is valid!" _CHECK_LOG "Creating fullchain.pem" _CHECK_LOG "Done!" _CHECK_ERRORLOG -mv tmp_config.sh config.sh - -# Move private key and add new location to config -mv private_key.pem account_key.pem -echo 'PRIVATE_KEY="./account_key.pem"' >> config.sh +mv tmp_config config # Add third domain to command-lime, should force renewal. _TEST "Run in cron mode again, this time adding third domain, should force renewal." ./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}" @@ -159,6 +156,9 @@ _CHECK_LOG "Checking domain name(s) of existing cert... unchanged." _CHECK_LOG "Skipping renew" _CHECK_ERRORLOG +# Disable private key renew +echo 'PRIVATE_KEY_RENEW="no"' >> config + # 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" @@ -180,12 +180,9 @@ _CHECK_LOG "BEGIN CERTIFICATE" _CHECK_LOG "END CERTIFICATE" _CHECK_NOT_LOG "ERROR" -# Delete account key (not needed anymore) -rm account_key.pem - # Check if renewal works _TEST "Run in cron mode again, to check if renewal works" -echo 'RENEW_DAYS="300"' >> config.sh +echo 'RENEW_DAYS="300"' >> config ./letsencrypt.sh --cron > tmplog 2> errorlog || _FAIL "Script execution failed" _CHECK_LOG "Checking domain name(s) of existing cert... unchanged." _CHECK_LOG "Renewing!"