2019-01-15 17:46:06 +00:00
|
|
|
#!/bin/bash
|
2021-11-16 21:51:42 +00:00
|
|
|
#########################################################################################
|
|
|
|
# Script to run the System Tests for HIRS TPM 2.0 Provisoner
|
|
|
|
#
|
|
|
|
#########################################################################################
|
|
|
|
aca_container=hirs-aca1
|
|
|
|
tpm2_container=hirs-provisioner1-tpm2
|
|
|
|
testResult="passed";
|
|
|
|
issuerCert=../setup/certs/ca.crt
|
2022-01-10 18:36:38 +00:00
|
|
|
hirs_aca_log=/var/log/tomcat/HIRS_AttestationCA.log
|
2019-01-15 17:46:06 +00:00
|
|
|
|
2021-11-16 21:51:42 +00:00
|
|
|
# Source files for Docker Variables and helper scripts
|
|
|
|
. ./.ci/docker/.env
|
2019-01-15 17:46:06 +00:00
|
|
|
|
2021-11-16 21:51:42 +00:00
|
|
|
set -a
|
2019-01-15 17:46:06 +00:00
|
|
|
|
2021-11-16 21:51:42 +00:00
|
|
|
echo "******** Setting up for HIRS System Tests for TPM 2.0 ******** "
|
2019-01-15 17:46:06 +00:00
|
|
|
|
2022-01-10 18:36:38 +00:00
|
|
|
# expand dmi files for mounting to the provisioner containers
|
|
|
|
unzip -q .ci/system-tests/profiles/laptop/laptop_dmi.zip -d .ci/system-tests/profiles/laptop/
|
2019-01-15 17:46:06 +00:00
|
|
|
# Start System Testing Docker Environment
|
2022-01-25 15:54:54 +00:00
|
|
|
pushd .ci/docker > /dev/null
|
2019-01-15 17:46:06 +00:00
|
|
|
|
2021-11-16 21:51:42 +00:00
|
|
|
docker-compose -f docker-compose-system-test.yml up -d
|
|
|
|
|
2022-01-25 15:54:54 +00:00
|
|
|
popd > /dev/null
|
|
|
|
pushd .ci/system-tests > /dev/null
|
2021-11-16 21:51:42 +00:00
|
|
|
source sys_test_common.sh
|
|
|
|
|
2022-01-10 18:36:38 +00:00
|
|
|
echo "ACA Container info: $(checkContainerStatus $aca_container)";
|
|
|
|
echo "TPM2 Provisioner Container info: $(checkContainerStatus $tpm2_container)";
|
2019-01-15 17:46:06 +00:00
|
|
|
|
2021-11-16 21:51:42 +00:00
|
|
|
# Install HIRS provioner and setup tpm2 emulator
|
2022-01-26 17:08:29 +00:00
|
|
|
docker exec $tpm2_container /HIRS/.ci/setup/setup_tpm2provisioner.sh
|
2019-01-15 17:46:06 +00:00
|
|
|
|
2021-11-16 21:51:42 +00:00
|
|
|
# ********* Execute system tests here, add tests as needed *************
|
|
|
|
echo "******** Setup Complete Begin HIRS System Tests ******** "
|
2019-01-15 17:46:06 +00:00
|
|
|
|
2021-11-16 21:51:42 +00:00
|
|
|
source aca_policy_tests.sh
|
2022-02-01 22:43:12 +00:00
|
|
|
source platform_cert_tests.sh
|
2022-02-03 21:03:15 +00:00
|
|
|
source rim_system_tests.sh
|
2022-02-01 22:43:12 +00:00
|
|
|
|
2019-02-04 19:26:54 +00:00
|
|
|
|
2021-11-16 21:51:42 +00:00
|
|
|
echo "******** HIRS System Tests Complete ******** "
|
2019-01-15 17:46:06 +00:00
|
|
|
|
2021-11-16 21:51:42 +00:00
|
|
|
# collecting ACA logs for archiving
|
|
|
|
echo "Collecting ACA logs ....."
|
|
|
|
docker exec $aca_container mkdir -p /HIRS/logs/aca/;
|
|
|
|
docker exec $aca_container cp -a /var/log/tomcat/. /HIRS/logs/aca/;
|
|
|
|
docker exec $aca_container chmod -R 777 /HIRS/logs/;
|
|
|
|
echo "Collecting provisioner logs"
|
|
|
|
docker exec $tpm2_container mkdir -p /HIRS/logs/provisioner/;
|
|
|
|
docker exec $tpm2_container cp -a /var/log/hirs/provisioner/. /HIRS/logs/provisioner/;
|
|
|
|
docker exec $tpm2_container chmod -R 777 /HIRS/logs/;
|
2019-02-01 11:00:10 +00:00
|
|
|
|
2021-11-16 21:51:42 +00:00
|
|
|
# Display container log
|
2019-01-15 17:46:06 +00:00
|
|
|
echo ""
|
2021-11-16 21:51:42 +00:00
|
|
|
echo "===========HIRS Tests and Log collection complete ==========="
|
2019-01-15 17:46:06 +00:00
|
|
|
|
|
|
|
echo ""
|
2021-11-16 21:51:42 +00:00
|
|
|
echo "End of System Tests for TPM 2.0, cleaning up..."
|
2019-01-15 17:46:06 +00:00
|
|
|
echo ""
|
2019-02-01 11:00:10 +00:00
|
|
|
# Clean up services and network
|
2022-01-25 15:54:54 +00:00
|
|
|
popd > /dev/null
|
2022-01-10 18:36:38 +00:00
|
|
|
pushd .ci/docker
|
2022-01-10 21:56:27 +00:00
|
|
|
docker-compose -f docker-compose-system-test.yml down -v
|
2022-01-25 15:54:54 +00:00
|
|
|
popd > /dev/null
|
2021-11-16 21:51:42 +00:00
|
|
|
# Clean up dangling containers
|
|
|
|
echo "Cleaning up dangling containers..."
|
|
|
|
echo ""
|
|
|
|
docker container prune --force
|
|
|
|
echo ""
|
|
|
|
echo "New value of test status is ${TEST_STATUS}"
|
|
|
|
# Return container exit code
|
|
|
|
if [[ ${TEST_STATUS} == "0" ]]; then
|
|
|
|
echo "SUCCESS: System Tests for TPM 2.0 passed"
|
|
|
|
echo "TEST_STATUS=0" >> $GITHUB_ENV
|
|
|
|
exit 0;
|
|
|
|
else
|
|
|
|
echo "FAILURE: System Tests for TPM 2.0 failed"
|
|
|
|
echo "TEST_STATUS=1" >> $GITHUB_ENV
|
|
|
|
exit 1
|
|
|
|
fi
|