summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2020-03-20 15:35:07 +0100
committerAlexander Larsson <alexl@redhat.com>2020-03-23 17:58:04 +0100
commit77105495965273c180f5852451e26ece2b913f7b (patch)
tree1a247026f607929fa203923938887f653ec9269c
parent2ac6be91f39668df61e9650f0f6f9c5c50ae3e4d (diff)
downloadflatpak-77105495965273c180f5852451e26ece2b913f7b.tar.gz
tests: Add tests for sideloading apps
-rw-r--r--tests/Makefile-test-matrix.am.inc3
-rw-r--r--tests/Makefile.am.inc1
-rw-r--r--tests/test-sideload.sh82
3 files changed, 86 insertions, 0 deletions
diff --git a/tests/Makefile-test-matrix.am.inc b/tests/Makefile-test-matrix.am.inc
index 70f8e625..ddf12dce 100644
--- a/tests/Makefile-test-matrix.am.inc
+++ b/tests/Makefile-test-matrix.am.inc
@@ -11,6 +11,8 @@ TEST_MATRIX= \
tests/test-repo@user.wrap \
tests/test-repo@system.wrap \
tests/test-repo@system-norevokefs.wrap \
+ tests/test-sideload@user.wrap \
+ tests/test-sideload@system.wrap \
tests/test-bundle@user.wrap \
tests/test-bundle@system.wrap \
tests/test-bundle@system-norevokefs.wrap \
@@ -35,6 +37,7 @@ TEST_MATRIX_EXTRA_DIST= \
tests/test-run.sh \
tests/test-info.sh \
tests/test-repo.sh \
+ tests/test-sideload.sh \
tests/test-bundle.sh \
tests/test-oci-registry.sh \
$(NULL)
diff --git a/tests/Makefile.am.inc b/tests/Makefile.am.inc
index d1ea064a..a7b25cb0 100644
--- a/tests/Makefile.am.inc
+++ b/tests/Makefile.am.inc
@@ -178,6 +178,7 @@ TEST_MATRIX_SOURCE = \
tests/test-run.sh{{user+system+system-norevokefs},{nodeltas+deltas}} \
tests/test-info.sh{user+system} \
tests/test-repo.sh{user+system+system-norevokefs} \
+ tests/test-sideload.sh{user+system} \
tests/test-default-remotes.sh \
tests/test-extensions.sh \
tests/test-bundle.sh{user+system+system-norevokefs} \
diff --git a/tests/test-sideload.sh b/tests/test-sideload.sh
new file mode 100644
index 00000000..1781da57
--- /dev/null
+++ b/tests/test-sideload.sh
@@ -0,0 +1,82 @@
+#!/bin/bash
+#
+# Copyright (C) 2011 Colin Walters <walters@verbum.org>
+#
+# 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.
+
+set -euo pipefail
+
+USE_COLLECTIONS_IN_SERVER=yes
+USE_COLLECTIONS_IN_CLIENT=yes
+
+. $(dirname $0)/libtest.sh
+
+skip_without_bwrap
+skip_revokefs_without_fuse
+
+echo "1..3"
+
+#Regular repo
+setup_repo
+
+${FLATPAK} ${U} install -y test-repo org.test.Hello
+# Ensure we have the full locale extension:
+${FLATPAK} ${U} update -y --subpath=
+
+mkdir usb_dir
+
+${FLATPAK} ${U} create-usb --destination-repo=repo usb_dir org.test.Hello
+
+assert_has_file usb_dir/repo/config
+assert_has_file usb_dir/repo/summary
+assert_has_file usb_dir/repo/refs/mirrors/org.test.Collection.test/app/org.test.Hello/${ARCH}/master
+assert_has_file usb_dir/repo/refs/mirrors/org.test.Collection.test/runtime/org.test.Hello.Locale/${ARCH}/master
+assert_has_file usb_dir/repo/refs/mirrors/org.test.Collection.test/runtime/org.test.Platform/${ARCH}/master
+assert_has_file usb_dir/repo/refs/mirrors/org.test.Collection.test/appstream2/${ARCH}
+
+${FLATPAK} ${U} uninstall -y --all
+
+ok "created sideloaded repo"
+
+${FLATPAK} ${U} remote-modify --url="http://no.127.0.0.1:${port}/test" test-repo
+
+if ${FLATPAK} ${U} install -y test-repo org.test.Hello &> /dev/null; then
+ assert_not_reached "Should not be able to install with wrong url"
+fi
+
+SIDELOAD_REPO=$(realpath usb_dir/repo)
+${FLATPAK} ${U} config --set sideload-repos ${SIDELOAD_REPO}
+
+${FLATPAK} ${U} config --get sideload-repos > sideload-repos
+assert_file_has_content sideload-repos ${SIDELOAD_REPO}
+
+${FLATPAK} ${U} install -y test-repo org.test.Hello
+assert_has_file $FL_DIR/app/org.test.Hello/$ARCH/master/active/metadata
+assert_has_file $FL_DIR/repo/refs/remotes/test-repo/app/org.test.Hello/${ARCH}/master
+assert_not_has_file $FL_DIR/repo/refs/mirrors/org.test.Collection.test/app/org.test.Hello/${ARCH}/master
+
+ok "installed sideloaded app"
+
+# Remove old appstream checkouts so we can update from the sideload
+rm -rf $FL_DIR/appstream/test-repo/$ARCH/
+rm -rf $FL_DIR/repo/refs/remotes/test-repo/appstream2/$ARCH
+ostree prune --repo=$FL_DIR/repo --refs-only
+
+${FLATPAK} ${U} update --appstream test-repo
+
+assert_has_file $FL_DIR/appstream/test-repo/$ARCH/active/appstream.xml
+
+ok "updated sideloaded appstream"