Commit Graph

490 Commits

Author SHA1 Message Date
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
Alexander Larsson
90dc9ace2a authenticator: Pass token-type for each ref
This allows the authenticator to handle each token type differently.
For example, this allows a "purchase" type to run the donation
webflow, but not require login (and then store the fact that this was
run locally).
2019-11-26 16:37:01 +01:00
Alexander Larsson
b77f7c9383 authenticator: Pass remote name to RequestRefTokens
This makes it very easy to reuse a single authenticator for several
remotes. This is useful for the a default authenticator implementation
that we can ship with flatpak and use for e.g. flathub.
2019-11-26 16:37:01 +01:00
Alexander Larsson
3411cf0336 tests: Test the webflow handling
We just verify that we can roundtrip via the cli by setting
BROWSER=curl to "finish" the webflow.
2019-11-26 16:37:01 +01:00
Alexander Larsson
2b06b0328c test-authenticator: Support requesting a web flow
If request-webflow file exists, then the authenticator will listen
to a local socket and start a webflow request with a uri pointing to it.
If anything connects to the uri it will consider the flow ok and continue.
If the client calls close() instead it will silently succeed anyway
if require-webflow doesn't exists, and fail if is exists.
2019-11-26 16:37:01 +01:00
Alexander Larsson
2cb51e5e57 tests: Fix installing org.flatpak.Authenticator.test.service.in 2019-11-26 16:37:01 +01:00
Alexander Larsson
ae13e31510 transaction: Request required tokens from configured authenticator
When we need a bearer token, look up the configured authenticator for
the remote and ask it for tokens. Also updates the test-auth test
with to use the new test authenticator instead of the previous
env var hack.
2019-11-26 16:37:01 +01:00
Alexander Larsson
094c1ee0ff tests: Add a test authenticator
This is a trivial implementation of org.freedesktop.Flatpak.Authenticator
that just reads the contents of the "required-token" file and returns
that as the tokens for all refs.
2019-11-26 16:37:01 +01:00
Alexander Larsson
d44864a74e tests: Add p2p token tests
Unfortunately we lose some error information when we pull multiple
refs, ending with a generic "something failed" error rather than the
401 error so in the p2p case we can't verify that we get the right
errors.
2019-11-26 16:37:01 +01:00
Alexander Larsson
f51cb45a4f tests: Add initial tests for token-needing installs 2019-11-26 16:37:01 +01:00
Alexander Larsson
ca5ba625a5 libtest.sh: Add gdb_bt helper
This is unused, but can be inserted in the tests if something is
segfaulting so that you can see the backtrace.
2019-11-26 16:37:01 +01:00
Umang Jain
ceab716ab6 installation: Mark apps as updatable if their runtime is missing
Mark installed apps to be updatable if an installed in missing
its runtime for some reasons. In pre-FlatpakTransaction world,
an app migration from runtime X to runtime Y would have rendered
an app unusable because runtime Y would not be installed
automatically by clients like gnome-software.

The goal here is that clients like gnome-software can show
those installed apps as updatable again, if such a situation
arises. The FlatpakTransaction API can automatically resolve one of
its ops to install the new runtime, provided we can mark the app
as updatable again at the first place.
2019-11-22 16:08:32 +01:00
Umang Jain
61f9d19eae installation: Return refs as updatable if related extensions are missing
While updating, if the related extension is missing on
the installation of an installed ref (could be an app or
runtime), FlatpakTransaction tends to "repair" the ref by
automatically downloading the related extension again and
restoring the overall functionality of the ref.

The related extension concerned that are the ones associated with
`should-download` to TRUE only.

Hence, teach the libflatpak API to do that same, so that clients
like gnome-software can mark those refs as updatable, if their
related extensions is missing.
2019-11-22 16:08:32 +01:00
Umang Jain
c76dca8550 test-list-updates: Update to use FlatpakTransaction
FlatpakTransaction will automatically download the related ref
(.Locale ref in this case). In case of mentioning previous-ids
in the deploy file, the related ref(.Locale) should be also
be requiring an update.
Hence, flatpak_installation_list_installed_refs_for_update now
will return 2 refs (app and related .Locale extension) to be
updated, instead of 1.
2019-11-22 16:08:32 +01:00
Matthew Leeds
10f6166a40 tests: Add mask command to test-basic and test-completion 2019-11-20 13:17:27 +01:00
Matthew Leeds
eabc52456a Clean up duplicated mirror refs
Due to bug #3215 some systems have refs in refs/mirrors/ in addition to
the usual refs/remotes/ location. The remote refs are always at least as
new as the mirror ones since the repo_pull() invocation in
flatpak_dir_pull() which does not use OSTREE_PULL_FLAGS_MIRROR happened
after the one that did. Cleaning up these mirror refs is important since
otherwise when the remote ref is either updated or removed (by an
uninstall) disk space will be leaked since the mirror ref will point to
a no longer needed commit.

So, remove (almost) all mirror refs during flatpak repair, uninstall,
or update operations. And for the uninstall and update operations do it
in FlatpakDir so that it happens regardless of if the CLI of libflatpak
are used.

Also, add a unit test for this.

Fixes https://github.com/flatpak/flatpak/issues/3222
2019-11-20 13:17:27 +01:00
Matthew Leeds
e467695549 tests: Delete test-p2p-security.sh
This test was intended to verify that updates from remote B can't
interfere with updates from remote A even if remote B maliciously sets
the same collection ID as remote A. However, the commits intended to
protect against this turned out to have nasty side effects and need to
be reverted.[1] A subsequent commit will revert the use of
OSTREE_REPO_PULL_FLAGS_MIRROR which means this attack is not exploitable
(since refs will be resolved using a refspec which includes the remote
name), at the cost of not supporting more than one remote having the
same collection ID configured. Since we don't support that, it doesn't
make sense to keep this unit test.

Also, the test seems to be failing.

[1] https://github.com/flatpak/flatpak/issues/3215
2019-11-20 13:17:27 +01:00
Philip Withnall
d5a1170820 doc: Clarify format of locale identifiers in extra-languages key
Also update the tests to use the same format, and make sure to include
coverage of all forms of locale (language-only, with locale, with
codeset, and with modifier).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-24 13:54:05 +01:00
Matthew Leeds
512444dc23 Merge pull request #3152 from mazen-asef/languages_locales_key
app: Change xa.extra-languages to accept locales
2019-10-16 15:50:35 -05:00
Mazen Asef
65912f27fe app: Allow locales to be stored in the extra-languages key
In order to configure gnome-software to show specific apps in one region
without showing to all language speakers, we allow the storage of full
locales on the extra-languages key. However, these locales are ignored when
calling flatpak_installation_get_default_languages, so locales will be reduced
to their language identifier (eg. en_IN locale will be returned as 'en', and
az_Latn_AZ will be returned as 'az'). In order to get the full locales, we can
call flatpak_installation_get_default_locales instead, which can return languages
and locales.
2019-10-16 16:25:06 -03:00
Matthias Clasen
caaeb53828 Merge pull request #3169 from smcv/nodist
build: Don't distribute flatpak-portal-dbus.c in tarballs
2019-10-11 08:44:22 -04:00
Simon McVittie
b64cad0f18 build: Don't distribute flatpak-portal-dbus.c in tarballs
Adding generated files to foo_SOURCES causes them to be distributed,
even if that was not intended. Use nodist_foo_SOURCES instead.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-10-11 10:22:08 +01:00
Simon McVittie
8fd5b14d08 build: Don't install test.portal as executable
There's no need for this file to be executable. If it was executed,
shells would typically try to execute it as a shell script (because it
isn't an ELF executable and doesn't start with #!), which isn't going
to work.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2019-10-11 10:17:52 +01:00
Matthias Clasen
11455525fb Merge pull request #3166 from pwithnall/3017-extension-ordering
transaction: Install extensions before apps
2019-10-10 08:46:43 -04:00
Philip Withnall
3acb4246bc transaction: Install extensions before apps
This ensures that when the operation to install the app completes, the
app is ready to run — rather than having to wait for subsequent
operations to install extensions which the app depends on (such as
content, or locales).

This fits in with the current ordering for *un*installing apps, where
the main app is uninstalled first, followed by its extensions.

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

https://github.com/flatpak/flatpak/issues/3017
2019-10-10 13:22:48 +01:00
Philip Withnall
0975c65574 build: Fix the path to some installed-tests files
Files in the srcdir need to be explicitly prefixed as such in rule
commands. This fixes `make install` when installed-tests are enabled.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-10-10 11:56:28 +01:00
Alexander Larsson
0e51264788 tests: Use regular HTTPServer, not ThreadingHTTPServer
The later requires python 3.7
2019-10-09 14:25:44 +02:00
Alexander Larsson
227cde12ba tests: Redo httpd server setup
Rather than this weird shell loop with a timeout and polling we
move the httpd spawning entirely into the python code, and use
a pipe to synchronize the spawning. This way we can also use
the shell job control to properly clean up any running processes
from the test suite.

Additionally, this adds some (lame) support for token handling in the
test webserver, where you for any file foo can create a foo.need_token
containing a token that is needed for that file.
2019-10-09 14:25:44 +02:00
Umang Jain
11631f9514 transaction: Add getter for querying no-pull
As this is a required to deploy autoupdates downloaded in the
background, for clients like gnome-software.
2019-10-08 15:21:09 +05:30
Umang Jain
c7670e87d7 transaction: Add getter for querying no-deploy
FlatpakTransaction inherently doesn't differentiate between a
autoupdate and a regular update; both are
FLATPAK_TRANSACTION_OPERATION_UPDATE.

This getter can help differentiate between a regular update
and autoupdate in clients like gnome-software. Autoupdates
work in two separate transaction passes; first that runs with
"no-deploy" and the second pass that deploys all the downloaded
update (i.e. with "no-pull").
2019-10-08 15:21:03 +05:30
Alexander Larsson
2b6641575d tests: Convert all tests to python3
Python2 is pretty much dead, lets make us only use python3.
2019-10-07 11:38:24 +02:00
Philip Withnall
0e53094645 flatpak-appdata: Add support for extracting app content ratings
This will be used in upcoming commits to enforce parental controls on
app installations.

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

https://github.com/flatpak/flatpak/pull/2797
2019-10-03 10:42:04 +02:00
Alexander Larsson
9e9c202afa Fix distcheck 2019-10-02 17:33:08 +02:00
Alexander Larsson
47d6ea12b5 tests: Remove leftover debug stuff 2019-10-02 16:53:58 +02:00
Alexander Larsson
4eb213a39a update-portal: Add tests with changed permission errors 2019-10-02 14:57:11 +02:00
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