Skip to content

Commit c8f6f80

Browse files
committed
Move the regular container tests into run instead of openshift testlib.
1 parent 7bb1d05 commit c8f6f80

File tree

2 files changed

+46
-45
lines changed

2 files changed

+46
-45
lines changed

test/run

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,52 @@ evaluate_build_result() {
215215
return $_ret_code
216216
}
217217

218+
# "0" if system is not FIPS enabled, "1" if it is.
219+
function fips_enabled() {
220+
local is_fips_enabled
221+
222+
# Read fips mode from host in case exists
223+
if [[ -f /proc/sys/crypto/fips_enabled ]]; then
224+
is_fips_enabled=$(cat /proc/sys/crypto/fips_enabled)
225+
else
226+
is_fips_enabled="0"
227+
fi
228+
229+
return "$is_fips_enabled"
230+
}
231+
232+
run_s2i_build_fips() {
233+
ct_s2i_build_as_df file://${test_dir}/test-fips ${IMAGE_NAME} ${IMAGE_NAME}-testfips ${s2i_args} $1
234+
}
235+
236+
function test_run_fips_app() {
237+
# Verify that the HTTP connection can be established to test application container
238+
run_test_application fips
239+
# Wait for the container to write it's CID file
240+
wait_for_cid
241+
ct_test_response "http://localhost:4567/symmetric/aes-256-cbc" 200 ""
242+
ct_test_response "http://localhost:4567/symmetric/des-ede-cbc" 200 ""
243+
ct_test_response "http://localhost:4567/symmetric/sha256" 200 ""
244+
ct_test_response "http://localhost:4567/symmetric/md5" 200 ""
245+
curl "http://localhost:4567/"
246+
ct_check_testcase_result $?
247+
kill_test_application
248+
}
249+
250+
function test_ruby_fips_mode() {
251+
if [[ "$(fips_enabled)" == "0" ]]; then
252+
# FIPS disabled -> OpenSSL#fips_enabled returns false
253+
echo "Fips should be disabled"
254+
docker run --rm "$IMAGE_NAME" /bin/bash -c 'ruby -ropenssl -e "exit !OpenSSL.fips_enabled"'
255+
ct_check_testcase_result "$?"
256+
else
257+
echo "Fips should be enabled"
258+
# FIPS enabled -> OpenSSL#fips_enabled returns true
259+
docker run --rm "$IMAGE_NAME" /bin/bash -c 'ruby -ropenssl -e "exit OpenSSL.fips_enabled"'
260+
ct_check_testcase_result "$?"
261+
fi
262+
}
263+
218264
# Prepare dependencies for tests
219265
pushd ${test_dir}
220266
# db test dependencies

test/test-lib-ruby.sh

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,6 @@ function ct_pull_or_import_postgresql() {
2929
fi
3030
}
3131

32-
# "0" if system is not FIPS enabled, "1" if it is.
33-
function fips_enabled() {
34-
local is_fips_enabled
35-
36-
# Read fips mode from host in case exists
37-
if [[ -f /proc/sys/crypto/fips_enabled ]]; then
38-
is_fips_enabled=$(cat /proc/sys/crypto/fips_enabled)
39-
else
40-
is_fips_enabled="0"
41-
fi
42-
43-
return "$is_fips_enabled"
44-
}
45-
4632
function rails_ex_branch() {
4733
# Ruby 3.3 introduced too many incompatibilities to be able
4834
# to use the same Gemfile for RHEL 7 and also newer RHELs.
@@ -60,10 +46,6 @@ function rails_ex_branch() {
6046
echo "$rails_example_repo_branch"
6147
}
6248

63-
run_s2i_build_fips() {
64-
ct_s2i_build_as_df file://${test_dir}/test-fips ${IMAGE_NAME} ${IMAGE_NAME}-testfips ${s2i_args} $1
65-
}
66-
6749
function run_test_application() {
6850
case "$1" in
6951
fips)
@@ -77,33 +59,6 @@ function run_test_application() {
7759
esac
7860
}
7961

80-
function test_run_fips_app() {
81-
# Verify that the HTTP connection can be established to test application container
82-
run_test_application fips
83-
# Wait for the container to write it's CID file
84-
wait_for_cid
85-
ct_test_response "http://localhost:4567/symmetric/aes-256-cbc" 200 ""
86-
ct_test_response "http://localhost:4567/symmetric/des-ede-cbc" 200 ""
87-
ct_test_response "http://localhost:4567/symmetric/sha256" 200 ""
88-
ct_test_response "http://localhost:4567/symmetric/md5" 200 ""
89-
curl "http://localhost:4567/"
90-
ct_check_testcase_result $?
91-
kill_test_application
92-
}
93-
94-
function test_ruby_fips_mode() {
95-
if [[ "$(fips_enabled)" == "0" ]]; then
96-
# FIPS disabled -> OpenSSL#fips_enabled returns false
97-
echo "Fips should be disabled"
98-
docker run --rm "$IMAGE_NAME" /bin/bash -c 'ruby -ropenssl -e "exit !OpenSSL.fips_enabled"'
99-
ct_check_testcase_result "$?"
100-
else
101-
echo "Fips should be enabled"
102-
# FIPS enabled -> OpenSSL#fips_enabled returns true
103-
docker run --rm "$IMAGE_NAME" /bin/bash -c 'ruby -ropenssl -e "exit OpenSSL.fips_enabled"'
104-
ct_check_testcase_result "$?"
105-
fi
106-
}
10762

10863
function test_ruby_integration() {
10964
ct_os_test_s2i_app "${IMAGE_NAME}" \

0 commit comments

Comments
 (0)