Skip to content

Commit

Permalink
To not test the key store if Java is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
matteocorti committed Nov 21, 2023
1 parent f025b80 commit bf4d5ff
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions test/unit_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ oneTimeSetUp() {
fi
"${OPENSSL}" version

KEYTOOL=$( command -v keytool) # Java?

if [ -z "${GREP_BIN}" ]; then
GREP_BIN=$(command -v grep) # needed by openssl_version
fi
Expand Down Expand Up @@ -557,17 +559,25 @@ testChainFailIgnored() {
}

testJavaKeyStore1() {
# shellcheck disable=SC2086
${SCRIPT} ${TEST_DEBUG} --file ./keystore.jks --password changeit --jks-alias google-com --ignore-incomplete-chain --ignore-exp
EXIT_CODE=$?
assertEquals "wrong exit code" "${NAGIOS_OK}" "${EXIT_CODE}"
if [ -n "${KEYTOOL}" ] ; then
# shellcheck disable=SC2086
${SCRIPT} ${TEST_DEBUG} --file ./keystore.jks --password changeit --jks-alias google-com --ignore-incomplete-chain --ignore-exp
EXIT_CODE=$?
assertEquals "wrong exit code" "${NAGIOS_OK}" "${EXIT_CODE}"
else
echo "Java not installed: skipping key store tests"
fi
}

testJavaKeyStore2() {
# shellcheck disable=SC2086
${SCRIPT} ${TEST_DEBUG} --file ./cacerts.jks --password changeit --jks-alias "verisignuniversalrootca [jdk]" --allow-empty-san --ignore-maximum-validity --selfsigned
EXIT_CODE=$?
assertEquals "wrong exit code" "${NAGIOS_OK}" "${EXIT_CODE}"
if [ -n "${KEYTOOL}" ] ; then
# shellcheck disable=SC2086
${SCRIPT} ${TEST_DEBUG} --file ./cacerts.jks --password changeit --jks-alias "verisignuniversalrootca [jdk]" --allow-empty-san --ignore-maximum-validity --selfsigned
EXIT_CODE=$?
assertEquals "wrong exit code" "${NAGIOS_OK}" "${EXIT_CODE}"
else
echo "Java not installed: skipping key store tests"
fi
}

testDirectoryAsAFile() {
Expand Down

0 comments on commit bf4d5ff

Please sign in to comment.