File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,9 @@ test_node_cmd_development_init_wrapper_true
6161test_init_wrapper_false_development
6262"
6363
64+ TEST_LIST_FIPS=" \
65+ test_nodejs_fips_mode
66+ "
6467source " ${THISDIR} /test-lib.sh"
6568source " ${THISDIR} /test-lib-nodejs.sh"
6669
@@ -160,3 +163,12 @@ evaluate_build_result $? "proxy"
160163TEST_SET=${TESTS:- $TEST_LIST_HW } ct_run_tests_from_testset " hw"
161164
162165cleanup
166+
167+ echo " Testing fips mode"
168+ prepare app
169+ check_prep_result $? app || exit
170+ echo " Testing the production image build"
171+ run_s2i_build
172+ evaluate_build_result $? " default"
173+
174+ TEST_SET=${TESTS:- $TEST_LIST_FIPS } ct_run_tests_from_testset " fips"
Original file line number Diff line number Diff line change @@ -478,6 +478,29 @@ function test_nodemon_present() {
478478 ct_check_testcase_result " $? "
479479}
480480
481+ function test_nodejs_fips_mode() {
482+ # Test that nodejs behaves as expected in fips mode
483+ local is_fips_enabled
484+
485+ # Read fips mode from host in case exists
486+ if [[ -f /proc/sys/crypto/fips_enabled ]]; then
487+ is_fips_enabled=$( cat /proc/sys/crypto/fips_enabled)
488+ else
489+ is_fips_enabled=" 0"
490+ fi
491+ if [[ " $is_fips_enabled " == " 0" ]]; then
492+ # FIPS disabled -- crypto.getFips() should return 0
493+ echo " Fips should be disabled"
494+ docker run --rm ${IMAGE_NAME} -testapp /bin/bash -c " node -e 'const crypto = require(\" crypto\" ); process.exit(crypto.getFips());'"
495+ ct_check_testcase_result " $? "
496+ else
497+ # FIPS enabled -- crypto.getFips() should return 1
498+ echo " Fips should be enabled"
499+ docker run --rm ${IMAGE_NAME} -testapp /bin/bash -c " ! node -e 'const crypto = require(\" crypto\" ); process.exit(crypto.getFips());'"
500+ ct_check_testcase_result " $? "
501+ fi
502+ }
503+
481504function test_npm_cache_cleared() {
482505 # Test that the npm cache has been cleared
483506 cache_loc=$( docker run --rm ${IMAGE_NAME} -testapp /bin/bash -c " npm config get cache" )
You can’t perform that action at this time.
0 commit comments