Commit Graph

526 Commits

Author SHA1 Message Date
Matthew Leeds
1bdd381007 test-oci-registry.sh: Fix filename in assertion 2020-06-22 11:05:53 +02:00
Matthew Leeds
e230d3c830 test-oci-registry.sh: Use RuntimeRepo= key
This is needed now that we emit a warning when it's not present.
2020-06-22 11:05:53 +02:00
Alexander Larsson
05573fb7b0 tests/test-auth.sh: Tests auto-install of authenticator 2020-06-22 10:51:36 +02:00
Alexander Larsson
620157ba12 tests: Allow specifying app id and app branch for updated apps 2020-06-22 10:51:36 +02:00
Alexander Larsson
530475b9ab Tests: Support HEAD requests in oci-registry-server
This just does a GET, which is not quite right, but will work.
This is needed for the authenticator.
2020-05-04 16:32:22 +02:00
Alexander Larsson
4d79110cb6 tests: Make OCI authenticator available 2020-05-04 16:32:22 +02:00
Alexander Larsson
1c04fc3bed Tests: Fix test due to change in uninstall behaviour
Removing multiple refs where one is missing is now a warning, not a
failure, so change the test to just try to remove one ref.
2020-04-23 10:59:27 +02:00
Matthew Leeds
cff972e422 testlibrary: Simplify code a bit 2020-04-16 09:22:11 +02:00
Matthew Leeds
f6e81f8caf testlibrary: Fix a whitespace issue 2020-04-16 09:22:11 +02:00
Matthew Leeds
e847bb31b6 installation: Re-implement list_installed_refs_for_update()
Re-implement flatpak_installation_list_installed_refs_for_update() using
a FlatpakTransaction, so we can guarantee it always gives the same set
of things to update as the update command. This API is used by GNOME
Software and many times in the past g-s has not shown the same list of
apps to be updated as the flatpak CLI. See:
- https://gitlab.gnome.org/GNOME/gnome-software/issues/539
- https://gitlab.gnome.org/GNOME/gnome-software/-/merge_requests/430

This commit also expands the unit tests for this API, which were already
quite good. Now we test that missing subpaths of locale extensions show
up as updates, and updates that have been pulled but not deployed show
up as well. The latter is a break from how this function used to behave,
but it seems unlikely to break any application.
2020-04-16 09:22:11 +02:00
Alexander Larsson
b28271bb5e Merge pull request #3498 from alexlarsson/use-symlinks-for-sideload-config
Use symlinks instead of xa.sideload-repos config option
2020-03-30 16:03:54 +02:00
Alexander Larsson
9a9dac7869 tests: Drop old reference to p2p 2020-03-30 15:05:01 +02:00
Alexander Larsson
15c761d482 Use symlinks instead of xa.sideload-repos config option
Instead of having a global config option we scan a directory for
symlinks into the sideload repos. These come from
/var/lib/flatpak/sideload-repos and /run/flatpak/sideload-repos (for
default system installation).

This is much easier to update atomically, and the two different
options are useful for persistant (the first) or dynamic (the second)
usescase.

Fixes https://github.com/flatpak/flatpak/issues/3494
2020-03-26 11:50:54 +01:00
Simon McVittie
6ba07613b4 installation: Formally deprecate deprecated methods
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-03-25 12:56:56 +00:00
Alexander Larsson
05eba2b32c Merge pull request #3474 from flatpak/wip/hadess/more-similar-appids
common: Allow version numbers in app-id for DConf migration
2020-03-25 09:57:43 +01:00
Alexander Larsson
aa6d9550c1 Merge pull request #3476 from alexlarsson/drop-p2p
Drop support p2p in favour of simpler side-loading scheme
2020-03-25 09:54:41 +01:00
Alexander Larsson
a843d2d594 sideload: Add api and CLI support to specify sideload repos dynamically 2020-03-24 14:01:20 +01:00
Alexander Larsson
e4df0fa6a6 sideload: Support pulling individual objects from sideload repos
We use the localcache-repos option to ostree_repo_pull to make ostree
directly import any files that are locally available in the sideload
repo even when pulling the main commit from upstream.

This also adds a test that verifies that such files are not
pulled via http.
2020-03-24 11:46:33 +01:00
Alexander Larsson
d30e902d9f Add build-update-repo --deploy-sideload-collection-id option
This is a new version of --deploy-collection-id that only applies
the collection id update for new (1.7.x+) version of flatpak clients.
This allows you to enable collection ids for sideload use but not
affect older clients where the p2p codepaths are not as tested.
2020-03-23 17:58:04 +01:00
Alexander Larsson
9208913664 Migrate config: Always enable gpg-verify-summary if collection id is set
This used to not be set for collection-id remotes as we used the
ostree-metadata branch for resolving. However, we now use the summary
always when doing a remote install (and not ostree-metadata for local
sideloads), so we still want to verify summary.

The signature on the summary is a nice security feature, but it is also
a very efficient small file to download to verify that no new summary
needs to be downloaded in the no-op update case.
2020-03-23 17:58:04 +01:00
Alexander Larsson
cd88ddd2af tests: Add more tests for sideloading
* Test that we load from sideload repo even when online
 * Test that when offline we don't update to older version in sideload repo
 * Test update to explicit version in sideload repo
 * Test updates to new version from sideload repo
2020-03-23 17:58:04 +01:00
Alexander Larsson
9abbb00b33 Drop xa.sideload-collection remote option in favour of regular collection-id
Nothing fundamentally happens differently in ostree if the collection-id
is set, as long as we don't call the p2p specific apis. So, lets keep
using it instead of adding our own special magic.
2020-03-23 17:58:04 +01:00
Alexander Larsson
7710549596 tests: Add tests for sideloading apps 2020-03-23 17:58:04 +01:00
Alexander Larsson
904e7b2e2f tests: Remove test-unsigned-summaries.sh
We no longer support unsigned summaries since we dropped the use
of the ostree-metadata branch for p2p.
2020-03-23 17:58:04 +01:00
Alexander Larsson
124b0be92e Drop more collection_id use
Most code that looks for a regular collection id set on the remote is
removed, as these should never happen in flatpak repo setups now.

Some is replaces with looking at xa.sideload-collection-id:
 * The libflatpak FlatpakRef::collection-id property now comes comes from the sideload id
 * Various CLI commands showing or changing the collection-id for a remote now uses the sideload id
 * Collection id deploy in update now sets the sideload-collection-id instead
 * Setting the collection id for a remote in libflatpak now sets the sideload id

Additionally we now delete the code that allows unsigned summaries
when there is a collection id (because there is none).

create-usb now uses the sideload id as as collection id source when exporting.

The direct repo operations (export, bundle, commit-from) still support
collection ids, because on the server we do want to set it so that we
can sideload.
2020-03-23 17:58:04 +01:00
Alexander Larsson
336a127f55 Support sideloaded repos
This adds a xa.sideload-collection-id option to the remote
configuration and a global xa.sideload-repos option (which is a list
of paths to local repos).

When resolving or listing refs, if we fail to download the real remote
summary (i.e. we're offline) then we instead look into the configured
sideloaded repos for refs that match ref and the sideloaded collection
id for the remote.

For the transaction to resolve the ref we need more metadata. In the
regular summary case we use the metadata from the summary, but that
is not available in the (partial) summary in the sideload repo, so
there we load the actual commit object and use the data from there.
(The ostree-metadata branch is not used/needed.)

This actually also fixes a longstanding issue when you "flatpak update
--checksum=XYZ" because we now handle this correctly by downloading
the commit object from the remote. Before we used the metadata in the
summary which is not right for non-HEAD commits.

To handle the sideloading we record the path to the sideload repo
when sideloading and pass the url to the repo as the remote name
when pulling, which will do a direct local pull.

We avoid using sideloaded refs when offline if the timestamp in the
commits is older than what is already installed locally.
2020-03-23 17:58:04 +01:00
Alexander Larsson
9061b855d8 Initial remove of p2p codepaths
This removes the most basic codepaths for p2p installation, as well
as the tests for it. There still remains various codepaths that
looks as the collection id, these will be removed later.

This is the first step in dropping the p2p code and replacing it with
a simpler approach that focuses on the sideloading case only.
2020-03-23 17:58:04 +01:00
Alexander Larsson
116a8b8487 transaction: Ensure the metadata in the pulled commit matches what we resolved
We're using the metadata from the summary, ostree-metadata or available
commit when making security sensitive decisions, so lets verify this
matches what we get in the actual commit we pulled.

We already did check that this then actually also matches what gets deployed,
so the new check shares code with that.

Note, we don't do this for OCI installs, because it seems the current
fedora flatpaks don't have this set, and we don't want to break
existing remotes.
2020-03-23 17:58:04 +01:00
Alexander Larsson
224b60016f tests: Print calling file+lineno when assert fails 2020-03-23 17:58:04 +01:00
Matthew Leeds
384c68d77a test-http-utils.sh: Fix a few typos 2020-03-20 15:52:50 -07:00
Alexander Larsson
ee93324333 tests: Avoid showing stderr for commands expected to fail 2020-03-20 15:37:10 +01:00
Alexander Larsson
241c5c7f40 tests: Hide unnecessary trace output from the test logs
We use some BASH_XTRACEFD hackery to hide the trace output from
the internals of the assert (and ok) functions, so that the
log output can focus on what is important, i.e. what asserts are
checked and what errors do they print.
2020-03-20 15:37:10 +01:00
Alexander Larsson
b1fdf6c4ef tests: Add and use "ok" helper
This allows us to print some separators for the logs also.

tests: Convert more tests to ok helper
2020-03-20 15:37:10 +01:00
Bastien Nocera
98c4b07322 common: Allow version numbers in app-id for DConf migration
Allow the app-id or the DConf path to finish with a digit and still be
considered similar enough for DConf migration purposes.

This allows the org.gnome.Rhythmbox3 app-id to migrate its
/org/gnome/rhythmbox DConf path.

See https://github.com/flathub/org.gnome.Rhythmbox3/pull/26
2020-03-17 13:12:57 +01:00
Bastien Nocera
a4df2bae2b tests: Better failure output for test_dconf_paths
Output whether we get an unexpected failure or success, and the values
we passed in, to make it easy to pinpoint the failing test.
2020-03-17 13:11:54 +01:00
Alexander Larsson
ab5f2dd7e8 tests: Fix gpg signature failure checks
It seems recent ostree reports a different error string for signature
check failures.
2020-03-16 15:01:54 +01:00
Matthew Leeds
8d49baaff9 testlibrary: Account for when origin remote is created
In test_transaction_install_local(), we test that the origin remote
created when installing from a local repo doesn't exist before
flatpak_transaction_run() is executed and does exist afterward. However,
the origin remote is created before the transaction is run; see the
flatpak_dir_create_origin_remote() call in
flatpak_transaction_add_ref(). The only reason this discrepancy has not
caused a test failure is that the FlatpakDir object held by the
FlatpakInstallation object is not reloaded when the origin remote is
added (so it's reading an old copy of the repo config). This issue will
be fixed in the commit following this one.
2020-02-12 16:41:06 +01:00
Alexander Larsson
ba7b9c30d6 tests: add some missing includes 2019-12-20 13:45:37 +01:00
Alexander Larsson
86c9e55561 tests: Drop oci label/annotation separate tests
We only do labels now, so no need to test both.
2019-12-19 18:01:00 +01:00
Alexander Larsson
cc4ea023f0 tests: Only fail FLATPAK_TESTS_VALGRIND_LEAKS for *definite* leaks 2019-12-19 16:52:36 +01:00
Alexander Larsson
aabadfdc8e authenticator: Fix sandboxed authenticators
We rely on broadcast signals for authenticator replies rather than unicast
as these are not filtered by the sandbox (due to them being opt-in by the
receiver).

Actually this already worked fine in the flatpak side as the generated
code already subscribes to the signals, this just switches the internal
authenticators (test and oci) to using the new way to emit signals.
2019-12-19 10:33:21 +01:00
Simon McVittie
777d80e2e4 testlibrary: Fix some leaks in the test itself
Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-12-17 15:00:07 +01:00
Simon McVittie
b72cd803e0 flatpak.supp: Silence GFile leak in flatpak_get_user_base_dir_location()
This is deliberately allocated once per process and never freed.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-12-17 14:58:15 +01:00
Alexander Larsson
bc1edce45a tests: Add new glib suppression
Seems there is a new GPrivate method in town!
2019-12-17 14:55:13 +01:00
Alexander Larsson
7fedf3578f OCI: Only use labels, never annotations
This is a slightly incompatible change, as we now only support
oci images generated with (what was before) build-export --oci-use-labels.
However, there are not a lot of OCI implementations in the wild, and
we can modify the ones in use to ensure there are labels (and
annotations if needed for older flatpak clients).

This also removes the --oci-use-label option from build-bundle --oci as
this is now the default.
2019-12-16 09:23:49 +01:00
Alexander Larsson
260c6f713d tests: Test passing of arguments to authenticator 2019-12-13 15:08:29 +01:00
Alexander Larsson
38c86bdf0f Authenticator: Add extra a{sv} args for future use
These are not used atm, but make the APIs future proof.
2019-12-12 14:27:59 +01:00
Alexander Larsson
4dba1c389b authenticator: Add more data to token request
This adds the remote uri, and the per-ref commit id, as well
as extensible per-ref and per-request dicts we can add stuff to
as needed.

These will be used for the OCI case.
2019-12-12 12:16:53 +01:00
Will Thompson
babb2da71a tests: test search-provider DefaultDisabled logic
2ebf672866 introduced special handling to
mark exported GNOME Shell search provider .ini files as disabled by
default. This functionality was not previously tested.
2019-11-29 20:15:08 +00:00
Alexander Larsson
d3c05f052c test: Dist web-server.py 2019-11-27 15:11:15 +01:00