Skip to content

Commit

Permalink
skip some tests if dig and nslookup are not available
Browse files Browse the repository at this point in the history
  • Loading branch information
matteocorti committed Nov 21, 2023
1 parent bf4d5ff commit 8e2922b
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 78 deletions.
100 changes: 50 additions & 50 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ authors:
- family-names: "Corti"
given-names: "Matteo"
orcid: "https://orcid.org/0000-0002-1746-1108"
- family-names: "Палаузов"
given-names: "Дилян"
website: https://github.com/dilyanpalauzov
- name: Alexander Aleksandrovič Klimov
website: https://github.com/Al2Klimov
- family-names: "Klärner"
Expand All @@ -14,12 +17,20 @@ authors:
- family-names: "Miśkiewicz"
given-names: "Arkadiusz"
website: https://github.com/arekm
- name: barakAtSoluto
website: https://github.com/barakAtSoluto
- family-names: "Byrne"
given-names: "Ben"
website: https://github.com/benbyr
- family-names: "Strößenreuther"
given-names: "Bernd"
website: https://github.com/booboo-at-gluga-de
- name: booboo-at-gluga-de
website: https://github.com/booboo-at-gluga-de
- name: cbiedl
website: https://github.com/cbiedl
- name: chornberger-c2c
website: https://github.com/chornberger-c2c
- family-names: "Ruppert"
given-names: "Christian"
- family-names: "Moench-Tegeder"
Expand All @@ -28,42 +39,62 @@ authors:
- family-names: "Kuenzler"
given-names: "Claudio"
website: https://github.com/Napsty
- name: claudioth
website: https://github.com/claudioth
- family-names: "Riegg"
given-names: "Claus-Theodor"
website: https://github.com/ctriegg-mak
- family-names: "Smith"
given-names: "Colin"
- name: d7415
website: https://github.com/d7415
- family-names: "Pritts"
given-names: "Dan"
- family-names: "Wallis"
given-names: "Dan"
- family-names: "Visser"
given-names: "Dick"
website: https://github.com/dnmvisser
- name: dupondje
website: https://github.com/dupondje
- family-names: "Sabol"
given-names: "Ed"
website: https://github.com/esabol
- name: eeertel
website: https://github.com/eeertel
- name: eimamagi
website: https://github.com/eimamagi
- family-names: "Ertel"
given-names: "Emilian"
- family-names: "Apolloner"
given-names: "Florian"
website: https://github.com/apollo13
- name: Georg
website: https://github.com/gbotti
- name: grizzlydev-sarl
website: https://github.com/grizzlydev-sarl
- name: iasdeoupxe
website: https://github.com/iasdeoupxe
- family-names: "Mironov"
given-names: "Igor"
website: https://github.com/mcs6502
- family-names: "Hablutzel"
given-names: "Jaime"
website: https://github.com/hablutzel1
- name: jalbstmeijer
website: https://github.com/jalbstmeijer
- name: Jalonet
website: https://github.com/jalonet
- family-names: "Gonel"
given-names: "Javier"
- family-names: "Lecour"
given-names: "Jérémy"
- name: jf-vf
website: https://github.com/jf-vf
- family-names: "Hopp"
given-names: "Jim"
- name: jmuecke
website: https://github.com/jmuecke
- family-names: "Meurer"
given-names: "Jonas"
website: https://github.com/mejo-
Expand All @@ -73,6 +104,8 @@ authors:
- family-names: "Thalheim"
given-names: "Jörg"
website: https://github.com/Mic92
- name: juckerf
website: https://github.com/juckerf
- family-names: "McCormack"
given-names: "Kenny"
- family-names: "Jahn"
Expand All @@ -89,6 +122,9 @@ authors:
- family-names: "Tribus"
given-names: "Lukas"
website: https://github.com/lukastribus
- family-names: "Wąsikowski"
given-names: "Łukasz"
website: https://github.com/IdahoPL
- family-names: "Fournier"
given-names: "Marc"
- family-names: "Burkhalter"
Expand Down Expand Up @@ -123,8 +159,6 @@ authors:
- family-names: "Lafont"
given-names: "Nicolas"
website: https://github.com/ManicoW
- name: PSSGCSim
website: https://github.com/PSSGCSim
- family-names: "Rochnyak"
given-names: "Pavel"
website: https://github.com/rpv-tomsk
Expand All @@ -138,6 +172,8 @@ authors:
- family-names: "Rupert"
given-names: "Pim"
website: https://github.com/prupert
- name: PSSGCSim
website: https://github.com/PSSGCSim
- family-names: "Thoma"
given-names: "Raphael"
- family-names: "Bartels"
Expand Down Expand Up @@ -167,8 +203,12 @@ authors:
- family-names: "Shmanko"
given-names: "Sergei"
website: https://github.com/sshmanko
- name: skanx
website: https://github.com/skanx
- name: Slavko
website: https://github.com/slavkoja
- name: sokol-44
website: https://github.com/sokol-44
- family-names: "Schlesinger"
given-names: "Stefan"
- family-names: "Nierlein"
Expand All @@ -184,6 +224,8 @@ authors:
website: https://github.com/d7031
- name: Tone
website: https://github.com/anthonyhaussman
- name: tunnelpr0
website: https://github.com/tunnelpr0
- family-names: "Haarala"
given-names: "Tuomas"
- family-names: "Heidelberger"
Expand All @@ -200,62 +242,20 @@ authors:
- family-names: "Horky"
given-names: "Vojtech"
website: https://github.com/vhotspur
- name: waja
website: https://github.com/waja
- name: Wim van Ravesteijn
website: https://github.com/wimvr
- family-names: "Schricker"
given-names: "Wolfgang"
- family-names: "Gravel"
given-names: "Yannick"
- name: Zadkiel
website: https://github.com/aslafy-z
- name: barakAtSoluto
website: https://github.com/barakAtSoluto
- name: booboo-at-gluga-de
website: https://github.com/booboo-at-gluga-de
- name: cbiedl
website: https://github.com/cbiedl
- name: chornberger-c2c
website: https://github.com/chornberger-c2c
- name: claudioth
website: https://github.com/claudioth
- name: d7415
website: https://github.com/d7415
- name: dupondje
website: https://github.com/dupondje
- name: eeertel
website: https://github.com/eeertel
- name: eimamagi
website: https://github.com/eimamagi
- name: grizzlydev-sarl
website: https://github.com/grizzlydev-sarl
- name: iasdeoupxe
website: https://github.com/iasdeoupxe
- name: jalbstmeijer
website: https://github.com/jalbstmeijer
- name: jf-vf
website: https://github.com/jf-vf
- name: jmuecke
website: https://github.com/jmuecke
- name: juckerf
website: https://github.com/juckerf
- name: skanx
website: https://github.com/skanx
- name: sokol-44
website: https://github.com/sokol-44
- name: tunnelpr0
website: https://github.com/tunnelpr0
- name: waja
website: https://github.com/waja
- name: xert
website: https://github.com/xert
- family-names: "Gravel"
given-names: "Yannick"
- name: yasirathackersdotmu
website: https://github.com/yasirathackersdotmu
- family-names: "Wąsikowski"
given-names: "Łukasz"
website: https://github.com/IdahoPL
- family-names: "Палаузов"
given-names: "Дилян"
website: https://github.com/dilyanpalauzov
- name: Zadkiel
website: https://github.com/aslafy-z
title: "check_ssl_cert"
version: 2.76.0
date-released: 2023-10-30
Expand Down
76 changes: 48 additions & 28 deletions test/integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ oneTimeSetUp() {
"${GREP_BIN}" -V
fi

DIG_BIN=$(command -v dig)
NSLOOKUP_BIN=$( command -v nslookup )
true # if the last variable is empty the setup will fail

}

seconds2String() {
Expand Down Expand Up @@ -1040,29 +1044,37 @@ testCertificateWithEmptySubject() {
# see #449
testNotExistingHosts() {

# shellcheck disable=SC2086
OUTPUT=$( ${SCRIPT} ${TEST_DEBUG} --rootcert-file cabundle.crt --host li )
EXIT_CODE=$?
assertEquals "wrong exit code" "${NAGIOS_CRITICAL}" "${EXIT_CODE}"
assertContains "wrong error message" "${OUTPUT}" "Cannot resolve"
if [ -n "${NSLOOKUP_BIN}" ] ; then

# shellcheck disable=SC2086
OUTPUT=$( ${SCRIPT} ${TEST_DEBUG} --rootcert-file cabundle.crt --host li --do-not-resolve )
EXIT_CODE=$?
assertEquals "wrong exit code" "${NAGIOS_CRITICAL}" "${EXIT_CODE}"
assertContains "wrong error message" "${OUTPUT}" "Cannot connect"
# shellcheck disable=SC2086
OUTPUT=$( ${SCRIPT} ${TEST_DEBUG} --rootcert-file cabundle.crt --host li )
EXIT_CODE=$?
assertEquals "wrong exit code" "${NAGIOS_CRITICAL}" "${EXIT_CODE}"
assertContains "wrong error message" "${OUTPUT}" "Cannot resolve"

# shellcheck disable=SC2086
OUTPUT=$( ${SCRIPT} ${TEST_DEBUG} --rootcert-file cabundle.crt --host nxdomain.corti.li )
EXIT_CODE=$?
assertEquals "wrong exit code" "${NAGIOS_CRITICAL}" "${EXIT_CODE}"
assertContains "wrong error message" "${OUTPUT}" "Cannot resolve"
# shellcheck disable=SC2086
OUTPUT=$( ${SCRIPT} ${TEST_DEBUG} --rootcert-file cabundle.crt --host li --do-not-resolve )
EXIT_CODE=$?
assertEquals "wrong exit code" "${NAGIOS_CRITICAL}" "${EXIT_CODE}"
assertContains "wrong error message" "${OUTPUT}" "Cannot connect"

# shellcheck disable=SC2086
OUTPUT=$( ${SCRIPT} ${TEST_DEBUG} --rootcert-file cabundle.crt --host nxdomain.corti.li --do-not-resolve )
EXIT_CODE=$?
assertEquals "wrong exit code" "${NAGIOS_CRITICAL}" "${EXIT_CODE}"
assertContains "wrong error message" "${OUTPUT}" "Cannot connect"
# shellcheck disable=SC2086
OUTPUT=$( ${SCRIPT} ${TEST_DEBUG} --rootcert-file cabundle.crt --host nxdomain.corti.li )
EXIT_CODE=$?
assertEquals "wrong exit code" "${NAGIOS_CRITICAL}" "${EXIT_CODE}"
assertContains "wrong error message" "${OUTPUT}" "Cannot resolve"

# shellcheck disable=SC2086
OUTPUT=$( ${SCRIPT} ${TEST_DEBUG} --rootcert-file cabundle.crt --host nxdomain.corti.li --do-not-resolve )
EXIT_CODE=$?
assertEquals "wrong exit code" "${NAGIOS_CRITICAL}" "${EXIT_CODE}"
assertContains "wrong error message" "${OUTPUT}" "Cannot connect"

else

echo "nslookup not found: skipping"

fi

}

Expand Down Expand Up @@ -1528,17 +1540,25 @@ testPurpose() {
}

testDNSSECOk() {
# shellcheck disable=SC2086
${SCRIPT} ${TEST_DEBUG} -H switch.ch --ignore-exp --require-dnssec
EXIT_CODE=$?
assertEquals "wrong exit code" "${NAGIOS_OK}" "${EXIT_CODE}"
if [ -n "${DIG_BIN}" ] ; then
# shellcheck disable=SC2086
${SCRIPT} ${TEST_DEBUG} -H switch.ch --ignore-exp --require-dnssec
EXIT_CODE=$?
assertEquals "wrong exit code" "${NAGIOS_OK}" "${EXIT_CODE}"
else
echo "Cannot find dig: skipping DNSSEC tests"
fi
}

testDNSSECError() {
# shellcheck disable=SC2086
${SCRIPT} ${TEST_DEBUG} -H corti.li --ignore-exp --require-dnssec
EXIT_CODE=$?
assertEquals "wrong exit code" "${NAGIOS_CRITICAL}" "${EXIT_CODE}"
if [ -n "${DIG_BIN}" ] ; then
# shellcheck disable=SC2086
${SCRIPT} ${TEST_DEBUG} -H corti.li --ignore-exp --require-dnssec
EXIT_CODE=$?
assertEquals "wrong exit code" "${NAGIOS_CRITICAL}" "${EXIT_CODE}"
else
echo "Cannot find dig: skipping DNSSEC tests"
fi
}

testXFrameOptionsOK() {
Expand Down

0 comments on commit 8e2922b

Please sign in to comment.