summaryrefslogtreecommitdiff
path: root/tests/test-pull-summary-sigs.sh
diff options
context:
space:
mode:
authorDan Nicholson <nicholson@endlessm.com>2018-08-02 14:12:32 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-14 13:38:11 +0000
commit1b5cb52da29bccbf14f49b0d990db2b5ca6ada82 (patch)
tree1dc0faafd09ab45275d43ae24efe1388039d5471 /tests/test-pull-summary-sigs.sh
parente5061f54d68ea95ab0b953e6cec6eeca26b01a12 (diff)
downloadostree-1b5cb52da29bccbf14f49b0d990db2b5ca6ada82.tar.gz
tests: Test for recovery from corrupted summary cache
Check that recovery from a corrupted summary cache (cached summary doesn't match cached signature) works. Closes: #1698 Approved by: cgwalters
Diffstat (limited to 'tests/test-pull-summary-sigs.sh')
-rwxr-xr-xtests/test-pull-summary-sigs.sh35
1 files changed, 34 insertions, 1 deletions
diff --git a/tests/test-pull-summary-sigs.sh b/tests/test-pull-summary-sigs.sh
index 77ff8444..4b71b506 100755
--- a/tests/test-pull-summary-sigs.sh
+++ b/tests/test-pull-summary-sigs.sh
@@ -23,7 +23,7 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
-echo "1..9"
+echo "1..10"
COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
setup_fake_remote_repo1 "archive" "${COMMIT_SIGN}"
@@ -230,4 +230,37 @@ cmp repo/tmp/cache/summaries/origin.sig ${test_tmpdir}/ostree-srv/gnomerepo/summ
echo "ok pull with signed summary remote old summary signature"
+# Reset to the old valid summary and pull to cache it
+cp ${test_tmpdir}/ostree-srv/gnomerepo/summary{.1,}
+cp ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig{.1,}
+repo_reinit
+${OSTREE} --repo=repo pull origin main
+assert_has_file repo/tmp/cache/summaries/origin
+assert_has_file repo/tmp/cache/summaries/origin.sig
+cmp repo/tmp/cache/summaries/origin ${test_tmpdir}/ostree-srv/gnomerepo/summary.1 >&2
+cmp repo/tmp/cache/summaries/origin.sig ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig.1 >&2
+
+# Simulate a broken summary cache to see if it can be recovered from.
+# Prior to commit c4c2b5eb the client would save the summary to the
+# cache before validating the signature. That would mean the cache would
+# have mismatched summary and signature and ostree would remain
+# deadlocked there until the remote published a new signature.
+cp ${test_tmpdir}/ostree-srv/gnomerepo/summary.2 repo/tmp/cache/summaries/origin
+${OSTREE} --repo=repo pull origin main
+assert_has_file repo/tmp/cache/summaries/origin
+assert_has_file repo/tmp/cache/summaries/origin.sig
+cmp repo/tmp/cache/summaries/origin ${test_tmpdir}/ostree-srv/gnomerepo/summary.1 >&2
+cmp repo/tmp/cache/summaries/origin.sig ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig.1 >&2
+
+# Publish new signature and check that subsequent pull succeeds
+cp ${test_tmpdir}/ostree-srv/gnomerepo/summary{.2,}
+cp ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig{.2,}
+${OSTREE} --repo=repo pull origin main
+assert_has_file repo/tmp/cache/summaries/origin
+assert_has_file repo/tmp/cache/summaries/origin.sig
+cmp repo/tmp/cache/summaries/origin ${test_tmpdir}/ostree-srv/gnomerepo/summary.2 >&2
+cmp repo/tmp/cache/summaries/origin.sig ${test_tmpdir}/ostree-srv/gnomerepo/summary.sig.2 >&2
+
+echo "ok pull with signed summary broken cache"
+
libtest_cleanup_gpg