From 8e2922b4b912b755d466b0ec83e3d46d18f9c369 Mon Sep 17 00:00:00 2001 From: Matteo Corti Date: Tue, 21 Nov 2023 10:39:01 +0100 Subject: [PATCH] skip some tests if dig and nslookup are not available --- CITATION.cff | 100 +++++++++++++++++++------------------- test/integration_tests.sh | 76 ++++++++++++++++++----------- 2 files changed, 98 insertions(+), 78 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 301f465..8c213aa 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -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" @@ -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" @@ -28,11 +39,15 @@ 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" @@ -40,9 +55,15 @@ authors: - 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" @@ -50,20 +71,30 @@ authors: 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- @@ -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" @@ -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" @@ -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 @@ -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" @@ -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" @@ -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" @@ -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 diff --git a/test/integration_tests.sh b/test/integration_tests.sh index 394fd44..d8e7669 100755 --- a/test/integration_tests.sh +++ b/test/integration_tests.sh @@ -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() { @@ -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 } @@ -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() {