Browse Source

Show curl error if obtain_ca_resource_location fails

pull/710/head
Tim Kimber 4 years ago
parent
commit
99c2854919
No known key found for this signature in database GPG Key ID: 3E1804964E76BD18
3 changed files with 42 additions and 2 deletions
  1. +12
    -1
      getssl
  2. +29
    -0
      test/0-test-curl-error.bats
  3. +1
    -1
      test/32-test-upgrade.bats

+ 12
- 1
getssl View File

@ -2118,11 +2118,22 @@ json_get() { # get values from json
obtain_ca_resource_locations()
{
CURL_RESPONSE_FILE="$(mktemp 2>/dev/null || mktemp -t getssl.XXXXXX)"
for suffix in "" "/directory" "/dir";
do
# Obtain CA resource locations
# shellcheck disable=SC2086
ca_all_loc=$(curl ${_NOMETER} --user-agent "$CURL_USERAGENT" "${CA}${suffix}" 2>/dev/null)
ca_all_loc=$(curl ${_NOMETER} --user-agent "$CURL_USERAGENT" "${CA}${suffix}" 2> $CURL_RESPONSE_FILE)
errcode=$?
if [[ $errcode -ne 0 ]]; then
response=$(cat "$CURL_RESPONSE_FILE")
rm "$CURL_RESPONSE_FILE"
error_exit "ERROR curl \"$CA$suffix\" failed with $errcode and returned:\n$response"
else
rm "$CURL_RESPONSE_FILE"
fi
debug "ca_all_loc from ${CA}${suffix} gives $ca_all_loc"
# APIv1
URL_new_reg=$(echo "$ca_all_loc" | grep "new-reg" | awk -F'"' '{print $4}')


+ 29
- 0
test/0-test-curl-error.bats View File

@ -0,0 +1,29 @@
#! /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
teardown() {
[ -n "$BATS_TEST_COMPLETED" ] || touch $BATS_RUN_TMPDIR/failed.skip
}
setup() {
[ ! -f $BATS_RUN_TMPDIR/failed.skip ] || skip "skipping tests after first failure"
#export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt
}
@test "Run getssl without pebble certificates to check the error message" {
if [ -n "$STAGING" ]; then
skip "Using staging server, skipping internal test"
fi
CONFIG_FILE="getssl-http01.cfg"
setup_environment
init_getssl
create_certificate
refute_line "getssl: unknown API version"
assert_failure
}

+ 1
- 1
test/32-test-upgrade.bats View File

@ -161,7 +161,7 @@ teardown() {
# Check for current tag or file version otherwise push to master fails on a new version (or if the tag hasn't been updated)
assert_line --regexp "Installed v(${CURRENT_TAG}|${FILE_VERSION}), restarting"
assert_line "Configuration check successful"
assert_line --partial "Configuration check successful"
}


Loading…
Cancel
Save