Skip to content

Commit 63171e6

Browse files
authored
Merge pull request #550 from srvrco/test-improvement
Fix domain case conversion for different locales
2 parents 4db955e + 472ea23 commit 63171e6

20 files changed

+76
-95
lines changed

getssl

+8-7
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,13 @@
224224
# 2020-04-16 Add -i|--install command line option (2.23)
225225
# 2020-04-19 Remove dependency on seq, ensure clean_up doesn't try to delete /tmp (2.24)
226226
# 2020-04-20 Check for domain using all DNS utilities (2.25)
227+
# 2020-04-22 Fix HAS_HOST and HAS_NSLOOKUP checks - wolfaba
228+
# 2020-04-22 Fix domain case conversion for different locales (2.26) - glynge
227229
# ----------------------------------------------------------------------------------------
228230

229231
PROGNAME=${0##*/}
230232
PROGDIR="$(cd "$(dirname "$0")" || exit; pwd -P;)"
231-
VERSION="2.25"
233+
VERSION="2.26"
232234

233235
# defaults
234236
ACCOUNT_KEY_LENGTH=4096
@@ -532,14 +534,14 @@ check_config() { # check the config files for all obvious errors
532534
fi
533535
fi
534536

535-
if [[ "$HAS_HOST" == true ]]; then
537+
if [[ "$HAS_HOST" == "true" ]]; then
536538
debug "DNS lookup using host ${d}"
537539
if [[ "$(host "${d}" |grep -c -i "^${d}")" -ge 1 ]]; then
538540
found_ip=true
539541
fi
540542
fi
541543

542-
if [[ "$HAS_NSLOOKUP" == true ]]; then
544+
if [[ "$HAS_NSLOOKUP" == "true" ]]; then
543545
debug "DNS lookup using nslookup -query AAAA ${d}"
544546
if [[ "$(nslookup -query=AAAA "${d}"|grep -c -i "^${d}.*has AAAA address")" -ge 1 ]]; then
545547
debug "found IPv6 record for ${d}"
@@ -863,8 +865,7 @@ create_order() {
863865
dn=0
864866
for d in $alldomains; do
865867
# Convert domain to lowercase as response from server will be in lowercase
866-
# shellcheck disable=SC2018,SC2019
867-
d=$(echo "$d" | tr A-Z a-z)
868+
d=$(echo "$d" | tr "[:upper:]" "[:lower:]")
868869
if [ "$d" == "$authdomain" ]; then
869870
debug "Saving authorization response for $authdomain for domain alldomains[$dn]"
870871
AuthLinkResponse[$dn]=$response
@@ -1260,7 +1261,7 @@ get_auth_dns() { # get the authoritative dns server for a domain (sets primary_n
12601261
fi
12611262
fi
12621263

1263-
if [[ "$HAS_HOST" == true ]]; then
1264+
if [[ "$HAS_HOST" == "true" ]]; then
12641265
gad_d="$orig_gad_d"
12651266
debug Using "host -t NS" to find primary name server for "$gad_d"
12661267
if [[ -z "$gad_s" ]]; then
@@ -1279,7 +1280,7 @@ get_auth_dns() { # get the authoritative dns server for a domain (sets primary_n
12791280
fi
12801281
fi
12811282

1282-
if [[ "$HAS_NSLOOKUP" == true ]]; then
1283+
if [[ "$HAS_NSLOOKUP" == "true" ]]; then
12831284
gad_d="$orig_gad_d"
12841285
debug Using "nslookup -debug -type=soa -type=ns $gad_d $gad_s" to find primary name server
12851286
res=$(nslookup -debug -type=soa -type=ns "$gad_d" ${gad_s})

test/1-simple-http01.bats

+2-6
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ setup() {
2020
init_getssl
2121
create_certificate
2222
assert_success
23-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
24-
refute_output --regexp '[Ee][Rr][Rr][Oo][Rr]'
25-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg]'
23+
check_output_for_errors
2624
}
2725

2826

@@ -32,8 +30,6 @@ setup() {
3230
fi
3331
run ${CODE_DIR}/getssl -f $GETSSL_HOST
3432
assert_success
35-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
36-
refute_output --regexp '[Ee][Rr][Rr][Oo][Rr]'
37-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg]'
33+
check_output_for_errors
3834
cleanup_environment
3935
}

test/10-mixed-case-staging.bats

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,5 @@ load '/getssl/test/test_helper.bash'
1818
create_certificate
1919

2020
assert_success
21-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
22-
refute_output --regexp '[Ee][Rr][Rr][Oo][Rr]'
23-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg]'
21+
check_output_for_errors
2422
}

test/10-mixed-case.bats

+2-6
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ setup() {
2323
create_certificate
2424

2525
assert_success
26-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
27-
refute_output --regexp '[Ee][Rr][Rr][Oo][Rr]'
28-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg]'
26+
check_output_for_errors
2927
}
3028

3129
@test "Check that DNS-01 verification works if the domain is not lowercase" {
@@ -39,7 +37,5 @@ setup() {
3937
init_getssl
4038
create_certificate
4139
assert_success
42-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
43-
refute_output --regexp '[Ee][Rr][Rr][Oo][Rr]'
44-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg]'
40+
check_output_for_errors
4541
}

test/11-test--install.bats

+2-6
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ setup() {
3232
run ${CODE_DIR}/getssl "$GETSSL_CMD_HOST"
3333

3434
assert_success
35-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
36-
refute_output --regexp '[Ee][Rr][Rr][Oo][Rr]'
37-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg]'
35+
check_output_for_errors
3836
assert_line 'Verification completed, obtaining certificate.'
3937
assert_line 'Requesting certificate'
4038
refute [ -d '$HOME/.getssl' ]
@@ -53,9 +51,7 @@ setup() {
5351
run ${CODE_DIR}/getssl --install "$GETSSL_CMD_HOST"
5452

5553
assert_success
56-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
57-
refute_output --regexp '[Ee][Rr][Rr][Oo][Rr]'
58-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg]'
54+
check_output_for_errors
5955
refute_line 'Verification completed, obtaining certificate.'
6056
refute_line 'Requesting certificate'
6157
assert_line --partial 'copying domain certificate to'

test/11-test-no-domain-storage.bats

+1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ load '/getssl/test/test_helper.bash'
1515
cp "${CODE_DIR}/test/test-config/${CONFIG_FILE}" "${INSTALL_DIR}/.getssl/getssl.cfg"
1616
run ${CODE_DIR}/getssl -a
1717
assert_success
18+
check_output_for_errors
1819
assert_line 'Not going to delete TEMP_DIR ///tmp as it appears to be /tmp'
1920
}

test/2-simple-dns01-dig.bats

+2-6
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ setup() {
2222
create_certificate -d
2323
assert_success
2424
assert_output --partial "dig"
25-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
26-
refute_output --regexp '[^:][Ee][Rr][Rr][Oo][Rr][^:]' # don't fail for :error:badNonce
27-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg]'
25+
check_output_for_errors "debug"
2826
}
2927

3028

@@ -35,8 +33,6 @@ setup() {
3533
run ${CODE_DIR}/getssl -d -f $GETSSL_HOST
3634
assert_success
3735
assert_output --partial "dig"
38-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
39-
refute_output --regexp '[^:][Ee][Rr][Rr][Oo][Rr][^:]' # don't fail for :error:badNonce
40-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg]'
36+
check_output_for_errors "debug"
4137
cleanup_environment
4238
}

test/2-simple-dns01-nslookup.bats

+1-4
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,5 @@ teardown() {
3232
create_certificate -d
3333
assert_success
3434
assert_output --partial "nslookup"
35-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
36-
refute_output --regexp '[^:][Ee][Rr][Rr][Oo][Rr][^:]' # don't fail for :error:badNonce
37-
# don't check for "Warnings:" as there might be a warning message if nslookup doesn't support -debug (alpine/ubuntu)
38-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg][^:]'
35+
check_output_for_errors "debug"
3936
}

test/3-dual-rsa-ecdsa.bats

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ setup() {
2020
init_getssl
2121
create_certificate
2222
assert_success
23+
check_output_for_errors
2324
}
2425

2526

@@ -29,6 +30,7 @@ setup() {
2930
fi
3031
run ${CODE_DIR}/getssl -f $GETSSL_HOST
3132
assert_success
33+
check_output_for_errors
3234
}
3335

3436
@test "Create dual certificates using DNS-01 verification" {
@@ -40,6 +42,7 @@ setup() {
4042
init_getssl
4143
create_certificate
4244
assert_success
45+
check_output_for_errors
4346
}
4447

4548

@@ -49,5 +52,6 @@ setup() {
4952
fi
5053
run ${CODE_DIR}/getssl -f $GETSSL_HOST
5154
assert_success
55+
check_output_for_errors
5256
cleanup_environment
5357
}

test/4-more-than-10-hosts.bats

+2-6
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ setup() {
2626
init_getssl
2727
create_certificate
2828
assert_success
29-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
30-
refute_output --regexp '[Ee][Rr][Rr][Oo][Rr]'
31-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg]'
29+
check_output_for_errors
3230
}
3331

3432

@@ -38,9 +36,7 @@ setup() {
3836
fi
3937
run ${CODE_DIR}/getssl -f $GETSSL_HOST
4038
assert_success
41-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
42-
refute_output --regexp '[Ee][Rr][Rr][Oo][Rr]'
43-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg]'
39+
check_output_for_errors
4440
# Remove all the dns aliases
4541
cleanup_environment
4642
for prefix in a b c d e f g h i j k; do

test/5-secp384-http01.bats

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ setup() {
2020
init_getssl
2121
create_certificate
2222
assert_success
23+
check_output_for_errors
2324
}
2425

2526

@@ -29,6 +30,7 @@ setup() {
2930
fi
3031
run ${CODE_DIR}/getssl -f $GETSSL_HOST
3132
assert_success
33+
check_output_for_errors
3234
}
3335

3436

@@ -41,6 +43,7 @@ setup() {
4143
init_getssl
4244
create_certificate
4345
assert_success
46+
check_output_for_errors
4447
}
4548

4649

@@ -50,4 +53,5 @@ setup() {
5053
fi
5154
run ${CODE_DIR}/getssl -f $GETSSL_HOST
5255
assert_success
56+
check_output_for_errors
5357
}

test/6-dual-rsa-ecdsa-copy-2-locations.bats

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ teardown() {
3232
init_getssl
3333
create_certificate
3434
assert_success
35+
check_output_for_errors
3536

3637
# Check that the RSA chain and key have been copied to both locations
3738
assert [ -e "/etc/nginx/pki/domain-chain.crt" ]

test/7-staging-dns01-dig.bats

+2-6
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ load '/getssl/test/test_helper.bash'
1616
init_getssl
1717
create_certificate
1818
assert_success
19-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
20-
refute_output --regexp '[Ee][Rr][Rr][Oo][Rr]'
21-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg]'
19+
check_output_for_errors
2220
}
2321

2422
@test "Force renewal of certificate using staging server, dig and DuckDNS" {
@@ -27,8 +25,6 @@ load '/getssl/test/test_helper.bash'
2725
fi
2826
run ${CODE_DIR}/getssl -f $GETSSL_HOST
2927
assert_success
30-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
31-
refute_output --regexp '[Ee][Rr][Rr][Oo][Rr]'
32-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg]'
28+
check_output_for_errors
3329
cleanup_environment
3430
}

test/7-staging-dns01-nslookup.bats

+2-6
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ teardown() {
3030
init_getssl
3131
create_certificate
3232
assert_success
33-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
34-
refute_output --regexp '[Ee][Rr][Rr][Oo][Rr]'
35-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg][^:]' # ignore nslookup warnings
33+
check_output_for_errors "debug"
3634
}
3735

3836

@@ -42,8 +40,6 @@ teardown() {
4240
fi
4341
run ${CODE_DIR}/getssl -f $GETSSL_HOST
4442
assert_success
45-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
46-
refute_output --regexp '[Ee][Rr][Rr][Oo][Rr]'
47-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg][^:]' # ignore nslookup warnings
43+
check_output_for_errors "debug"
4844
cleanup_environment
4945
}

test/8-staging-ecdsa.bats

+4-12
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ load '/getssl/test/test_helper.bash'
1818
sed -e 's/rsa/prime256v1/g' < "${CODE_DIR}/test/test-config/${CONFIG_FILE}" > "${INSTALL_DIR}/.getssl/${GETSSL_HOST}/getssl.cfg"
1919
run ${CODE_DIR}/getssl -d "$GETSSL_HOST"
2020
assert_success
21-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
22-
refute_output --regexp '[^:][Ee][Rr][Rr][Oo][Rr][^:]'
23-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg][^:]' # ignore nslookup warnings
21+
check_output_for_errors "debug"
2422
}
2523

2624

@@ -30,9 +28,7 @@ load '/getssl/test/test_helper.bash'
3028
fi
3129
run ${CODE_DIR}/getssl -d -f $GETSSL_HOST
3230
assert_success
33-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
34-
refute_output --regexp '[^:][Ee][Rr][Rr][Oo][Rr][^:]'
35-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg][^:]' # ignore nslookup warnings
31+
check_output_for_errors "debug"
3632
cleanup_environment
3733
}
3834

@@ -48,9 +44,7 @@ load '/getssl/test/test_helper.bash'
4844
sed -e 's/rsa/secp384r1/g' < "${CODE_DIR}/test/test-config/${CONFIG_FILE}" > "${INSTALL_DIR}/.getssl/${GETSSL_HOST}/getssl.cfg"
4945
run ${CODE_DIR}/getssl -d "$GETSSL_HOST"
5046
assert_success
51-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
52-
refute_output --regexp '[^:][Ee][Rr][Rr][Oo][Rr][^:]'
53-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg][^:]'
47+
check_output_for_errors "debug"
5448
}
5549

5650

@@ -60,9 +54,7 @@ load '/getssl/test/test_helper.bash'
6054
fi
6155
run ${CODE_DIR}/getssl -d -f $GETSSL_HOST
6256
assert_success
63-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
64-
refute_output --regexp '[^:][Ee][Rr][Rr][Oo][Rr][^:]'
65-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg][^:]'
57+
check_output_for_errors "debug"
6658
cleanup_environment
6759
}
6860

test/9-multiple-domains-dns01.bats

+3-9
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ setup() {
2525
init_getssl
2626
create_certificate
2727
assert_success
28-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
29-
refute_output --regexp '[Ee][Rr][Rr][Oo][Rr]'
30-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg]'
28+
check_output_for_errors
3129
}
3230

3331

@@ -38,9 +36,7 @@ setup() {
3836
fi
3937
run ${CODE_DIR}/getssl -f $GETSSL_HOST
4038
assert_success
41-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
42-
refute_output --regexp '[Ee][Rr][Rr][Oo][Rr]'
43-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg]'
39+
check_output_for_errors
4440
# Remove all the dns aliases
4541
cleanup_environment
4642
curl --silent -X POST -d '{"host":"getssl.tst"}' http://10.30.50.3:8055/clear-a
@@ -60,7 +56,5 @@ setup() {
6056
init_getssl
6157
create_certificate
6258
assert_success
63-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
64-
refute_output --regexp '[Ee][Rr][Rr][Oo][Rr]'
65-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg]'
59+
check_output_for_errors
6660
}

test/9-test--all.bats

+1-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,5 @@ setup() {
2828

2929
# Check success conditions
3030
assert_success
31-
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
32-
refute_output --regexp '[Ee][Rr][Rr][Oo][Rr]'
33-
refute_output --regexp '[Ww][Aa][Rr][Nn][Ii][Nn][Gg]'
31+
check_output_for_errors
3432
}

test/Dockerfile-ubuntu

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ FROM ubuntu:latest
22

33
# Note this image uses mawk1.3
44

5+
# Set noninteractive otherwise tzdata hangs
6+
ENV DEBIAN_FRONTEND noninteractive
7+
58
# Update and install required software
69
RUN apt-get update --fix-missing
710
RUN apt-get install -y git curl dnsutils wget nginx-light

0 commit comments

Comments
 (0)