[ostree] tests: add a test for signed summary file



commit 6aeeba4280be0fc2460198affb69d228b8ee3912
Author: Giuseppe Scrivano <gscrivan redhat com>
Date:   Thu Apr 30 09:36:27 2015 +0200

    tests: add a test for signed summary file
    
    Signed-off-by: Giuseppe Scrivano <gscrivan redhat com>

 tests/libtest.sh                  |    9 +++++----
 tests/test-pull-mirror-summary.sh |   27 +++++++++++++++++++++++----
 tests/test-pull-resume.sh         |    2 +-
 3 files changed, 29 insertions(+), 9 deletions(-)
---
diff --git a/tests/libtest.sh b/tests/libtest.sh
index 5ee5ae4..ba435c0 100644
--- a/tests/libtest.sh
+++ b/tests/libtest.sh
@@ -137,7 +137,8 @@ setup_test_repository () {
 
 setup_fake_remote_repo1() {
     mode=$1
-    args=$2
+    commit_opts=$2
+    args=$3
     shift
     oldpwd=`pwd`
     mkdir ostree-srv
@@ -150,13 +151,13 @@ setup_fake_remote_repo1() {
     mkdir baz
     echo moo > baz/cow
     echo alien > baz/saucer
-    ${CMD_PREFIX} ostree  --repo=${test_tmpdir}/ostree-srv/gnomerepo commit --add-metadata-string 
version=3.0 -b main -s "A remote commit" -m "Some Commit body"
+    ${CMD_PREFIX} ostree  --repo=${test_tmpdir}/ostree-srv/gnomerepo commit $commit_opts 
--add-metadata-string version=3.0 -b main -s "A remote commit" -m "Some Commit body"
     mkdir baz/deeper
-    ${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo commit --add-metadata-string version=3.1 
-b main -s "Add deeper"
+    ${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo commit $commit_opts 
--add-metadata-string version=3.1 -b main -s "Add deeper"
     echo hi > baz/deeper/ohyeah
     mkdir baz/another/
     echo x > baz/another/y
-    ${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo commit --add-metadata-string version=3.2 
-b main -s "The rest"
+    ${CMD_PREFIX} ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo commit $commit_opts 
--add-metadata-string version=3.2 -b main -s "The rest"
     cd ..
     rm -rf gnomerepo-files
     
diff --git a/tests/test-pull-mirror-summary.sh b/tests/test-pull-mirror-summary.sh
index 2a8a293..87182bc 100755
--- a/tests/test-pull-mirror-summary.sh
+++ b/tests/test-pull-mirror-summary.sh
@@ -21,23 +21,24 @@ set -e
 
 . $(dirname $0)/libtest.sh
 
-setup_fake_remote_repo1 "archive-z2"
+COMMIT_SIGN="--gpg-homedir=${TEST_GPG_KEYHOME} --gpg-sign=${TEST_GPG_KEYID_1}"
+setup_fake_remote_repo1 "archive-z2" "${COMMIT_SIGN}"
 
 # Now, setup multiple branches
 mkdir ${test_tmpdir}/ostree-srv/other-files
 cd ${test_tmpdir}/ostree-srv/other-files
 echo 'hello world another object' > hello-world
-ostree  --repo=${test_tmpdir}/ostree-srv/gnomerepo commit -b other -s "A commit" -m "Another Commit body"
+ostree  --repo=${test_tmpdir}/ostree-srv/gnomerepo commit ${COMMIT_SIGN} -b other -s "A commit" -m "Another 
Commit body"
 
 mkdir ${test_tmpdir}/ostree-srv/yet-other-files
 cd ${test_tmpdir}/ostree-srv/yet-other-files
 echo 'hello world yet another object' > yet-another-hello-world
-ostree  --repo=${test_tmpdir}/ostree-srv/gnomerepo commit -b yet-another -s "A commit" -m "Another Commit 
body"
+ostree  --repo=${test_tmpdir}/ostree-srv/gnomerepo commit ${COMMIT_SIGN} -b yet-another -s "A commit" -m 
"Another Commit body"
 
 ostree --repo=${test_tmpdir}/ostree-srv/gnomerepo summary -u
 
+prev_dir=`pwd`
 cd ${test_tmpdir}
-mkdir repo
 ostree --repo=repo init --mode=archive-z2
 ostree --repo=repo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
 ostree --repo=repo pull --mirror origin
@@ -50,3 +51,21 @@ ostree --repo=repo checkout -U yet-another yet-another-copy
 assert_file_has_content yet-another-copy/yet-another-hello-world "hello world yet another object"
 ostree --repo=repo fsck
 echo "ok pull mirror summary"
+
+if ! ${CMD_PREFIX} ostree --version | grep -q -e '\+gpgme'; then
+    exit 0;
+fi
+
+cd $prev_dir
+
+${OSTREE} --repo=${test_tmpdir}/ostree-srv/gnomerepo summary -u ${COMMIT_SIGN}
+
+cd ${test_tmpdir}
+rm -rf repo
+mkdir repo
+${OSTREE} --repo=repo init --mode=archive-z2
+${OSTREE} --repo=repo remote add origin $(cat httpd-address)/ostree/gnomerepo
+${OSTREE} --repo=repo pull --mirror origin
+assert_has_file repo/summary
+assert_has_file repo/summary.sig
+echo "ok pull mirror with signed summary"
diff --git a/tests/test-pull-resume.sh b/tests/test-pull-resume.sh
index e073243..25ee907 100755
--- a/tests/test-pull-resume.sh
+++ b/tests/test-pull-resume.sh
@@ -21,7 +21,7 @@ set -e
 
 . $(dirname $0)/libtest.sh
 
-setup_fake_remote_repo1 "archive-z2" "--force-range-requests"
+setup_fake_remote_repo1 "archive-z2" "" "--force-range-requests"
 
 echo '1..1'
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]