summaryrefslogtreecommitdiff
path: root/tests/test-repo.sh
diff options
context:
space:
mode:
authorMatthew Leeds <matthew.leeds@endlessm.com>2019-07-22 18:31:11 -0700
committerAtomic Bot <atomic-devel@projectatomic.io>2019-09-13 08:31:41 +0000
commitaf4504c8d3a2e00b2d968644517ef8a9180afcd6 (patch)
tree2d5a957cc6d425a9dbecd8a776b84cb65da0df72 /tests/test-repo.sh
parentc804042df4813352153f7a79189356fa2ed5b290 (diff)
downloadflatpak-af4504c8d3a2e00b2d968644517ef8a9180afcd6.tar.gz
dir: Ignore trailing slash in remote URIs
Currently if you have a remote configured with the URL "https://dl.flathub.org/repo/" (as you would if you use the flatpakrepo file) and you use a flatpakref file which specifies the URL "https://dl.flathub.org/repo", Flatpak tries to add a duplicate remote because it doesn't see those URLs as equal. So ignore the trailing slash when comparing remote URLs. OSTree works equally well with both kinds (it uses g_build_filename()). Flathub served flatpakref files with URLs missing a trailing slash until this commit: https://github.com/flathub/ansible-playbook/commit/b20694f09 Also, add a unit test that fails without this patch. Fixes https://github.com/flatpak/flatpak/issues/2979 Closes: #3065 Approved by: alexlarsson
Diffstat (limited to 'tests/test-repo.sh')
-rw-r--r--tests/test-repo.sh40
1 files changed, 39 insertions, 1 deletions
diff --git a/tests/test-repo.sh b/tests/test-repo.sh
index 8c3b19f5..3ef9b94a 100644
--- a/tests/test-repo.sh
+++ b/tests/test-repo.sh
@@ -24,7 +24,7 @@ set -euo pipefail
skip_without_bwrap
skip_revokefs_without_fuse
-echo "1..34"
+echo "1..35"
#Regular repo
setup_repo
@@ -178,6 +178,44 @@ assert_file_has_content install-error-log "Server returned status 404: Not Found
echo "ok install fails gracefully for 404 URLs"
+# Use a new remote so we can be sure it doesn't match any existing one's URL
+setup_repo_no_add flatpakref org.test.Collection.Flatpakref
+
+cat << EOF > repos/flatpakref/flatpakref-repo.flatpakrepo
+[Flatpak Repo]
+Version=1
+Url=http://127.0.0.1:$(cat httpd-port-main)/flatpakref/
+Title=The Title
+GPGKey=${FL_GPG_BASE64}
+EOF
+
+if [ x${USE_COLLECTIONS_IN_CLIENT-} == xyes ]; then
+ echo "DeployCollectionID=org.test.Collection.Flatpakref" >> repos/flatpakref/flatpakref-repo.flatpakrepo
+fi
+
+cat << EOF > org.test.Hello.flatpakref
+[Flatpak Ref]
+Name=org.test.Hello
+Branch=master
+Url=http://127.0.0.1:$(cat httpd-port-main)/flatpakref
+GPGKey=${FL_GPG_BASE64}
+RuntimeRepo=http://127.0.0.1:$(cat httpd-port-main)/flatpakref/flatpakref-repo.flatpakrepo
+EOF
+
+${FLATPAK} ${U} uninstall -y org.test.Platform org.test.Hello
+
+# Ensure that only one remote is added even though the URL in the flatpakref
+# does not have a trailing slash and the URL in the flatpakrepo file does
+NUM_REMOTES_BEFORE=$(flatpak remotes | wc -l)
+${FLATPAK} ${U} install -y org.test.Hello.flatpakref
+NUM_REMOTES_AFTER=$(flatpak remotes | wc -l)
+
+if [ $NUM_REMOTES_AFTER -ne $((NUM_REMOTES_BEFORE + 1)) ]; then
+ assert_not_reached "install of flatpakref should only add one remote"
+fi
+
+echo "ok install flatpakref normalizes remote URL trailing slash"
+
${FLATPAK} ${U} uninstall -y org.test.Platform org.test.Hello
if ${FLATPAK} ${U} install -y test-missing-gpg-repo org.test.Platform 2> install-error-log; then