Skip to content

Commit

Permalink
Make first fail global
Browse files Browse the repository at this point in the history
The first fail logic seems scoped to a single test file.

Set the flag globally.
Since the tests run in a container, cleanup is automagic.
  • Loading branch information
tlhackque committed Aug 3, 2021
1 parent ea83139 commit 84d9cc6
Show file tree
Hide file tree
Showing 52 changed files with 131 additions and 116 deletions.
4 changes: 4 additions & 0 deletions getssl
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,10 @@ error_exit() { # give error message on error exit
if [[ ${_RUNNING_TEST} -eq 1 ]] || [[ ${_USE_DEBUG} -eq 1 ]] ; then
traceback
fi
debug "error_exit calling clean_up"
debug "$TEMP_DIR $(find "$TEMP_DIR")"
clean_up
debug "error_exit clean_up returned"
exit 1
}

Expand Down Expand Up @@ -2432,6 +2435,7 @@ traceback() { # Print function traceback
debug "$(printf "%*s%s() line %d%s\n" "$d" '' "${FUNCNAME[$i]}" "${BASH_LINENO[$((i-1))]}" "$lbl")"
((d++))
done
return 0
}

urlbase64() { # urlbase64: base64 encoded string with '+' replaced with '-' and '/' replaced with '_'
Expand Down
4 changes: 2 additions & 2 deletions test/1-simple-http01-dig.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ load '/getssl/test/test_helper.bash'

# This is run for every test
setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
if [ -f /usr/bin/host ]; then
mv /usr/bin/host /usr/bin/host.getssl.bak
Expand All @@ -19,7 +19,7 @@ setup() {


teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
if [ -f /usr/bin/host.getssl.bak ]; then
mv /usr/bin/host.getssl.bak /usr/bin/host
fi
Expand Down
4 changes: 2 additions & 2 deletions test/1-simple-http01-nslookup.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ load '/getssl/test/test_helper.bash'

# This is run for every test
setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
if [ -f /usr/bin/dig ]; then
mv /usr/bin/dig /usr/bin/dig.getssl.bak
Expand All @@ -19,7 +19,7 @@ setup() {


teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
if [ -f /usr/bin/dig.getssl.bak ]; then
mv /usr/bin/dig.getssl.bak /usr/bin/dig
fi
Expand Down
4 changes: 2 additions & 2 deletions test/1-simple-http01-two-acl.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ load '/getssl/test/test_helper.bash'

# This is run for every test
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
}

setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
}

Expand Down
4 changes: 2 additions & 2 deletions test/1-simple-http01.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ load '/getssl/test/test_helper.bash'

# This is run for every test
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
}

setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
}

Expand Down
4 changes: 2 additions & 2 deletions test/10-mixed-case.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ load '/getssl/test/test_helper.bash'

# This is run for every test
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
}

setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
if [ -z "$STAGING" ]; then
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
fi
Expand Down
4 changes: 2 additions & 2 deletions test/11-test--install.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ load '/getssl/test/test_helper.bash'

# This is run for every test
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
}

setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
}

Expand Down
4 changes: 2 additions & 2 deletions test/11-test-no-domain-storage.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ load '/getssl/test/test_helper.bash'


setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
}
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
}

@test "Check that if domain storage isn't set getssl doesn't try to delete /tmp" {
Expand Down
20 changes: 10 additions & 10 deletions test/12-auto-upgrade-v1.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ load '/getssl/test/test_helper.bash'


setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
}
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
}

@test "Check that auto upgrade to v2 doesn't change pebble url" {
Expand All @@ -27,10 +27,10 @@ teardown() {


setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
}
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
}

@test "Check that auto upgrade to v2 doesn't change v2 staging url" {
Expand All @@ -48,10 +48,10 @@ teardown() {


setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
}
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
}

@test "Check that auto upgrade to v2 doesn't change v2 prod url" {
Expand All @@ -69,10 +69,10 @@ teardown() {


setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
}
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
}

@test "Check that auto upgrade to v2 changes v1 staging to v2 staging url" {
Expand All @@ -90,10 +90,10 @@ teardown() {


setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
}
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
}

@test "Check that auto upgrade to v2 changes v1 prod to v2 prod url" {
Expand Down
4 changes: 2 additions & 2 deletions test/13-notify-valid.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ load '/getssl/test/test_helper.bash'

# This is run for every test
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
}

setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
}

Expand Down
4 changes: 2 additions & 2 deletions test/14-test-revoke.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ load '/getssl/test/test_helper.bash'

# This is run for every test
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
}

setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
if [ -z "$STAGING" ]; then
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
fi
Expand Down
4 changes: 2 additions & 2 deletions test/15-test-revoke-no-suffix.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ load '/getssl/test/test_helper.bash'

# This is run for every test
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
}

setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
if [ -z "$STAGING" ]; then
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
fi
Expand Down
4 changes: 2 additions & 2 deletions test/16-test-bad-acl.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ load '/getssl/test/test_helper.bash'

# This is run for every test
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
}

setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
}

Expand Down
4 changes: 2 additions & 2 deletions test/17-test-spaces-in-sans-dns01.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ load '/getssl/test/test_helper.bash'

# This is run for every test
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
}

setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
if [ -z "$STAGING" ]; then
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
fi
Expand Down
12 changes: 10 additions & 2 deletions test/17-test-spaces-in-sans-http01.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ load '/getssl/test/test_helper.bash'

# This is run for every test
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
echo "# teardown ${BATS_TEST_NAME} Stat $status TC $BATS_TEST_COMPLETED SK $BATS_TEST_SKIPPED" >&3
echo "# teardownsym $(set | grep -P "^\s*BATS_")" >&3
}

setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
echo "# setup ${BATS_TEST_NAME} Stat $status $(ls $BATS_TMPDIR)" >&3

if [ -z "$STAGING" ]; then
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
fi
Expand Down Expand Up @@ -82,11 +86,15 @@ setup() {

init_getssl
create_certificate
echo "# create $status $(set | grep -P "^\s*BATS_")" >&3
assert_success
echo "# success $status" >&3
check_output_for_errors
echo "# output $status" >&3
cleanup_environment

for prefix in a b c; do
curl --silent -X POST -d '{"host":"'$prefix.$GETSSL_HOST'"}' http://10.30.50.3:8055/clear-a
done
echo "# done $status" >&3
}
4 changes: 2 additions & 2 deletions test/18-retry-dns-add.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ load '/getssl/test/test_helper.bash'

# This is run for every test
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
}

setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
}

Expand Down
4 changes: 2 additions & 2 deletions test/19-test-add-to-sans.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ load '/getssl/test/test_helper.bash'

# This is run for every test
setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
if [ -z "$STAGING" ]; then
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
curl --silent -X POST -d '{"host":"a.'$GETSSL_HOST'", "addresses":["'$GETSSL_IP'"]}' http://10.30.50.3:8055/add-a
fi
}

teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
if [ -z "$STAGING" ]; then
curl --silent -X POST -d '{"host":"a.'$GETSSL_HOST'", "addresses":["'$GETSSL_IP'"]}' http://10.30.50.3:8055/clear-a
fi
Expand Down
8 changes: 4 additions & 4 deletions test/2-simple-dns01-dig.bats
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ teardown_file() {


setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
}
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
}

@test "Create new certificate using DNS-01 verification (dig)" {
Expand All @@ -48,10 +48,10 @@ teardown() {


setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
}
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
}

@test "Force renewal of certificate using DNS-01 (dig)" {
Expand Down
4 changes: 2 additions & 2 deletions test/2-simple-dns01-nslookup.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ load '/getssl/test/test_helper.bash'

# This is run for every test
setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
if [ -z "$STAGING" ]; then
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
fi
Expand All @@ -21,7 +21,7 @@ setup() {


teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
if [ -f /usr/bin/dig.getssl.bak ]; then
mv /usr/bin/dig.getssl.bak /usr/bin/dig
fi
Expand Down
4 changes: 2 additions & 2 deletions test/20-wildcard-simple.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ load '/getssl/test/test_helper.bash'

# This is run for every test
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
}

setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
if [ -z "$STAGING" ]; then
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
fi
Expand Down
4 changes: 2 additions & 2 deletions test/21-wildcard-dual-rsa.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ load '/getssl/test/test_helper.bash'

# This is run for every test
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_TMPDIR/failed.skip
}

setup() {
[ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
[ ! -f $BATS_TMPDIR/failed.skip ] || skip "skip remaining tests"
if [ -z "$STAGING" ]; then
export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
fi
Expand Down
Loading

0 comments on commit 84d9cc6

Please sign in to comment.