tests/sign: allow to start pull test without libsodium

Allow to run the pulling test if there is no ed25519 support.
Test the signed pull only with dummy engine. Fixed tests names.

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
This commit is contained in:
Denis Pynkin 2019-11-26 09:40:57 +00:00
parent 5cd822ae05
commit acace9b95a
1 changed files with 14 additions and 7 deletions

View File

@ -23,7 +23,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh . $(dirname $0)/libtest.sh
echo "1..7" echo "1..6"
setup_fake_remote_repo1 "archive" setup_fake_remote_repo1 "archive"
@ -39,6 +39,7 @@ function repo_init() {
function test_signed_pull() { function test_signed_pull() {
local sign_type="$1" local sign_type="$1"
local comment="$2"
cd ${test_tmpdir} cd ${test_tmpdir}
${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo commit ${COMMIT_ARGS} \ ${CMD_PREFIX} ostree --repo=ostree-srv/gnomerepo commit ${COMMIT_ARGS} \
-b main -s "A signed commit" --tree=ref=main -b main -s "A signed commit" --tree=ref=main
@ -56,19 +57,26 @@ function test_signed_pull() {
# ok now check that we can pull correctly # ok now check that we can pull correctly
mv $remotesig.bak $remotesig mv $remotesig.bak $remotesig
${CMD_PREFIX} ostree --repo=repo pull origin main ${CMD_PREFIX} ostree --repo=repo pull origin main
echo "ok pull ${sign_type} signed commit" echo "ok ${sign_type}${comment} pull signed commit"
rm $localsig rm $localsig
${CMD_PREFIX} ostree --repo=repo pull origin main ${CMD_PREFIX} ostree --repo=repo pull origin main
test -f $localsig test -f $localsig
echo "ok re-pull ${sign_type} signature for stored commit" echo "ok ${sign_type}${comment} re-pull signature for stored commit"
} }
DUMMYSIGN="dummysign" DUMMYSIGN="dummysign"
COMMIT_ARGS="--sign=${DUMMYSIGN} --sign-type=dummy" COMMIT_ARGS="--sign=${DUMMYSIGN} --sign-type=dummy"
repo_init --set=sign-verify=true repo_init --set=sign-verify=true
${CMD_PREFIX} ostree --repo=repo config set 'remote "origin"'.verification-key "${DUMMYSIGN}" ${CMD_PREFIX} ostree --repo=repo config set 'remote "origin"'.verification-key "${DUMMYSIGN}"
test_signed_pull "dummy" test_signed_pull "dummy" ""
if ! has_libsodium; 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-file pull signed commit # SKIP due libsodium unavailability"
echo "ok ed25519-file re-pull signature for stored commit # SKIP due libsodium unavailability"
exit 0
fi
# Test ostree sign with 'ed25519' module # Test ostree sign with 'ed25519' module
gen_ed25519_keys gen_ed25519_keys
@ -80,7 +88,7 @@ COMMIT_ARGS="--sign=${SECRET} --sign-type=ed25519"
repo_init --set=sign-verify=true repo_init --set=sign-verify=true
${CMD_PREFIX} ostree --repo=repo config set 'remote "origin"'.verification-key "${PUBLIC}" ${CMD_PREFIX} ostree --repo=repo config set 'remote "origin"'.verification-key "${PUBLIC}"
test_signed_pull "ed25519" test_signed_pull "ed25519" "key"
# Prepare files with public ed25519 signatures # Prepare files with public ed25519 signatures
PUBKEYS="$(mktemp -p ${test_tmpdir} ed25519_XXXXXX.ed25519)" PUBKEYS="$(mktemp -p ${test_tmpdir} ed25519_XXXXXX.ed25519)"
@ -95,6 +103,5 @@ echo ${PUBLIC} >> ${PUBKEYS}
repo_init --set=sign-verify=true repo_init --set=sign-verify=true
${CMD_PREFIX} ostree --repo=repo config set 'remote "origin"'.verification-file "${PUBKEYS}" ${CMD_PREFIX} ostree --repo=repo config set 'remote "origin"'.verification-file "${PUBKEYS}"
test_signed_pull "ed25519" test_signed_pull "ed25519" "file"
echo "ok verify ed25519 keys file"