tests/commit-sign: Update a bit to more modern style
I was trying to debug this while working on another PR. Add `echo ok` lines and also use `assert_file_has_content` more directly; there's no reason to use an intermediate `grep` since if it fails it won't print the original file. Closes: #1220 Approved by: jlebon
This commit is contained in:
parent
d319e75982
commit
3314140415
|
|
@ -26,7 +26,7 @@ if ! has_gpgme; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "1..1"
|
echo "1..6"
|
||||||
|
|
||||||
keyid="472CDAFA"
|
keyid="472CDAFA"
|
||||||
oldpwd=`pwd`
|
oldpwd=`pwd`
|
||||||
|
|
@ -73,6 +73,7 @@ if env OSTREE_GPG_HOME=${test_tmpdir} ${CMD_PREFIX} ostree --repo=repo pull orig
|
||||||
assert_not_reached "pull with no trusted GPG keys unexpectedly succeeded!"
|
assert_not_reached "pull with no trusted GPG keys unexpectedly succeeded!"
|
||||||
fi
|
fi
|
||||||
rm repo -rf
|
rm repo -rf
|
||||||
|
echo "ok pull no trusted GPG"
|
||||||
|
|
||||||
# And a test case with valid signature
|
# And a test case with valid signature
|
||||||
cd ${test_tmpdir}
|
cd ${test_tmpdir}
|
||||||
|
|
@ -80,9 +81,10 @@ mkdir repo
|
||||||
ostree_repo_init repo
|
ostree_repo_init repo
|
||||||
${CMD_PREFIX} ostree --repo=repo remote add origin $(cat httpd-address)/ostree/gnomerepo
|
${CMD_PREFIX} ostree --repo=repo remote add origin $(cat httpd-address)/ostree/gnomerepo
|
||||||
${CMD_PREFIX} ostree --repo=repo pull origin main
|
${CMD_PREFIX} ostree --repo=repo pull origin main
|
||||||
${CMD_PREFIX} ostree --repo=repo show --gpg-verify-remote=origin main | grep -o 'Found [[:digit:]] signature' > show-verify-remote
|
${CMD_PREFIX} ostree --repo=repo show --gpg-verify-remote=origin main > show.txt
|
||||||
assert_file_has_content show-verify-remote 'Found 1 signature'
|
assert_file_has_content_literal show.txt 'Found 1 signature'
|
||||||
rm repo -rf
|
rm repo -rf
|
||||||
|
echo "ok pull verify"
|
||||||
|
|
||||||
# A test with corrupted detached signature
|
# A test with corrupted detached signature
|
||||||
cd ${test_tmpdir}
|
cd ${test_tmpdir}
|
||||||
|
|
@ -96,6 +98,7 @@ if ${CMD_PREFIX} ostree --repo=repo pull origin main; then
|
||||||
assert_not_reached "pull with corrupted signature unexpectedly succeeded!"
|
assert_not_reached "pull with corrupted signature unexpectedly succeeded!"
|
||||||
fi
|
fi
|
||||||
rm repo -rf
|
rm repo -rf
|
||||||
|
echo "ok pull corrupted sig"
|
||||||
|
|
||||||
# And now attempt to pull the same corrupted commit, but with GPG
|
# And now attempt to pull the same corrupted commit, but with GPG
|
||||||
# verification off
|
# verification off
|
||||||
|
|
@ -105,6 +108,7 @@ ostree_repo_init repo
|
||||||
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
|
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
|
||||||
${CMD_PREFIX} ostree --repo=repo pull origin main
|
${CMD_PREFIX} ostree --repo=repo pull origin main
|
||||||
rm repo -rf
|
rm repo -rf
|
||||||
|
echo "ok repull corrupted"
|
||||||
|
|
||||||
# Add an unsigned commit to the repo, then pull, then sign the commit,
|
# Add an unsigned commit to the repo, then pull, then sign the commit,
|
||||||
# then pull again. Make sure we get the expected number of signatures
|
# then pull again. Make sure we get the expected number of signatures
|
||||||
|
|
@ -117,23 +121,21 @@ mkdir repo
|
||||||
ostree_repo_init repo
|
ostree_repo_init repo
|
||||||
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
|
${CMD_PREFIX} ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
|
||||||
${CMD_PREFIX} ostree --repo=repo pull origin main
|
${CMD_PREFIX} ostree --repo=repo pull origin main
|
||||||
if ${CMD_PREFIX} ostree --repo=repo show main | grep -o 'Found [[:digit:]] signature'; then
|
${CMD_PREFIX} ostree --repo=repo show main > show.txt
|
||||||
assert_not_reached
|
assert_not_file_has_content show.txt 'Found.*signature'
|
||||||
fi
|
|
||||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo gpg-sign --gpg-homedir=${test_tmpdir}/gpghome main $keyid
|
${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo gpg-sign --gpg-homedir=${test_tmpdir}/gpghome main $keyid
|
||||||
${CMD_PREFIX} ostree --repo=repo pull origin main
|
${CMD_PREFIX} ostree --repo=repo pull origin main
|
||||||
${CMD_PREFIX} ostree --repo=repo show main | grep -o 'Found [[:digit:]] signature' > show
|
${CMD_PREFIX} ostree --repo=repo show main > show.txt
|
||||||
assert_file_has_content show 'Found 1 signature'
|
assert_file_has_content_literal show.txt 'Found 1 signature'
|
||||||
|
echo "ok pull unsigned, then sign"
|
||||||
|
|
||||||
# Delete the signature from the commit so the detached metadata is empty,
|
# Delete the signature from the commit so the detached metadata is empty,
|
||||||
# then pull and verify the signature is also deleted on the client side.
|
# then pull and verify the signature is also deleted on the client side.
|
||||||
${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo gpg-sign --gpg-homedir=${test_tmpdir}/gpghome --delete main $keyid
|
${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo gpg-sign --gpg-homedir=${test_tmpdir}/gpghome --delete main $keyid
|
||||||
${CMD_PREFIX} ostree --repo=repo pull origin main
|
${CMD_PREFIX} ostree --repo=repo pull origin main
|
||||||
if ${CMD_PREFIX} ostree --repo=repo show main | grep -o 'Found [[:digit:]] signature'; then
|
${CMD_PREFIX} ostree --repo=repo show main >show.txt
|
||||||
assert_not_reached
|
assert_not_file_has_content show.txt 'Found.*signature'
|
||||||
fi
|
echo "ok pull sig deleted"
|
||||||
|
|
||||||
rm -rf repo gnomerepo-files
|
rm -rf repo gnomerepo-files
|
||||||
libtest_cleanup_gpg
|
libtest_cleanup_gpg
|
||||||
|
|
||||||
echo "ok"
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue