Skip to content

Commit

Permalink
Add test for image generation and change python's version check
Browse files Browse the repository at this point in the history
We need to test generated image before releasing new version.
  • Loading branch information
NgoHuy committed Dec 13, 2023
1 parent 1151daf commit f7b6cfe
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
24 changes: 12 additions & 12 deletions src/install/ykfde
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ build() {
add_file $file
done

python_ver=$(python -V | awk '{print $2}')
add_full_dir "/usr/lib/python${python_ver::-2}/site-packages/zipp"
add_full_dir "/usr/lib/python${python_ver::-2}/site-packages/cryptography"
add_full_dir "/usr/lib/python${python_ver::-2}/site-packages/cffi"
add_full_dir "/usr/lib/python${python_ver::-2}/site-packages/smartcard"
add_full_dir "/usr/lib/python${python_ver::-2}/site-packages/fido2"
add_full_dir "/usr/lib/python${python_ver::-2}/site-packages/importlib_metadata"
add_full_dir "/usr/lib/python${python_ver::-2}/site-packages/ykman"
add_full_dir "/usr/lib/python${python_ver::-2}/site-packages/yubikit"
add_full_dir "/usr/lib/python${python_ver::-2}/site-packages/click"
add_full_dir "/usr/lib/python${python_ver::-2}/site-packages/keyring"
add_binary "/usr/lib/python${python_ver::-2}/site-packages/_cffi_backend.cpython-311-x86_64-linux-gnu.so"
python_ver=$(python -V | awk -F'[" ",.]' '{print $2"."$3}')
add_full_dir "/usr/lib/python${python_ver}/site-packages/zipp"
add_full_dir "/usr/lib/python${python_ver}/site-packages/cryptography"
add_full_dir "/usr/lib/python${python_ver}/site-packages/cffi"
add_full_dir "/usr/lib/python${python_ver}/site-packages/smartcard"
add_full_dir "/usr/lib/python${python_ver}/site-packages/fido2"
add_full_dir "/usr/lib/python${python_ver}/site-packages/importlib_metadata"
add_full_dir "/usr/lib/python${python_ver}/site-packages/ykman"
add_full_dir "/usr/lib/python${python_ver}/site-packages/yubikit"
add_full_dir "/usr/lib/python${python_ver}/site-packages/click"
add_full_dir "/usr/lib/python${python_ver}/site-packages/keyring"
add_binary "/usr/lib/python${python_ver}/site-packages/_cffi_backend.cpython-311-x86_64-linux-gnu.so"
add_binary "/usr/lib/libssl.so.3"

add_binary "cryptsetup"
Expand Down
21 changes: 19 additions & 2 deletions testrun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ truncate -s 20M "$YKFDE_TMPFILE"

cleanup() {
rm -f "$YKFDE_TMPFILE"
rm -rf initramfs
}
trap cleanup EXIT

Expand All @@ -55,6 +56,22 @@ bash "$(pwd)/src/ykfde-open" -d "$YKFDE_TMPFILE" -n ykfde-test -v
cryptsetup close ykfde-test
echo "Test 'ykfde-open' script successfully passed."

echo "All tests successfully passed."

echo "INFO: Testing initramfs..."
mkdir -p "$(pwd)/initramfs"
mkinitcpio -d "$(pwd)/initramfs"
status=1
status=$(chroot "$(pwd)/initramfs" /bin/sh -c "export CRYPTOGRAPHY_OPENSSL_NO_LEGACY=1; ykman otp info; exit 0" 2>&1 | awk '
{
if ($0 ~ /No YubiKey detected/) {
print "0";
exit 0;
}
}'
)
if [[ "$status" == 0 ]]
then
echo "All tests successfully passed."
else
echo "The image didnot pass the test, please file a bug report to: https://github.com/agherzan/yubikey-full-disk-encryption/issues"
fi
exit 0

0 comments on commit f7b6cfe

Please sign in to comment.