diff --git a/tests/pull-test.sh b/tests/pull-test.sh index a8bc49a9..0a97a119 100644 --- a/tests/pull-test.sh +++ b/tests/pull-test.sh @@ -54,7 +54,12 @@ function verify_initial_contents() { assert_file_has_content baz/cow '^moo$' } -echo "1..34" +if has_gpgme; then + echo "1..34" +else + # 3 tests needs GPG support + echo "1..31" +fi # Try both syntaxes repo_init --no-gpg-verify @@ -543,13 +548,15 @@ fi assert_file_has_content err.txt "404" echo "ok pull repo 404" -cd ${test_tmpdir} -repo_init --set=gpg-verify=true -if ${CMD_PREFIX} ostree --repo=repo --depth=0 pull origin main 2>err.txt; then - assert_not_reached "pull repo 404 succeeded?" +if has_gpgme; then + cd ${test_tmpdir} + repo_init --set=gpg-verify=true + if ${CMD_PREFIX} ostree --repo=repo --depth=0 pull origin main 2>err.txt; then + assert_not_reached "pull repo 404 succeeded?" + fi + assert_file_has_content err.txt "GPG verification enabled, but no signatures found" + echo "ok pull repo 404 (gpg)" fi -assert_file_has_content err.txt "GPG verification enabled, but no signatures found" -echo "ok pull repo 404 (gpg)" cd ${test_tmpdir} find ostree-srv/gnomerepo/objects -name '*.dirtree' | while read f; do mv ${f}{,.orig}; done @@ -561,29 +568,31 @@ assert_file_has_content err.txt "404" find ostree-srv/gnomerepo/objects -name '*.dirtree.orig' | while read f; do mv ${f} $(dirname $f)/$(basename ${f} .orig); done echo "ok pull repo 404 on dirtree object" -cd ${test_tmpdir} -repo_init --set=gpg-verify=true -${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo commit ${COMMIT_ARGS} \ - --gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1} -b main \ - -s "A signed commit" --tree=ref=main -${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo summary -u -# make sure gpg verification is correctly on -csum=$(${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo rev-parse main) -objpath=objects/${csum::2}/${csum:2}.commitmeta -remotesig=ostree-srv/gnomerepo/$objpath -localsig=repo/$objpath -mv $remotesig $remotesig.bak -if ${CMD_PREFIX} ostree --repo=repo --depth=0 pull origin main; then - assert_not_reached "pull with gpg-verify unexpectedly succeeded?" +if has_gpgme; then + cd ${test_tmpdir} + repo_init --set=gpg-verify=true + ${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo commit ${COMMIT_ARGS} \ + --gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1} -b main \ + -s "A signed commit" --tree=ref=main + ${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo summary -u + # make sure gpg verification is correctly on + csum=$(${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo rev-parse main) + objpath=objects/${csum::2}/${csum:2}.commitmeta + remotesig=ostree-srv/gnomerepo/$objpath + localsig=repo/$objpath + mv $remotesig $remotesig.bak + if ${CMD_PREFIX} ostree --repo=repo --depth=0 pull origin main; then + assert_not_reached "pull with gpg-verify unexpectedly succeeded?" + fi + # ok now check that we can pull correctly + mv $remotesig.bak $remotesig + ${CMD_PREFIX} ostree --repo=repo pull origin main + echo "ok pull signed commit" + rm $localsig + ${CMD_PREFIX} ostree --repo=repo pull origin main + test -f $localsig + echo "ok re-pull signature for stored commit" fi -# ok now check that we can pull correctly -mv $remotesig.bak $remotesig -${CMD_PREFIX} ostree --repo=repo pull origin main -echo "ok pull signed commit" -rm $localsig -${CMD_PREFIX} ostree --repo=repo pull origin main -test -f $localsig -echo "ok re-pull signature for stored commit" cd ${test_tmpdir} repo_init --no-gpg-verify diff --git a/tests/test-create-usb.sh b/tests/test-create-usb.sh index 8040ed9c..8187ea75 100755 --- a/tests/test-create-usb.sh +++ b/tests/test-create-usb.sh @@ -26,6 +26,8 @@ set -euo pipefail . $(dirname $0)/libtest.sh +skip_without_gpgme + echo "1..5" cd ${test_tmpdir} diff --git a/tests/test-find-remotes.sh b/tests/test-find-remotes.sh index 226053ce..5dd880f0 100755 --- a/tests/test-find-remotes.sh +++ b/tests/test-find-remotes.sh @@ -23,6 +23,8 @@ set -euo pipefail . $(dirname $0)/libtest.sh +skip_without_gpgme + echo '1..1' # Create two upstream collection repositories with some example commits diff --git a/tests/test-local-pull.sh b/tests/test-local-pull.sh index 8168486c..97bb9954 100755 --- a/tests/test-local-pull.sh +++ b/tests/test-local-pull.sh @@ -28,7 +28,12 @@ unset OSTREE_GPG_HOME skip_without_user_xattrs -echo "1..8" +if has_gpgme; then + echo "1..8" +else + # Only some tests doesn't need GPG support + echo "1..5" +fi setup_test_repository "archive" echo "ok setup" @@ -63,6 +68,20 @@ cmp checkout1.files checkout2.files cmp checkout1.files checkout3.files echo "ok checkouts same" +mkdir repo7 +ostree_repo_init repo7 --mode="archive" +${CMD_PREFIX} ostree --repo=repo7 pull-local repo +${CMD_PREFIX} ostree --repo=repo7 fsck +for src_object in `find repo/objects -name '*.filez'`; do + dst_object=${src_object/repo/repo7} + assert_files_hardlinked "$src_object" "$dst_object" +done +echo "ok pull-local z2 to z2 default hardlink" + +if ! has_gpgme; then + exit 0 +fi + mkdir repo4 ostree_repo_init repo4 --mode="archive" ${CMD_PREFIX} ostree --repo=repo4 remote add --gpg-import ${test_tmpdir}/gpghome/key1.asc origin repo @@ -97,13 +116,3 @@ ${OSTREE} summary --update --gpg-sign=${TEST_GPG_KEYID_1} --gpg-homedir=${TEST_G ${CMD_PREFIX} ostree --repo=repo6 pull-local --remote=origin --gpg-verify-summary repo test2 2>&1 echo "ok --gpg-verify-summary" - -mkdir repo7 -ostree_repo_init repo7 --mode="archive" -${CMD_PREFIX} ostree --repo=repo7 pull-local repo -${CMD_PREFIX} ostree --repo=repo7 fsck -for src_object in `find repo/objects -name '*.filez'`; do - dst_object=${src_object/repo/repo7} - assert_files_hardlinked "$src_object" "$dst_object" -done -echo "ok pull-local z2 to z2 default hardlink" diff --git a/tests/test-parent.sh b/tests/test-parent.sh index a9a3494c..b62b9557 100755 --- a/tests/test-parent.sh +++ b/tests/test-parent.sh @@ -25,6 +25,8 @@ set -euo pipefail skip_without_user_xattrs +skip_without_gpgme + echo '1..2' setup_test_repository "archive" diff --git a/tests/test-pull-collections.sh b/tests/test-pull-collections.sh index fd782af9..d1de5f88 100755 --- a/tests/test-pull-collections.sh +++ b/tests/test-pull-collections.sh @@ -34,7 +34,11 @@ do_commit() { mkdir -p files pushd files - ${CMD_PREFIX} ostree --repo="../${repo}" commit -s "Test ${repo} commit for branch ${branch}" -b "${branch}" --gpg-homedir="${TEST_GPG_KEYHOME}" --gpg-sign="${TEST_GPG_KEYID_1}" "$@" > "../${branch}-checksum" + local GPG_ARGS="" + if has_gpgme; then + GPG_ARGS="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}" + fi + ${CMD_PREFIX} ostree --repo="../${repo}" commit -s "Test ${repo} commit for branch ${branch}" -b "${branch}" ${GPG_ARGS} "$@" > "../${branch}-checksum" popd } @@ -42,7 +46,11 @@ do_summary() { local repo=$1 shift 1 - ${CMD_PREFIX} ostree "--repo=${repo}" summary --update --gpg-homedir="${TEST_GPG_KEYHOME}" --gpg-sign="${TEST_GPG_KEYID_1}" + local GPG_ARGS="" + if has_gpgme; then + GPG_ARGS="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}" + fi + ${CMD_PREFIX} ostree "--repo=${repo}" summary --update ${GPG_ARGS} } do_collection_ref_show() { @@ -96,7 +104,11 @@ do_remote_add() { local remote_repo=$2 shift 2 - ${CMD_PREFIX} ostree "--repo=${repo}" remote add "${remote_repo}-remote" "file://$(pwd)/${remote_repo}" "$@" --gpg-import="${test_tmpdir}/gpghome/key1.asc" + local GPG_ARGS="" + if has_gpgme; then + GPG_ARGS="--gpg-import=${test_tmpdir}/gpghome/key1.asc" + fi + ${CMD_PREFIX} ostree "--repo=${repo}" remote add "${remote_repo}-remote" "file://$(pwd)/${remote_repo}" "$@" ${GPG_ARGS} } do_pull() { diff --git a/tests/test-pull-mirror-summary.sh b/tests/test-pull-mirror-summary.sh index 504cf545..a2a98bad 100755 --- a/tests/test-pull-mirror-summary.sh +++ b/tests/test-pull-mirror-summary.sh @@ -23,9 +23,15 @@ set -euo pipefail . $(dirname $0)/libtest.sh -echo "1..5" +COMMIT_SIGN="" +if has_gpgme; then + COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}" + echo "1..5" +else + # Only one test don't need GPG support + echo "1..1" +fi -COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}" setup_fake_remote_repo1 "archive" "${COMMIT_SIGN}" # Now, setup multiple branches diff --git a/tests/test-pull-repeated.sh b/tests/test-pull-repeated.sh index a2707d6d..237a863c 100755 --- a/tests/test-pull-repeated.sh +++ b/tests/test-pull-repeated.sh @@ -23,9 +23,12 @@ set -euo pipefail . $(dirname $0)/libtest.sh -echo "1..4" +COMMIT_SIGN="" +if has_gpgme; then + COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}" +fi -COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}" +echo "1..4" # Test pulling from a repo which gives error 500 (internal server error) a lot of the time. setup_fake_remote_repo1 "archive" "${COMMIT_SIGN}" --random-500s=50 diff --git a/tests/test-pull-summary-sigs.sh b/tests/test-pull-summary-sigs.sh index 0b6b806c..821ae953 100755 --- a/tests/test-pull-summary-sigs.sh +++ b/tests/test-pull-summary-sigs.sh @@ -23,9 +23,15 @@ set -euo pipefail . $(dirname $0)/libtest.sh -echo "1..10" +COMMIT_SIGN="" +if has_gpgme; then + COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}" + echo "1..10" +else + # Only one test don't need GPG support + echo "1..1" +fi -COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}" setup_fake_remote_repo1 "archive" "${COMMIT_SIGN}" # Now, setup multiple branches diff --git a/tests/test-summary-update.sh b/tests/test-summary-update.sh index 062d5bd4..ceaa5409 100755 --- a/tests/test-summary-update.sh +++ b/tests/test-summary-update.sh @@ -28,6 +28,12 @@ set -euo pipefail echo "1..2" +COMMIT_SIGN="" +if has_gpgme; then + COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}" +fi + + cd ${test_tmpdir} mkdir repo ostree_repo_init repo @@ -45,7 +51,7 @@ done ${CMD_PREFIX} ostree --repo=repo summary --update # Generate a signed summary file. -${CMD_PREFIX} ostree --repo=repo summary --update --gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1} +${CMD_PREFIX} ostree --repo=repo summary --update ${COMMIT_SIGN} # Try various ways of adding additional data. ${CMD_PREFIX} ostree --repo=repo summary --update --add-metadata key="'value'" --add-metadata=key2=true @@ -77,7 +83,7 @@ done ${CMD_PREFIX} ostree --repo=repo summary --update # Generate a signed summary file. -${CMD_PREFIX} ostree --repo=repo summary --update --gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1} +${CMD_PREFIX} ostree --repo=repo summary --update ${COMMIT_SIGN} # Try various ways of adding additional data. ${CMD_PREFIX} ostree --repo=repo summary --update --add-metadata key="'value'" --add-metadata=key2=true diff --git a/tests/test-summary-view.sh b/tests/test-summary-view.sh index d26d3431..14de0294 100755 --- a/tests/test-summary-view.sh +++ b/tests/test-summary-view.sh @@ -28,7 +28,11 @@ set -euo pipefail echo "1..2" -COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}" +COMMIT_SIGN="" +if has_gpgme; then + COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}" +fi + setup_fake_remote_repo1 "archive" "${COMMIT_SIGN}" # Set up a second branch.