Browse Source

Add tests for --upgrade and posix error

pull/622/head
Tim Kimber 5 years ago
parent
commit
a749cb4606
No known key found for this signature in database GPG Key ID: 3E1804964E76BD18
3 changed files with 110 additions and 0 deletions
  1. +25
    -0
      test/31-test-posix-error.bats
  2. +78
    -0
      test/32-test-upgrade.bats
  3. +7
    -0
      test/test-config/getssl-http01.cfg

+ 25
- 0
test/31-test-posix-error.bats View File

@ -0,0 +1,25 @@
#! /usr/bin/env bats
load '/bats-support/load.bash'
load '/bats-assert/load.bash'
load '/getssl/test/test_helper.bash'
# This is run for every test
setup() {
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
}
@test "Test that running in POSIX mode shows an error" {
# v2.31 uses read to create an array in the get_auth_dns function which causes a parse error in posix mode
# Could be re-written to not use this functionality if it causes for required.
if [ -n "$STAGING" ]; then
skip "Using staging server, skipping internal test"
fi
run bash --posix "${CODE_DIR}/getssl"
assert_failure
assert_line "getssl: Running with POSIX mode enabled is not supported"
check_output_for_errors
}

+ 78
- 0
test/32-test-upgrade.bats View File

@ -0,0 +1,78 @@
#! /usr/bin/env bats
load '/bats-support/load.bash'
load '/bats-assert/load.bash'
load '/getssl/test/test_helper.bash'
# This is run for every test
setup() {
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
CURRENT_VERSION=$(awk -F '"' '$1 == "VERSION=" {print $2}' ${CODE_DIR}/getssl)
PREVIOUS_VERSION=$(echo ${CURRENT_VERSION} | awk -F. '{ print $1 "." --$2}')
run git clone https://github.com/srvrco/getssl.git "$INSTALL_DIR/upgrade-getssl"
}
teardown() {
rm -r "$INSTALL_DIR/upgrade-getssl"
}
@test "Test that we are told that a newer version is available" {
if [ -n "$STAGING" ]; then
skip "Using staging server, skipping internal test"
fi
cd "$INSTALL_DIR/upgrade-getssl"
git checkout tags/v${PREVIOUS_VERSION}
CONFIG_FILE="getssl-http01.cfg"
setup_environment
init_getssl
cp "${CODE_DIR}/test/test-config/${CONFIG_FILE}" "${INSTALL_DIR}/.getssl/${GETSSL_CMD_HOST}/getssl.cfg"
run "$INSTALL_DIR/upgrade-getssl/getssl" --check-config ${GETSSL_CMD_HOST}
assert_success
#assert_line "Updated getssl from v${PREVIOUS_VERSION} to v${CURRENT_VERSION}"
assert_line "A more recent version (v${CURRENT_VERSION}) of getssl is available, please update"
check_output_for_errors
}
@test "Test that we can upgrade to the newer version" {
if [ -n "$STAGING" ]; then
skip "Using staging server, skipping internal test"
fi
cd "$INSTALL_DIR/upgrade-getssl"
git checkout tags/v${PREVIOUS_VERSION}
CONFIG_FILE="getssl-http01.cfg"
setup_environment
init_getssl
cp "${CODE_DIR}/test/test-config/${CONFIG_FILE}" "${INSTALL_DIR}/.getssl/${GETSSL_CMD_HOST}/getssl.cfg"
run "$INSTALL_DIR/upgrade-getssl/getssl" --check-config --upgrade ${GETSSL_CMD_HOST}
assert_success
assert_line "Updated getssl from v${PREVIOUS_VERSION} to v${CURRENT_VERSION}"
check_output_for_errors
}
@test "Test that we can upgrade to the newer version when invoking as \"bash ./getssl\"" {
# Note that `bash getssl` will fail if the CWD isn't in the PATH and an upgrade occurs
if [ -n "$STAGING" ]; then
skip "Using staging server, skipping internal test"
fi
cd "$INSTALL_DIR/upgrade-getssl"
git checkout tags/v${PREVIOUS_VERSION}
CONFIG_FILE="getssl-http01.cfg"
setup_environment
init_getssl
cp "${CODE_DIR}/test/test-config/${CONFIG_FILE}" "${INSTALL_DIR}/.getssl/${GETSSL_CMD_HOST}/getssl.cfg"
run bash ./getssl --check-config --upgrade ${GETSSL_CMD_HOST}
assert_success
assert_line "Updated getssl from v${PREVIOUS_VERSION} to v${CURRENT_VERSION}"
check_output_for_errors
}

+ 7
- 0
test/test-config/getssl-http01.cfg View File

@ -27,3 +27,10 @@ RELOAD_CMD="cp /getssl/test/test-config/nginx-ubuntu-ssl ${NGINX_CONFIG} && /get
# Define the server type and confirm correct certificate is installed
SERVER_TYPE="https"
CHECK_REMOTE="true"
if [[ -s "$DOMAIN_DIR/getssl_test_specific.cfg" ]]; then
. $DOMAIN_DIR/getssl_test_specific.cfg
fi
#_USE_DEBUG=1
#_RUNNING_TEST=1

Loading…
Cancel
Save