Skip to content

Commit

Permalink
Fix test errors caused by DNS_CHECK_OPTIONS
Browse files Browse the repository at this point in the history
Use a regexp rather than a partial match to skip any DNS_CHECK_OPTIONS,
which in the current tests create whitespace, but could be anything.

Catch a missing inclusion of DNS_CHECK_OPTIONS for dig CNAME
  • Loading branch information
tlhackque committed May 9, 2021
1 parent e315d87 commit db2ec98
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions getssl
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ check_config() { # check the config files for all obvious errors
# check domain exists using all DNS utilities. DNS_CHECK_OPTIONS may bind IP address or provide TSIG
found_ip=false
if [[ -n "$HAS_DIG_OR_DRILL" ]]; then
debug "DNS lookup using $HAS_DIG_OR_DRILL ${d}"
debug "DNS lookup using $HAS_DIG_OR_DRILL $DNS_CHECK_OPTIONS ${d}"
if [[ "$($HAS_DIG_OR_DRILL $DNS_CHECK_OPTIONS -t SOA "${d}" |grep -c -i "^${d}")" -ge 1 ]]; then
found_ip=true
elif [[ "$($HAS_DIG_OR_DRILL $DNS_CHECK_OPTIONS -t A "${d}"|grep -c -i "^${d}")" -ge 1 ]]; then
Expand Down Expand Up @@ -1389,7 +1389,7 @@ get_auth_dns() { # get the authoritative dns server for a domain (sets primary_n
fi

# Check if domain is a CNAME, first
test_output "Using $HAS_DIG_OR_DRILL CNAME"
test_output "Using $HAS_DIG_OR_DRILL $DNS_CHECK_OPTIONS CNAME"

# Two options here; either dig CNAME will return the CNAME and the NS or just the CNAME
debug Checking for CNAME using "$HAS_DIG_OR_DRILL $DNS_CHECK_OPTIONS CNAME $gad_d $gad_s"
Expand Down
14 changes: 7 additions & 7 deletions test/u1-test-get_auth_dns-dig.bats
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ teardown() {
# Assert that we've found the primary_ns server
assert_output --regexp 'set primary_ns = ns[1-4]+\.duckdns\.org'
# Assert that we had to use dig NS
assert_line --partial 'Using dig NS'
assert_line --regexp 'Using dig.* NS'

# Check all Authoritive DNS servers are returned if requested
CHECK_ALL_AUTH_DNS=true
Expand Down Expand Up @@ -89,8 +89,8 @@ teardown() {
assert_output --regexp 'set primary_ns = ns[1-4]+\.duckdns\.org'

# Assert that we had to use dig NS
assert_line --partial 'Using dig SOA'
refute_line --partial 'Using dig NS'
assert_line --regexp 'Using dig.* SOA'
refute_line --regexp 'Using dig.* NS'

# Check all Authoritive DNS servers are returned if requested
CHECK_ALL_AUTH_DNS=true
Expand Down Expand Up @@ -125,8 +125,8 @@ teardown() {
assert_output --regexp 'set primary_ns = ns.*\.awsdns.*\.com'

# Assert that we found a CNAME and use dig NS
assert_line --partial 'Using dig CNAME'
assert_line --partial 'Using dig NS'
assert_line --regexp 'Using dig.* CNAME'
assert_line --regexp 'Using dig.* NS'

# Check all Authoritive DNS servers are returned if requested
CHECK_ALL_AUTH_DNS=true
Expand Down Expand Up @@ -168,8 +168,8 @@ teardown() {
assert_output --regexp 'set primary_ns = ns[1-4]+\.duckdns\.org'

# Assert that we found a CNAME but didn't use dig NS
assert_line --partial 'Using dig CNAME'
refute_line --partial 'Using dig NS'
assert_line --regexp 'Using dig.* CNAME'
refute_line --regexp 'Using dig.* NS'

# Check all Authoritive DNS servers are returned if requested
CHECK_ALL_AUTH_DNS=true
Expand Down
14 changes: 7 additions & 7 deletions test/u2-test-get_auth_dns-drill.bats
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ teardown() {
# Assert that we've found the primary_ns server
assert_output --regexp 'set primary_ns = ns[1-4]+\.duckdns\.org'
# Assert that we had to use drill NS
assert_line --partial 'Using drill NS'
assert_line --regexp 'Using drill.* NS'

# Check all Authoritive DNS servers are returned if requested
CHECK_ALL_AUTH_DNS=true
Expand Down Expand Up @@ -100,8 +100,8 @@ teardown() {
assert_output --regexp 'set primary_ns = ns[1-4]+\.duckdns\.org'

# Assert that we had to use drill NS
assert_line --partial 'Using drill SOA'
refute_line --partial 'Using drill NS'
assert_line --regexp 'Using drill.* SOA'
refute_line --regexp 'Using drill.* NS'

# Check all Authoritive DNS servers are returned if requested
CHECK_ALL_AUTH_DNS=true
Expand Down Expand Up @@ -141,8 +141,8 @@ teardown() {
assert_output --regexp 'set primary_ns = ns.*\.awsdns.*\.com'

# Assert that we found a CNAME and use drill NS
assert_line --partial 'Using drill CNAME'
assert_line --partial 'Using drill NS'
assert_line --regexp 'Using drill.* CNAME'
assert_line --regexp 'Using drill.* NS'

# Check all Authoritive DNS servers are returned if requested
CHECK_ALL_AUTH_DNS=true
Expand Down Expand Up @@ -192,8 +192,8 @@ teardown() {
assert_output --regexp 'set primary_ns = ns[1-4]+\.duckdns\.org'

# Assert that we found a CNAME but didn't use drill NS
assert_line --partial 'Using drill CNAME'
refute_line --partial 'Using drill NS'
assert_line --regexp 'Using drill.* CNAME'
refute_line --regexp 'Using drill.* NS'

# Check all Authoritive DNS servers are returned if requested
CHECK_ALL_AUTH_DNS=true
Expand Down
4 changes: 2 additions & 2 deletions test/u5-test-get_auth_dns-no-root-servers.bats
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ teardown() {
# Assert that we've found the primary_ns server
assert_output --regexp 'set primary_ns = '
# Assert that we had to use dig NS
assert_line --partial 'Using dig NS'
assert_line --regexp 'Using dig.* NS'

# Check we didn't include any root servers
refute_line --partial 'root-servers.net'
Expand Down Expand Up @@ -89,7 +89,7 @@ teardown() {
# Assert that we've found the primary_ns server
assert_output --regexp 'set primary_ns = '
# Assert that we had to use dig SOA
assert_line --partial 'Using dig SOA'
assert_line --regexp 'Using dig.* SOA'

# Check we didn't include any root servers
refute_line --partial 'root-servers.net'
Expand Down

0 comments on commit db2ec98

Please sign in to comment.