Commit Graph

442 Commits

Author SHA1 Message Date
Alexander Larsson
ade1b299e7 tests: Test masking in updates portal
If the app is masked it should neither report updates or update
itself. Test this.
2019-10-02 14:57:11 +02:00
Alexander Larsson
d942b47b64 tests: Remove some unused code in update-portal test 2019-10-02 14:57:11 +02:00
Alexander Larsson
714f13a6a0 tests: Test self-update via the update-portal
We test a successful update, a null update and a failed update.
2019-10-02 14:57:11 +02:00
Alexander Larsson
91d9fe9c60 tests: Add simple testing portal backend and wire it up to the tests
This only supports the AccessDialog call, and always just allows
everything. Still, it tests the entire codepath for authentication.
2019-10-02 14:57:11 +02:00
Alexander Larsson
c15c1946ff test: Add test for update-portal monitoring
We add socat to the test runtime, and then we use that to run a
test app outside the sandbox as if it was inside.

The testcase connects creates a monitor and ensure we properly get signals
for updates.
2019-10-02 14:57:11 +02:00
Alexander Larsson
8ab48d5198 tests: Fix whitespace in makefile 2019-10-02 14:57:11 +02:00
Alexander Larsson
8832e7c7d1 Make test output a bit less noicy
This gets rid of some unnecessary spew that happens in every
test run and just makes the logs harder to read.
2019-10-02 14:57:11 +02:00
Alexander Larsson
161a13951b Add flatpak install --or-update operation
This allows you to ensure that a particular app/runtime is installed
and with the latest version in a single operation, which is useful
for instance in automatic use, like CI systems.
2019-09-27 09:07:13 +02:00
Alexander Larsson
c719710907 tests: Some cosmetic fixes for the version check test
Closes: #3118
Approved by: alexlarsson
2019-09-19 16:17:34 +00:00
Philip Withnall
5236608d86 tests: Fix a warning about ignoring the return value of symlink()
Assert it was successful instead. This is probably pointless from the
point of view of testing things (why would symlink() ever realistically
fail but everything else succeed?), but it does shut up a compiler
warning, which gives us a better chance to spot legitimate warnings in
future.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #3116
Approved by: alexlarsson
2019-09-19 15:51:11 +00:00
Matthew Leeds
989b18bba8 Set a collection ID on FlatpakInstalledRef objects
Currently FlatpakInstalledRef objects are constructed without the
collection-id property set. This is a problem because in the USB app
update support in the Endless fork of GNOME Software, when we find a
FlatpakRemoteRef on a USB drive which matches the ref of a
FlatpakInstalledRef object, the collection IDs of the two objects must
also match, and currently the installed one has a NULL collection ID.

So get the collection ID on the relevant configured remote when
constructing a FlatpakInstalledRef. This should be good enough in most
cases but isn't perfect; see
https://github.com/flatpak/flatpak/issues/3103

Closes: #3114
Approved by: alexlarsson
2019-09-19 15:20:15 +00:00
Matthew Leeds
9c3b42d67e testlibrary: Fix type for FlatpakTransaction::add-new-remote @reason
Closes: #3066
Approved by: alexlarsson
2019-09-19 15:20:06 +00:00
Matthew Leeds
f374a80ed7 testlibrary: Fix a typo in a URL
Closes: #3066
Approved by: alexlarsson
2019-09-19 15:20:06 +00:00
Matthew Leeds
c29e686246 installation: Don't return an error checking for updates offline
In commit b8a3075d8 I changed a few places to check if the array
returned by ostree_repo_find_remotes_finish() is empty, which would mean
either none of the configured remotes (or P2P sources) provide the
requested refs, or the one(s) that do are offline. That was mostly
correct but in the case of
flatpak_installation_list_installed_refs_for_update() we don't want to
treat empty results as an error, because otherwise GNOME Software prints
an error message when offline: "No remotes found which provide these
refs: ...".

So this commit makes list_installed_refs_for_update() return an empty
array in case it can't find any updates (we don't distinguish "remotes
checked and provide no updates" from "remotes couldn't be reached").
This matches the behavior of the non-P2P code: the for loop above which
handles remotes without collection IDs prints a debug message if an
error is encountered.

Also, add a unit test that fails without this patch.

Closes: #3066
Approved by: alexlarsson
2019-09-19 15:20:06 +00:00
Alexander Larsson
5026f01153 Support multiple versions in required-flatpak metadata key
Support a list of versions that are supported. This will be useful
for e.g. the extra_data for extensions once that is backported to
1.2, because that will require it to say that it is supported for
> 1.2.5 in the 1.2 series and > 1.4.2 otherwise.

Closes: #3112
Approved by: alexlarsson
2019-09-18 14:55:38 +00:00
Alexander Larsson
62117308c1 tests: Add test for required-flatpak versioning
This sets required-flatpak in the metadata to some different versions
and ensure we're properly able or not able to install it.

Additionally it uses some options with multiple versions. This is not
yet supported but I want to test the existing code and make sure it
properly falls back to just using the first element of the list.

Closes: #3112
Approved by: alexlarsson
2019-09-18 14:55:38 +00:00
Matthew Leeds
13279af129 Merge pull request #3058 from mazen-asef/add_default_languages_key
Add extra-languages config key
2019-09-13 13:19:08 -07:00
Mazen Asef
a0666034db app: Add new extra-languages key
If xa.languages is set, use these, and no others. Otherwise, take the union
of xa.extra-languages, and the system default locales for system repos;
xa.extra-languages for user repo and the langs based on the user's locale

Fixes https://github.com/flatpak/flatpak/issues/3043
2019-09-13 15:31:14 -03:00
Matthew Leeds
07ab6e3a7a tests: Fix whitespace and typo errors
Closes: #3065
Approved by: alexlarsson
2019-09-13 08:31:41 +00:00
Matthew Leeds
af4504c8d3 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
2019-09-13 08:31:41 +00:00
Matthew Leeds
ea19e4e5a7 flatpak-remote: Enforce GPG verification when a collection ID is set
Currently the "test_remote()" test calls
flatpak_remote_set_gpg_verify (remote, FALSE) and disables GPG
verification on a remote while a collection ID is set on it, which
should not be possible. The remote-add command enforces that GPG
verification is used if a collection ID is set, but the library API does
not. This commit changes libflatpak to return an error when such an
invalidly configured remote is being committed to disk. Also, update the
unit test to check for the newly added error, and to unset the
collection ID before disabling GPG verification.

Later in the unit test, GPG verification is re-enabled on the remote,
but libflatpak erroneously sets gpg-verify-summary=true in addition to
gpg-verify=true (summary verification is supposed to be disabled when
collections are used, but the library doesn't notice the mistake since a
collection ID isn't set in the same transaction and was already set).

This fix addresses both issues.

Closes: #3095
Approved by: alexlarsson
2019-09-13 07:21:15 +00:00
Matthew Leeds
e2752abf28 tests: Add a test for uninstall --unused
Closes: #3067
Approved by: alexlarsson
2019-09-09 10:20:34 +00:00
Matthew Leeds
b3d77bec69 common: Make uninstalls robust to a missing remote
Currently if you delete a remote when it still has installed apps (using
--force), you're then unable to uninstall those orphaned apps (or
runtimes). This commit makes the uninstall operation succeed despite the
missing remote. Since we don't need a FlatpakRemoteState for an
uninstall operation, just avoid calling flatpak_ensure_remote_state().
Also, do some refactoring in flatpak_transaction_real_run() that should
improve readability and allows us to add a g_return_val_if_fail() in the
helper function, which ensures that only uninstall operations are
allowed to not have remote state.

This also includes a unit test for uninstalling with a missing remote.

Fixes https://github.com/flatpak/flatpak/issues/1982

Closes: #3067
Approved by: alexlarsson
2019-09-09 10:20:33 +00:00
Alexander Larsson
9ec61ae328 tests: Add tests for oci registries using labels instead of annotations
Closes: #2978
Approved by: alexlarsson
2019-09-06 12:49:40 +00:00
Debarshi Ray
e82efa8603 Trim unused shared library linkages from the session helper
The org.freedesktop.Flatpak user D-Bus service isn't just used by
flatpak(1) or applications running as Flatpaks. It's also used by
toolbox(1) for similar reasons:
 * To keep various configuration files inside the container
   synchronized with the host
 * To let the container request certain commands to be run on the host

The org.freedesktop.Flatpak D-Bus service itself doesn't need much in
the way of dependencies, but inherits a lot of unused shared library
linkages through the libflatpak-common.la convenience library. Removing
these unused shared libraries reduces the footprint of toolbox(1) for
those who care about such things. eg., Fedora CoreOS.

This commit brings down the number of shared libraries to 19 from 62.

Closes: #3052
Approved by: alexlarsson
2019-08-16 09:13:43 +00:00
Matthew Leeds
5e65174e8d build-bundle: Fix resolving refs
Unfortunately in commit 253fcc6e3 I broke the build-bundle command so
that it is unable to resolve remote refs (as opposed to local ones).
This means in the normal case of building a bundle for an app installed
from a remote it fails:

$ flatpak build-bundle /var/lib/flatpak/repo gnome-calculator.flatpak org.gnome.Calculator stable
error: Refspec 'app/org.gnome.Calculator/x86_64/stable' not found

This is because flatpak_repo_resolve_rev() interprets a NULL remote name
to mean the ref is local (in refs/heads/) but in this case we just don't
know which remote it's from. This commit fixes the issue by using
ostree_repo_resolve_rev() directly which searches refs/heads/ and
refs/remotes/, and if that fails falling back to iterating over refs
returned by ostree_repo_list_collection_refs() to catch collection-refs
that may be in refs/mirrors/.

Also, add a unit test that fails without this patch.

Fixes https://github.com/flatpak/flatpak/issues/3026

Closes: #3032
Approved by: alexlarsson
2019-08-15 19:42:45 +00:00
Matthew Leeds
9928ce757f libtest.sh: Delete unreachable exit command 2019-07-02 16:12:42 -07:00
Simon McVittie
423cb7d053 testlibrary: Remove unused variables
Detected by compiling with clang.

Signed-off-by: Simon McVittie <smcv@collabora.com>

Closes: #2951
Approved by: matthiasclasen
2019-06-10 15:59:33 +00:00
Alexander Larsson
b53f937d7e Fix installable tests when running on a tty
This sets FLATPAK_FANCY_OUTPUT=0 in most tests and then special cases
the test_fancy_output() test in case the installable tests are running
on an actual tty. This was causing failures because the added bold escapes
caused some test cases to not generate the expected output.

Closes: #2907
Approved by: alexlarsson
2019-05-16 15:24:47 +00:00
Alexander Larsson
4947fa6e44 fix distcheck: Pass -f to rm to avoid interactive prompt 2019-05-10 09:07:41 +02:00
Alexander Larsson
1b2207c64e tests: Fix distcheck (test.filter is in srcdir, not builddir) 2019-05-10 08:59:41 +02:00
Alexander Larsson
c01fdee171 lib Add flatpak_remote_new_from_file() to add remotes from flatpakrefs
Closes: #2888
Approved by: alexlarsson
2019-05-09 12:39:36 +00:00
Alexander Larsson
8d674234aa lib: Add flatpak_installation_add_remote
This is basically modify_remote, but it fails if the remote is
already configured instead of modifying it. Although it also
has a if_needed option, and if that is set it will silently complete
as a no-op (exept resetting filters).

Closes: #2888
Approved by: alexlarsson
2019-05-09 12:39:36 +00:00
Alexander Larsson
1313506449 tests: Add test for updating from oci remote (currently broken)
This is currently failing with:
  Can't pull from untrusted non-gpg verified remote

Closes: #2891
Approved by: alexlarsson
2019-05-09 12:22:44 +00:00
Alexander Larsson
08c544a3f0 tests/oci-registry-server.py: Delete old images for the tag when creating
Closes: #2891
Approved by: alexlarsson
2019-05-09 12:22:44 +00:00
Alexander Larsson
436d738a16 tests: In the oci test, install both app and runtime dependencies
This tests dependencies and stuff too. Also we run it to make sure it works.

Closes: #2891
Approved by: alexlarsson
2019-05-09 12:22:44 +00:00
Alexander Larsson
d7bc26031c filters: Make a backup copy of the filter when it is set and use when needed
We still look at the regular file to pick up changes, but to avoid
issues if the file disappears (for example if it was in a package
that was uninstalled) then we still have something to show so we don't
start accidentally showing unfiltered stuff.

Closes: #2890
Approved by: alexlarsson
2019-05-09 09:46:17 +00:00
Matthew Leeds
6cfad442c5 tests: Add test-p2p-security.sh
This test is meant to test the issue described in the message for the
commit "dir: Use the right keyring to verify P2P pulls".

Closes: #2705
Approved by: alexlarsson
2019-05-09 09:12:26 +00:00
Matthew Leeds
803fa15b06 tests: Consistently use a bash shebang
There's not much point in using /bin/bash for all but three scripts and
using /bin/sh for those, so use bash for everything.

Closes: #2705
Approved by: alexlarsson
2019-05-09 09:12:26 +00:00
Alexander Larsson
39946c3959 Support .flatpakrepo files in /etc/flatpak/remotes.d
A *.flatpakrepo file in this directory will be automatically
added as a system remote with the basename (sans extension) as the
name unless that name already exist. Also, once this is done we
record the name in the repo config so that it is not applied again if
the remote is removed.

Closes: #2884
Approved by: alexlarsson
2019-05-08 08:13:52 +00:00
Alexander Larsson
b519b69e38 Add tests for adding remotes from flatpakrefs
Closes: #2884
Approved by: alexlarsson
2019-05-08 08:13:52 +00:00
Matthias Clasen
25696d67e3 Add tests for dconf utilities
Closes: #2880
Approved by: alexlarsson
2019-05-07 06:11:18 +00:00
Alexander Larsson
894151033f tests: Add tests for client-side filtering
Closes: #2869
Approved by: alexlarsson
2019-05-06 13:58:58 +00:00
Alexander Larsson
4f6428af83 appstream: Automatically rewrite appstream xml during deploy if filtering
This means only refs that are allowed will be visible in the deployed
appstream.

This sometimes means we have to uncompress the xml.gz before rewriting
and then re-compressing that.

As a result of this we now always end up with both the compressed and
the uncompressed xml file, whereas we before didn't get an uncompressed
one if the remote was using the old appstream format.

Closes: #2869
Approved by: alexlarsson
2019-05-06 13:58:58 +00:00
Alexander Larsson
9c9efe19e0 tests: Properly pass -y to install
This bug was unearthed when we suddenly started to fail when you
answered no to the prompt.

Closes: #2858
Approved by: alexlarsson
2019-04-25 10:01:14 +00:00
Alexander Larsson
c84db7714e list/remote-ls/search: Split description field
Instead of combining name and comment we split them into two columns.
We also disable the comment column by default for list and remote-ls
as it is very poor in long tables. However, it is still there for search
where it seems more useful.

Also, the Application column title changed to Application ID to make
it clearer what it is compared to the "Name" column.

Closes: #2852
Approved by: alexlarsson
2019-04-24 13:31:35 +00:00
Alexander Larsson
0b05a502a7 remote-ls: Don't list eol:ed app unless -a
Closes: #2853
Approved by: matthiasclasen
2019-04-23 16:07:13 +00:00
Simon McVittie
b07b48e206 Skip some tests if we can't use FUSE
On some systems we can't make use of FUSE, especially on the same
locked-down systems where distribution packages are typically built.
For example, official Debian autobuilders (buildds) are configured to
disallow module loading after boot has finished as a form of security
hardening, some build chroots don't have a valid /etc/mtab, and Docker
containers give us uid 0 but not CAP_SYS_ADMIN.

These checks are taken from libostree.

Signed-off-by: Simon McVittie <smcv@collabora.com>

Closes: #2824
Approved by: matthiasclasen
2019-04-15 03:09:00 +00:00
Simon McVittie
8115489116 Use system copy of xdg-dbus-proxy for build-time tests if configured
This follows the same logic as the system bwrap.

Otherwise, build-time tests will fail when we are using a system
xdg-dbus-proxy and not compiling our own (the symptom is that testlibrary
hangs).

Signed-off-by: Simon McVittie <smcv@collabora.com>

Closes: #2823
Approved by: matthiasclasen
2019-04-15 02:54:51 +00:00
Alexander Larsson
fb4a8dda21 tests: Add gnutls valgrind suppression 2019-04-12 13:01:08 +02:00