diff --git a/getssl b/getssl index b77cf07..f0a289c 100755 --- a/getssl +++ b/getssl @@ -267,6 +267,7 @@ # 2021-07-25 Fix copy_file_to_location failures with ssh when suffix applied to file lacking an extension (tlhackque)(#686) # 2021-07-27 Support ftps://, FTPS_OPTIONS, remove default --insecure parameter to ftpes. Report caller(s) of error_exit in debug and test modes (tlhackque)(#687)(2.39) # 2021-07-30 Prefer API V2 when both offered (tlhackque) (#690) (2.40) +# 2021-07-30 Run tests with -d to catch intermittent failures, Use fork's repo for upgrade tests. (tlhackque) (#692) (2.41) # ---------------------------------------------------------------------------------------- case :$SHELLOPTS: in @@ -275,7 +276,7 @@ esac PROGNAME=${0##*/} PROGDIR="$(cd "$(dirname "$0")" || exit; pwd -P;)" -VERSION="2.40" +VERSION="2.41" # defaults ACCOUNT_KEY_LENGTH=4096 @@ -285,7 +286,11 @@ CA="https://acme-staging-v02.api.letsencrypt.org/directory" CHALLENGE_CHECK_TYPE="http" CHECK_REMOTE_WAIT=0 CHECK_REMOTE="true" -CODE_LOCATION="https://raw.githubusercontent.com/srvrco/getssl/master/getssl" +if [[ -n "${GITHUB_REPOSITORY}" ]] ; then + CODE_LOCATION="https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/master/getssl" +else + CODE_LOCATION="https://raw.githubusercontent.com/srvrco/getssl/master/getssl" +fi CSR_SUBJECT="/" CURL_USERAGENT="${PROGNAME}/${VERSION}" DEACTIVATE_AUTH="false" @@ -1798,7 +1803,7 @@ get_signing_params() { # get signing parameters from key } graceful_exit() { # normal exit function. - exit_code=$1 + exit_code="${1-0}" clean_up # shellcheck disable=SC2086 exit $exit_code @@ -2415,14 +2420,18 @@ signal_exit() { # Handle trapped signals esac } +test_setup() { # setup for running test + _USE_DEBUG=1 +} + traceback() { # Print function traceback - local i d=1 lbl=" called" - echo "Traceback" >&2 - for ((i=$((${#FUNCNAME[@]}-1)); i>0; i--)); do - if [[ ${i} -eq 1 ]] ; then lbl=" called traceback" ; fi - printf "%*s%s() line %d%s\n" "$d" '' "${FUNCNAME[$i]}" "${BASH_LINENO[$((i-1))]}" "$lbl" >&2 - ((d++)) - done + local i d=1 lbl=" called" + debug "Traceback" + for ((i=$((${#FUNCNAME[@]}-1)); i>0; i--)); do + if [[ ${i} -eq 1 ]] ; then lbl=" called traceback" ; fi + debug "$(printf "%*s%s() line %d%s\n" "$d" '' "${FUNCNAME[$i]}" "${BASH_LINENO[$((i-1))]}" "$lbl")" + ((d++)) + done } urlbase64() { # urlbase64: base64 encoded string with '+' replaced with '-' and '/' replaced with '_' @@ -2627,6 +2636,12 @@ write_openssl_conf() { # write out a minimal openssl conf trap "signal_exit TERM" TERM HUP trap "signal_exit INT" INT +# When running tests, use debug mode to capture intermittent faults +# Test harness will Save output in a temporary file, which is displayed if an error occurs +if [[ ${_RUNNING_TEST} -eq 1 ]] ; then + test_setup +fi + # Parse command-line while [[ -n ${1+defined} ]]; do case $1 in diff --git a/test/32-test-upgrade.bats b/test/32-test-upgrade.bats index f8fc68a..48edf85 100644 --- a/test/32-test-upgrade.bats +++ b/test/32-test-upgrade.bats @@ -11,7 +11,12 @@ setup() { # Turn off warning about detached head git config --global advice.detachedHead false - run git clone https://github.com/srvrco/getssl.git "$INSTALL_DIR/upgrade-getssl" + if [[ -n "${GITHUB_REPOSITORY}" ]] ; then + _REPO="https://github.com/${GITHUB_REPOSITORY}.git" + else + _REPO="https://github.com/srvrco/getssl.git" + fi + run git clone "${_REPO}" "$INSTALL_DIR/upgrade-getssl" # Don't do version arithmetics any longer, look what was the previous version by getting the last # line (starting with v) and the one before that from the list of tags. diff --git a/test/run-test.sh b/test/run-test.sh index c3852ef..76a7555 100755 --- a/test/run-test.sh +++ b/test/run-test.sh @@ -37,6 +37,7 @@ docker run \ --env GETSSL_HOST=$ALIAS $STAGING \ --env GETSSL_IDN_HOST=$GETSSL_IDN_HOST \ --env GETSSL_OS=$GETSSL_OS \ + --env GITHUB_REPOSITORY="${GITHUB_REPOSITORY}" \ -v "$(pwd)":/getssl \ --rm \ --network ${PWD##*/}_acmenet \ diff --git a/test/test_helper.bash b/test/test_helper.bash index ea71967..0827adf 100644 --- a/test/test_helper.bash +++ b/test/test_helper.bash @@ -25,7 +25,7 @@ check_nginx() { check_output_for_errors() { refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]' # less strict tests if running with debug output - if [ -n "$1" ]; then + if [ -n "X$1" ]; then # don't fail for :error:badNonce refute_output --regexp '[^:][Ee][Rr][Rr][Oo][Rr][^:]' # don't check for "Warnings:" as there might be a warning message if nslookup doesn't support -debug (alpine/ubuntu) @@ -47,12 +47,12 @@ create_certificate() { # Create certificate cp "${CODE_DIR}/test/test-config/${CONFIG_FILE}" "${INSTALL_DIR}/.getssl/${GETSSL_CMD_HOST}/getssl.cfg" # shellcheck disable=SC2086 - run ${CODE_DIR}/getssl "$@" "$GETSSL_CMD_HOST" + run ${CODE_DIR}/getssl -d "$@" "$GETSSL_CMD_HOST" } init_getssl() { # Run initialisation (create account key, etc) - run ${CODE_DIR}/getssl -c "$GETSSL_CMD_HOST" + run ${CODE_DIR}/getssl -d -c "$GETSSL_CMD_HOST" assert_success [ -d "$INSTALL_DIR/.getssl" ] }