diff options
author | Matthew Leeds <matthew.leeds@endlessm.com> | 2019-03-05 13:04:51 -0800 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2019-03-06 23:44:50 +0000 |
commit | 4e8178916711bfe30c031b26633aef50ffc16e5e (patch) | |
tree | 4ba639ad3c6e76ff0eacd82c03055460539027d1 /tests/test-repo.sh | |
parent | 7a5c0246954566e4e7516b26beced10762290241 (diff) | |
download | flatpak-4e8178916711bfe30c031b26633aef50ffc16e5e.tar.gz |
Consistently use flatpak_load_http_uri()
Currently Flatpak has a few different implementations of helper
functions to download a URI using libsoup, but the best one seems to be
in common/flatpak-utils-http.c. So this commit deletes the others and
makes use of flatpak_load_http_uri() in place of download_uri() in a
few places. This has a couple consequences:
1) It means that we're now properly checking HTTP status codes rather
than assuming that the request was successful, in the install command,
remote-add command, and in FlatpakTransaction. This fixes an assertion
failure seen by a user when they tried to use a flatpakref URL that hit
a 404.
2) It means that in the places where we're using flatpak_load_http_uri()
we are only supporting http:// and https:// URLs not, say, file:// ones.
For the install and remote-add commands this was already being enforced.
For the handling of flatpakref files and bundles in FlatpakTransaction,
I believe it's just convention because it doesn't make much sense to
do anything else; this commit enforces that convention.
Also, add a unit test for the case of trying to install a flatpakref at
a URL that hits a 404 error.
Fixes https://github.com/flatpak/flatpak/issues/2727
Closes: #2740
Approved by: matthiasclasen
Diffstat (limited to 'tests/test-repo.sh')
-rwxr-xr-x | tests/test-repo.sh | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/test-repo.sh b/tests/test-repo.sh index 4a309760..04b7775c 100755 --- a/tests/test-repo.sh +++ b/tests/test-repo.sh @@ -23,7 +23,7 @@ set -euo pipefail skip_without_bwrap -echo "1..27" +echo "1..28" #Regular repo setup_repo @@ -169,6 +169,14 @@ fi echo "ok missing remote name auto-corrects for install" +port=$(cat httpd-port-main) +if ${FLATPAK} ${U} install -y http://127.0.0.1:${port}/nonexistent.flatpakref 2> install-error-log; then + assert_not_reached "Should not be able to install a nonexistent flatpakref" +fi +assert_file_has_content install-error-log "Server returned status 404: Not Found" + +echo "ok install fails gracefully for 404 URLs" + ${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 |