diff --git a/tests/Makefile.am.inc b/tests/Makefile.am.inc index 091b4ab1..dcd8fa17 100644 --- a/tests/Makefile.am.inc +++ b/tests/Makefile.am.inc @@ -132,6 +132,8 @@ dist_test_scripts = \ tests/test-run-deltas.sh \ tests/test-run-system-deltas.sh \ tests/test-repo.sh \ + tests/test-repo-collections.sh \ + tests/test-repo-collections-server-only.sh \ tests/test-repo-system.sh \ tests/test-extensions.sh \ tests/test-bundle.sh \ diff --git a/tests/libtest.sh b/tests/libtest.sh index 88e6d6d3..77da52c2 100644 --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -194,42 +194,93 @@ export FL_GPGARGS2="--gpg-homedir=${FL_GPG_HOMEDIR2} --gpg-sign=${FL_GPG_ID2}" export FL_GPG_BASE64="mQENBFbPBvoBCADWbz5O+XzuyN+dDExK81pci+gIzBNWB+7SsN0EgoJppKgwBCX+Bd6ERe9Yz0nJbJB/tjazRp7MnnoPnh6fXnhIbHA766/Eciy4sL5X8laqDmWmROCqCe79QZH/w6vYTKsDmoLQrw9eKRP1ilCvECNGcVdhIyfTDlNrU//uy5U4h2PVUz1/Al87lvaJnrj5423m5GnX+qpEG8mmpmcw52lvXNPuC95ykylPQJjI0WnOuaTcxzRhm5eHPkqKQ+nPIS+66iw1SFdobYuye/vg/rDiyp8uyQkh7FWXnzHxz4J8ovesnrCM7pKI4VEHCnZ4/sj2v9E3l0wJlqZxLTULaV3lABEBAAG0D1hkZy1hcHAgdGVzdGluZ4kBOAQTAQIAIgUCVs8G+gIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQE4sx4HsJYf2DiAf7BQ8anU3CgYpJjuO2rT8jQPO0jGRCNaPyaeAcBx8IjFkjf8daKMPCAt6gQioEpC8OhDig86Bl5piYOB7L7JSB53mgUrADJXhgC/dG4soCt7/U4wW30MseXdlXSOqHGApblF/bIs4B30OBGReBj3DcWIqyb48GraSKlPlaCpkZFySNEAcGUCeCqbbygxCQAM8MDq9FgVRk5oVrE/nAUm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eZClHm1EjYlgsAq1UJr9wgbyBFKTEkGZ/CAvVmgg+BUXcN/SPAkELbEAOJZTyv8C5cuJC49iFHOxUbRZXZ5eN2SvhZzl+5gep2uHwVLdqRIxFDTHbLWnmtHxPeU7IRA9u86q3wV1N0pD7kreNN7BWKY3/tI33hY2/XVVFy0MN5sutPn+lVK66MqAHqtode5xqqz9Z8LmS7LlqokQkAytcGd6Xqsx99NTk8kk3bnk9HWsAvDO8tRZroeseKeRNmbhGvCNUxPSB6bpYBJLvQtjA9ZVv6sNm0E+SuiXKizZkBGO5AH50pDoy0+MCGoOhwwXeY5+1kZAOzkMI=" -setup_repo () { +setup_repo_no_add () { REPONAME=${1:-test} - GPGARGS="${GPGARGS:-${FL_GPGARGS}}" . $(dirname $0)/make-test-runtime.sh ${REPONAME} org.test.Platform bash ls cat echo readlink > /dev/null - GPGARGS="${GPGARGS:-${FL_GPGARGS}}" . $(dirname $0)/make-test-app.sh ${REPONAME} > /dev/null - update_repo $REPONAME + if [ x${USE_COLLECTIONS_IN_SERVER-} == xyes ] ; then + COLLECTION_ID=${2:-org.test.Collection.${REPONAME}} + else + COLLECTION_ID= + fi + + GPGARGS="${GPGARGS:-${FL_GPGARGS}}" . $(dirname $0)/make-test-runtime.sh ${REPONAME} org.test.Platform "${COLLECTION_ID}" bash ls cat echo readlink > /dev/null + GPGARGS="${GPGARGS:-${FL_GPGARGS}}" . $(dirname $0)/make-test-app.sh ${REPONAME} "${COLLECTION_ID}" > /dev/null + update_repo $REPONAME "${COLLECTION_ID}" if [ $REPONAME == "test" ]; then $(dirname $0)/test-webserver.sh repos FLATPAK_HTTP_PID=$(cat httpd-pid) mv httpd-port httpd-port-main fi +} + +setup_repo () { + REPONAME=${1:-test} + COLLECTION_ID=${2:-org.test.Collection.${REPONAME}} + + setup_repo_no_add "$@" + port=$(cat httpd-port-main) - flatpak remote-add ${U} --gpg-import=${GPGPUBKEY:-${FL_GPG_HOMEDIR}/pubring.gpg} ${REPONAME}-repo "http://127.0.0.1:${port}/$REPONAME" + if [ x${GPGPUBKEY:-${FL_GPG_HOMEDIR}/pubring.gpg} != x ]; then + import_args=--gpg-import=${GPGPUBKEY:-${FL_GPG_HOMEDIR}/pubring.gpg} + else + import_args= + fi + if [ x${USE_COLLECTIONS_IN_CLIENT-} == xyes ] ; then + collection_args=--collection-id=${COLLECTION_ID} + else + collection_args= + fi + + flatpak remote-add ${U} ${collection_args} ${import_args} ${REPONAME}-repo "http://127.0.0.1:${port}/$REPONAME" } update_repo () { REPONAME=${1:-test} - ${FLATPAK} build-update-repo ${GPGARGS:-${FL_GPGARGS}} ${UPDATE_REPO_ARGS-} repos/${REPONAME} + COLLECTION_ID=${2:-org.test.Collection.${REPONAME}} + + if [ x${USE_COLLECTIONS_IN_SERVER-} == xyes ] ; then + collection_args=--collection-id=${COLLECTION_ID} + else + collection_args= + fi + + ${FLATPAK} build-update-repo ${collection_args} ${GPGARGS:-${FL_GPGARGS}} ${UPDATE_REPO_ARGS-} repos/${REPONAME} } make_updated_app () { REPONAME=${1:-test} - GPGARGS="${GPGARGS:-${FL_GPGARGS}}" . $(dirname $0)/make-test-app.sh ${REPONAME} ${2:-UPDATED} > /dev/null - update_repo $REPONAME + if [ x${USE_COLLECTIONS_IN_SERVER-} == xyes ] ; then + COLLECTION_ID=${2:-org.test.Collection.${REPONAME}} + else + COLLECTION_ID="" + fi + + GPGARGS="${GPGARGS:-${FL_GPGARGS}}" . $(dirname $0)/make-test-app.sh ${REPONAME} "${COLLECTION_ID}" ${3:-UPDATED} > /dev/null + update_repo $REPONAME "${COLLECTION_ID}" } setup_sdk_repo () { REPONAME=${1:-test} - GPGARGS="${GPGARGS:-${FL_GPGARGS}}" . $(dirname $0)/make-test-runtime.sh ${REPONAME} org.test.Sdk bash ls cat echo readlink make mkdir cp touch > /dev/null - update_repo $REPONAME + if [ x${USE_COLLECTIONS_IN_SERVER-} == xyes ] ; then + COLLECTION_ID=${2:-org.test.Collection.${REPONAME}} + else + COLLECTION_ID="" + fi + + GPGARGS="${GPGARGS:-${FL_GPGARGS}}" . $(dirname $0)/make-test-runtime.sh ${REPONAME} org.test.Sdk "${COLLECTION_ID}" bash ls cat echo readlink make mkdir cp touch > /dev/null + update_repo $REPONAME "${COLLECTION_ID}" } setup_python2_repo () { REPONAME=${1:-test} - GPGARGS="${GPGARGS:-${FL_GPGARGS}}" . $(dirname $0)/make-test-runtime.sh ${REPONAME} org.test.PythonPlatform bash python2 ls cat echo rm readlink > /dev/null - GPGARGS="${GPGARGS:-${FL_GPGARGS}}" . $(dirname $0)/make-test-runtime.sh ${REPONAME} org.test.PythonSdk python2 bash ls cat echo rm readlink make mkdir cp touch > /dev/null - update_repo $REPONAME + if [ x${USE_COLLECTIONS_IN_SERVER-} == xyes ] ; then + COLLECTION_ID=${2:-org.test.Collection.${REPONAME}} + else + COLLECTION_ID="" + fi + + GPGARGS="${GPGARGS:-${FL_GPGARGS}}" . $(dirname $0)/make-test-runtime.sh ${REPONAME} org.test.PythonPlatform "${COLLECTION_ID}" bash python2 ls cat echo rm readlink > /dev/null + GPGARGS="${GPGARGS:-${FL_GPGARGS}}" . $(dirname $0)/make-test-runtime.sh ${REPONAME} org.test.PythonSdk "${COLLECTION_ID}" python2 bash ls cat echo rm readlink make mkdir cp touch > /dev/null + update_repo $REPONAME "${COLLECTION_ID}" } install_repo () { diff --git a/tests/make-test-app.sh b/tests/make-test-app.sh index e28a1c0c..10631de0 100755 --- a/tests/make-test-app.sh +++ b/tests/make-test-app.sh @@ -6,6 +6,8 @@ DIR=`mktemp -d` REPONAME=$1 shift +COLLECTION_ID=$1 +shift EXTRA="${1-}" @@ -63,7 +65,13 @@ gzip -c > ${DIR}/files/share/app-info/xmls/org.test.Hello.xml.gz < /dev/null -. $(dirname $0)/make-test-app.sh test > /dev/null +. $(dirname $0)/make-test-runtime.sh test org.test.Platform "" bash ls cat echo readlink > /dev/null +. $(dirname $0)/make-test-app.sh test "" > /dev/null # Modify platform metadata ostree checkout -U --repo=repos/test runtime/org.test.Platform/${ARCH}/master platform diff --git a/tests/test-oci.sh b/tests/test-oci.sh index bbca8fa0..82befed6 100755 --- a/tests/test-oci.sh +++ b/tests/test-oci.sh @@ -76,7 +76,7 @@ echo "ok update oci" flatpak uninstall ${U} org.test.Hello -make_updated_app test HTTP +make_updated_app test org.test.Collection.test HTTP ${FLATPAK} build-bundle --oci $FL_GPGARGS repos/test oci/registry org.test.Hello $(dirname $0)/test-webserver.sh `pwd`/oci @@ -91,7 +91,7 @@ assert_file_has_content hello_out '^Hello world, from a sandboxHTTP$' echo "ok install oci http" -make_updated_app test UPDATEDHTTP +make_updated_app test org.test.Collection.test UPDATEDHTTP ${FLATPAK} build-bundle --oci $FL_GPGARGS repos/test oci/registry org.test.Hello ${FLATPAK} update ${U} org.test.Hello diff --git a/tests/test-repo-collections-server-only.sh b/tests/test-repo-collections-server-only.sh new file mode 100755 index 00000000..69b71688 --- /dev/null +++ b/tests/test-repo-collections-server-only.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# +# Copyright © 2017 Endless Mobile, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +export USE_COLLECTIONS_IN_SERVER=yes +export USE_COLLECTIONS_IN_CLIENT=no + +. $(dirname $0)/test-repo.sh diff --git a/tests/test-repo-collections.sh b/tests/test-repo-collections.sh new file mode 100755 index 00000000..044ca24c --- /dev/null +++ b/tests/test-repo-collections.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# +# Copyright © 2017 Endless Mobile, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +export USE_COLLECTIONS_IN_SERVER=yes +export USE_COLLECTIONS_IN_CLIENT=yes + +. $(dirname $0)/test-repo.sh diff --git a/tests/test-repo.sh b/tests/test-repo.sh index e12aaaa5..763405e0 100755 --- a/tests/test-repo.sh +++ b/tests/test-repo.sh @@ -24,18 +24,35 @@ set -euo pipefail skip_without_bwrap skip_without_user_xattrs +if [ x${USE_COLLECTIONS_IN_CLIENT-} == xyes ] || [ x${USE_COLLECTIONS_IN_SERVER-} == xyes ] ; then + skip_without_p2p +fi + echo "1..6" #Regular repo setup_repo -#unsigned repo -GPGPUBKEY="" GPG_ARGS="" setup_repo test-no-gpg +# Unsigned repo (not supported with collections; client-side use of collections requires GPG) +if [ x${USE_COLLECTIONS_IN_CLIENT-} == xyes ] ; then + if GPGPUBKEY=" " GPGARGS=" " setup_repo test-no-gpg org.test.Collection.NoGpg; then + assert_not_reached "Should fail remote-add due to missing GPG key" + fi +elif [ x${USE_COLLECTIONS_IN_SERVER-} == xyes ] ; then + # Set a collection ID and GPG on the server, but not in the client configuration + setup_repo_no_add test-no-gpg org.test.Collection.NoGpg + port=$(cat httpd-port-main) + flatpak remote-add ${U} --no-gpg-verify test-no-gpg-repo "http://127.0.0.1:${port}/test-no-gpg" +else + GPGPUBKEY="" GPGARGS="" setup_repo test-no-gpg +fi #alternative gpg key repo -GPGPUBKEY="${FL_GPG_HOMEDIR2}/pubring.gpg" GPGARGS="${FL_GPGARGS2}" setup_repo test-gpg2 +GPGPUBKEY="${FL_GPG_HOMEDIR2}/pubring.gpg" GPGARGS="${FL_GPGARGS2}" setup_repo test-gpg2 org.test.Collection.Gpg2 #remote with missing GPG key +# Don’t use --collection-id= here, or the collections code will grab the appropriate +# GPG key from one of the previously-configured remotes with the same collection ID. port=$(cat httpd-port-main) if flatpak remote-add ${U} test-missing-gpg-repo "http://127.0.0.1:${port}/test"; then assert_not_reached "Should fail metadata-update due to missing gpg key" @@ -47,10 +64,14 @@ if flatpak remote-add ${U} --gpg-import=${FL_GPG_HOMEDIR2}/pubring.gpg test-wron assert_not_reached "Should fail metadata-update due to wrong gpg key" fi -install_repo test-no-gpg -echo "ok install without gpg key" +if [ x${USE_COLLECTIONS_IN_CLIENT-} != xyes ] ; then + install_repo test-no-gpg + echo "ok install without gpg key" -${FLATPAK} ${U} uninstall org.test.Platform org.test.Hello + ${FLATPAK} ${U} uninstall org.test.Platform org.test.Hello +else + echo "ok install without gpg key # skip not supported for collections" +fi install_repo test-gpg2 echo "ok with alternative gpg key" @@ -95,16 +116,17 @@ assert_file_has_content repo-info "new-title" echo "ok update metadata" port=$(cat httpd-port-main) -UPDATE_REPO_ARGS="--redirect-url=http://127.0.0.1:${port}/test-gpg2 --gpg-import=${FL_GPG_HOMEDIR2}/pubring.gpg" update_repo +UPDATE_REPO_ARGS="--redirect-url=http://127.0.0.1:${port}/test-gpg3 --gpg-import=${FL_GPG_HOMEDIR2}/pubring.gpg" update_repo +GPGPUBKEY="${FL_GPG_HOMEDIR2}/pubring.gpg" GPGARGS="${FL_GPGARGS2}" setup_repo_no_add test-gpg3 org.test.Collection.test ${FLATPAK} ${U} update org.test.Platform -${FLATPAK} ${U} remotes -d | grep ^test-repo > repo-info # Ensure we have the new uri -assert_file_has_content repo-info "/test-gpg2" +${FLATPAK} ${U} remotes -d | grep ^test-repo > repo-info +assert_file_has_content repo-info "/test-gpg3" # Make sure we also get new installs from the new repo -GPGARGS="${FL_GPGARGS2}" make_updated_app test-gpg2 -update_repo test-gpg2 +GPGARGS="${FL_GPGARGS2}" make_updated_app test-gpg3 org.test.Collection.test +update_repo test-gpg3 org.test.Collection.test ${FLATPAK} ${U} install test-repo org.test.Hello assert_file_has_content $FL_DIR/app/org.test.Hello/$ARCH/master/active/files/bin/hello.sh UPDATED diff --git a/tests/testlibrary.c b/tests/testlibrary.c index 7901529c..e8f49ce6 100644 --- a/tests/testlibrary.c +++ b/tests/testlibrary.c @@ -278,6 +278,9 @@ test_remote (void) g_assert_cmpstr (flatpak_remote_get_collection_id (remote), ==, NULL); flatpak_remote_set_collection_id (remote, "org.example.CollectionID"); g_assert_cmpstr (flatpak_remote_get_collection_id (remote), ==, "org.example.CollectionID"); + /* Don’t leave the collection ID set since the repos aren’t configured with one. */ + flatpak_remote_set_collection_id (remote, NULL); + g_assert_cmpstr (flatpak_remote_get_collection_id (remote), ==, NULL); #endif /* FLATPAK_ENABLE_P2P */ g_assert_cmpstr (flatpak_remote_get_title (remote), ==, NULL); @@ -552,7 +555,7 @@ make_test_runtime (void) g_autoptr(GError) error = NULL; g_autofree char *arg0 = NULL; char *argv[] = { - NULL, "test", "org.test.Platform", "bash", "ls", "cat", "echo", "readlink", NULL + NULL, "test", "org.test.Platform", "", "bash", "ls", "cat", "echo", "readlink", NULL }; GSpawnFlags flags = G_SPAWN_DEFAULT; @@ -578,7 +581,7 @@ make_test_app (void) int status; g_autoptr(GError) error = NULL; g_autofree char *arg0 = NULL; - char *argv[] = { NULL, "test", NULL }; + char *argv[] = { NULL, "test", "", NULL }; GSpawnFlags flags = G_SPAWN_DEFAULT; arg0 = g_test_build_filename (G_TEST_DIST, "make-test-app.sh", NULL);