[ -e /etc/mtab ] || skip "no /etc/mtab"
}
-has_gpgme () {
- local ret
+has_ostree_feature () {
+ local ret=0
+ # Note that this needs to write to a file and then grep the file, to
+ # avoid ostree --version being killed with SIGPIPE and exiting with a
+ # nonzero status under `set -o pipefail`.
${CMD_PREFIX} ostree --version > version.txt
- grep -q -e '- gpgme' version.txt
- ret=$?
+ grep -q -e "- $1\$" version.txt || ret=$?
rm -f version.txt
return ${ret}
}
-skip_without_gpgme() {
- if ! has_gpgme; then
- skip "no gpg support compiled in"
+skip_without_ostree_feature () {
+ if ! has_ostree_feature "$1"; then
+ skip "no $1 support compiled in"
fi
}
}
libtest_exit_cmds+=(libtest_cleanup_gpg)
-has_sign_ed25519 () {
- local ret
- ${CMD_PREFIX} ostree --version > version.txt
- grep -q -e '- sign-ed25519' version.txt
- ret=$?
- rm -f version.txt
- return ${ret}
-}
-
-skip_without_sign_ed25519() {
- if ! has_sign_ed25519; then
- skip "no ed25519 support compiled in"
- fi
-}
-
# Keys for ed25519 signing tests
ED25519PUBLIC=
ED25519SEED=
n_base_tests=35
gpg_tests=3
-if has_gpgme; then
+if has_ostree_feature gpgme; then
echo "1..$(($n_base_tests+$gpg_tests))"
else
echo "1..$((n_base_tests))"
assert_file_has_content err.txt "404"
echo "ok pull repo 404"
-if has_gpgme; then
+if has_ostree_feature 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
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"
-if has_gpgme; then
+if has_ostree_feature gpgme; then
cd ${test_tmpdir}
repo_init --set=gpg-verify=true
${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo commit ${COMMIT_ARGS} \
. $(dirname $0)/libtest.sh
-if ! has_gpgme; then
- echo "1..0 #SKIP no gpg support compiled in"
- exit 0
-fi
+skip_without_ostree_feature gpgme
if test -z "${OSTREE_HTTPD}"; then
echo "1..0 #SKIP no ostree-trivial-httpd"
. $(dirname $0)/libtest.sh
-skip_without_gpgme
+skip_without_ostree_feature gpgme
echo "1..5"
skip_without_user_xattrs
-skip_without_sign_ed25519
+skip_without_ostree_feature sign-ed25519
bindatafiles="bash true ostree"
. $(dirname $0)/libtest.sh
-skip_without_gpgme
+skip_without_ostree_feature gpgme
echo '1..1'
. $(dirname $0)/libtest.sh
-if ! has_gpgme; then
- echo "1..0 #SKIP no gpgme support compiled in"
- exit 0
-fi
+skip_without_ostree_feature gpgme
num_tests=1
cmp checkout1.files checkout3.files
echo "ok checkouts same"
-if has_gpgme; then
+if has_ostree_feature gpgme; then
# These tests are needed GPG support
mkdir repo4
ostree_repo_init repo4 --mode="archive"
skip_without_user_xattrs
-skip_without_gpgme
+skip_without_ostree_feature gpgme
echo '1..2'
echo "1..1"
-if ! has_sign_ed25519; then
+if ! has_ostree_feature sign-ed25519; then
echo "ok pre-signed pull # SKIP due ed25519 unavailability"
exit 0
fi
mkdir -p files
pushd files
local GPG_ARGS=""
- if has_gpgme; then
+ if has_ostree_feature 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"
shift 1
local GPG_ARGS=""
- if has_gpgme; then
+ if has_ostree_feature 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}
shift 2
local GPG_ARGS=""
- if has_gpgme; then
+ if has_ostree_feature 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}
echo "1..2"
COMMIT_SIGN=""
-if has_gpgme; then
+if has_ostree_feature gpgme; then
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
fi
# delete all the meta stuff from here
rm ostree/gnomerepo/summary
-if has_gpgme; then
+if has_ostree_feature gpgme; then
rm ostree/gnomerepo/summary.sig
find ostree/gnomerepo/objects -name '*.commitmeta' | xargs rm
fi
cd ${test_tmpdir}
mkdir repo
ostree_repo_init repo
-if has_gpgme; then VERIFY=true; else VERIFY=false; fi
+if has_ostree_feature gpgme; then VERIFY=true; else VERIFY=false; fi
${CMD_PREFIX} ostree --repo=repo remote add origin \
--set=gpg-verify=$VERIFY --set=gpg-verify-summary=$VERIFY \
--contenturl=$(cat httpd-content-address)/ostree/gnomerepo \
echo "ok pull objects from contenturl"
-if ! has_gpgme; then
+if ! has_ostree_feature gpgme; then
echo "ok don't pull sigs from contenturl # SKIP not compiled with gpgme"
else
echo "ok don't pull sigs from contenturl"
. $(dirname $0)/libtest.sh
COMMIT_SIGN=""
-if has_gpgme; then
+if has_ostree_feature gpgme; then
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
echo "1..5"
else
done
echo "ok pull mirror summary"
-if ! has_gpgme; then
+if ! has_ostree_feature gpgme; then
exit 0;
fi
. $(dirname $0)/libtest.sh
COMMIT_SIGN=""
-if has_gpgme; then
+if has_ostree_feature gpgme; then
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
fi
. $(dirname $0)/libtest.sh
-if ! has_gpgme; then
- echo "1..0 #SKIP no gpg support compiled in"
- exit 0
-fi
+skip_without_ostree_feature gpgme
# Ensure repo caching is in use.
unset OSTREE_SKIP_CACHE
unset OSTREE_SKIP_CACHE
COMMIT_SIGN=""
-if has_gpgme; then
+if has_ostree_feature gpgme; then
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
echo "1..10"
else
${CMD_PREFIX} ostree --repo=repo fsck
echo "ok pull mirror summary"
-if ! has_gpgme; then
+if ! has_ostree_feature gpgme; then
exit 0;
fi
echo "ok dummy sig requires env"
# tests below require libsodium support
-if ! has_sign_ed25519; then
+if ! has_ostree_feature sign-ed25519; then
echo "ok Detached ed25519 signature # SKIP due libsodium unavailability"
echo "ok ed25519 signature verified # SKIP due libsodium unavailability"
echo "ok multiple signing # SKIP due libsodium unavailability"
PUBLIC_KEY="dummysign"
;;
ed25519)
- if ! has_sign_ed25519; then
+ if ! has_ostree_feature sign-ed25519; then
echo "ok ${engine} pull mirror summary # SKIP due libsodium unavailability"
echo "ok ${engine} pull with signed summary # SKIP due libsodium unavailability"
echo "ok ${engine} prune summary cache # SKIP due libsodium unavailability"
done
-if ! has_sign_ed25519; then
+if ! has_ostree_feature sign-ed25519; then
echo "ok ${engine} pull with signed summary remote old summary # SKIP due libsodium unavailability"
echo "ok ${engine} pull with signed summary broken cache # SKIP due libsodium unavailability"
exit 0
assert_file_has_content err.txt 'Invalid key reference'
echo "ok remote add errs"
-if ! has_sign_ed25519; then
+if ! has_ostree_feature sign-ed25519; then
echo "ok ed25519-key pull signed commit # SKIP due libsodium unavailability"
echo "ok ed25519-key re-pull signature for stored commit # SKIP due libsodium unavailability"
echo "ok ed25519-key+file pull signed commit # SKIP due libsodium unavailability"
echo "1..2"
COMMIT_SIGN=""
-if has_gpgme; then
+if has_ostree_feature gpgme; then
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
fi
echo "1..2"
COMMIT_SIGN=""
-if has_gpgme; then
+if has_ostree_feature gpgme; then
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
fi