846 Commits

Author SHA1 Message Date
John Cardullo
f653896b18 tests: Add test cases for file-forwarding in test-run.sh
Add regression tests to verify that remote URIs and local files can
be forwarded correctly, and that empty paths result in an error.
2026-07-03 17:16:06 +00:00
bbhtt
5fcf748ac9 dir: Don't pass temp repo path to flatpak_dir_log during initial pull
During a system install with the system helper enabled, the initial
network pull goes to a temporary repo and then via pull local from that
repo to the final system repo while during user install there is only
one pull from network to the final repo.

c672c55 set the logger to use the temporary repo path as installation
but the history command afc87ad since the same day filters the initial
pull out as the installation name will never match the temporary path.

This causes the initial pull operation to be never show up in flatpak
history when using system installs while they work for user installs as
`INSTALLATION=user`.

This is presumably also broken for custom installations as they
will similarly not match the temp repo path.

So don't pass the path at all to flatpak_dir_log and we can later
fall back via flatpak_dir_get_name_cached() which sets the correct
`INSTALLATION` for system installs ie. `INSTALLATION=system`.

This also allows us to remove the workaround of adding two different
expected history outputs from ad1ff6d as both branches log the pull.

Without system helper `flatpak install` needs to be executed as
priviledged to operate on system install so the initial pull was
always logged correctly for that branch.
2026-06-23 09:11:59 +00:00
bbhtt
ad1ff6da68 tests: Fix expected history output when system helper is compiled out
Pulls do not go to the temp repo so they are logged when system
helper is compiled out
2026-06-18 21:15:41 +00:00
bbhtt
d820c4bc5e tests: Fix FL_CACHE_DIR when system helper is compiled out
The tests assumed that a system installation always uses the XDG cache
location unless running as root. However, Flatpak only uses that cache
location when the system helper is available at both compile and run
time. [1]

Builds configured with -Dsystem_helper=disabled instead use the
repo-local cache directory [2], causing the tests to look for cached
summaries in the wrong location and fail.

[1]: 96ad6825f3/common/flatpak-dir.c (L4853-L4862)
[2]: 96ad6825f3/common/flatpak-dir.c (L4942-L4943)
2026-06-18 21:15:41 +00:00
bbhtt
489b3972cb tests: Skip seccomp tests when seccomp is unavailable
Fixes the testsuite with `-Dseccomp=disabled`.
2026-06-18 21:15:41 +00:00
Mia McMahill
cebc323966 tests: Add test for building and installing with exported releases.xml
Adds a test that verifies releases.xml metainfo files are not duplicated
at any export stage, and that they are not left unexported either.
2026-06-16 11:20:58 +00:00
Luigi Pavan
b9c3cdd7a4 tests: Add test for installing from an auth-protected OCI registry
Add a regression test that installs from an auth-protected OCI registry.
The registry requires a bearer token for all /v2/ requests; the client
authenticates via the mock test authenticator and the installation
completes successfully. The test runs for both user and system install
paths.

Assisted-by: Cursor
2026-06-11 18:26:52 +00:00
Luigi Pavan
a5b15b9aa1 tests/oci-registry: Add bearer token auth support to the mock OCI registry
Add infrastructure for testing OCI installations from auth-protected
registries. The mock server now supports requiring a bearer token on all
/v2/ requests, configurable via a new POST /testing-auth/configure admin
endpoint. The client gains a corresponding 'configure-auth' subcommand.

Assisted-by: Cursor
2026-06-11 18:26:52 +00:00
bbhtt
a38377eb88 tests: Suppress an unused-result warning
The warning seems to happen with GCC 11 but not with GCC 13 or newer.

A simple void cast still leaves the warning enabled due to a bug
or intentional choice in GCC [1], so it is assigned to a variable first
and then void-ed.

[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
2026-05-27 14:32:40 +00:00
Sebastian Wick
17cb1135cb context: Keep fallback-x11 separate from x11 conditionals
If we convert fallback-x11 internally to a conditional x11 permission,
we cannot express current fallback-x11 stacking behavior:

lower: empty + upper: !fallback-x11 -> no x11 access
lower: fallback-x11 + upper: !fallback-x11 -> x11 access

The reason is that conditionals have no view of the lower level.

This changes things in a way that fallback-x11 stays its own socket
permission with two interactions with the x11 socket permission:

* If a upper level resets x11 (--socket=x11, --nosocket=x11), the lower
  level fallback-x11 permission gets dropped
* When computing the allowed sockets, --socket=fallback-x11 gets
  converted to --socket=if:x11:!has-wayland

Fixes: #6556
2026-04-29 10:14:29 +00:00
Sebastian Wick
bd75302323 tests/repo: Make a test more robust by checking files for diff
Instead of trying to read them into variables, which could fail if there
were null bytes in the key.

Fixes: 43642337 ("dir: Try to delete the remote if we failed to add it entirely")
2026-04-28 13:18:48 +00:00
Sebastian Wick
3296c9e619 system-helper: Fix checking if the reinstall flag was passed in
Fixes: 919d2922 ("common: support reinstall option on bundle installations")
2026-04-28 13:18:48 +00:00
Sebastian Wick
68343e938f tests: Fix checks where we expect a command to fail
I was convinced that the pattern `! command` with -e aborts when
`command` fails. This is not the case (the result of `false` is the same
as `! true` but somehow this doesn't matter).

Fix the tests and use the newly introduced `assert_not` function. One
could also use `command && assert_not_reached "message"` but who has
time to write error messages for all the cases.
2026-04-28 13:18:48 +00:00
razzeee
6dfe1ad4d0 dir: handle missing remote tracking ref in repo_pull so that Flatpak-Upgrade-From header is sent 2026-04-21 11:28:31 +00:00
razzeee
fad37dfa8c tests: add test for Flatpak-Upgrade-From header on install vs update
Add an integration test that verifies the Flatpak-Upgrade-From HTTP
header is correctly sent during update operations but absent during
fresh installs. This header is used by Flathub to distinguish updates
from new installs in download statistics.

To support the test, extend web-server.py to optionally log Flatpak-*
request headers to a separate file.
2026-04-21 11:28:31 +00:00
Gordon Messmer
fffe38a2b0 common: Report the age of the configuration
This change will allow applications to determine if their data
is older than the flatpak configuration, to aid cache invalidation.
2026-04-20 14:00:20 +00:00
Sebastian Wick
43642337e4 dir: Try to delete the remote if we failed to add it entirely
Ideally, we would be able to atomically add and remove remotes, but
we're very far from that ideal state. The current behavior is really
suboptimal and leaves the remotes in a inconsistent state if
initialization failed. We can at least make it better by trying to clean
up the half-initialized mess we're currently in. It does however not
protect against SIGKILL-like aborts, as that would require it to be
atomic.

Closes: #6449
Co-authored-by: craftyguy "Clayton Craft" <clayton@craftyguy.net>
2026-04-20 13:59:14 +00:00
Razze
3f2e10e274 tests: add missing assertions after second flatpak_usb_parse_usb_list call
The call to flatpak_usb_parse_usb_list() lacked the
g_assert(ret) and g_assert_no_error(error) guards that are present
on the first call.
2026-04-18 20:33:07 +05:30
Sebastian Wick
3c843932aa tests: Use meson to enumerate the tests
This gets rid of the test-matrix generation, and instead enumerates all
the tests in meson.

Some people (including me) constantly modified the generated meson
instead of the test-matrix generator file because they find it so
uncommon and unusual that a meson file is generated.

This looses the combinatorial combination of the generated system, but
in practice, six lines of enumeration is not bad, and it makes things
easier to understand.
2026-04-16 12:00:46 +00:00
razzeee
655ddb42ec tests: add test-run-custom.sh to test matrix source
test-run-custom.sh was only manually appended to test-matrix/meson.build
and would be lost on regeneration. Add it to update-test-matrix so it is
properly managed.
2026-04-13 16:00:54 +00:00
Razze
51cff37bea tests: fix copy-paste bug checking mid_high instead of highest 2026-04-12 07:37:43 +05:30
Razze
758a096d72 tests: remove duplicate g_mkdir_with_parents call for dont_hide in test_full 2026-04-12 07:25:11 +05:30
razzeee
39dda201c9 tests: fix copy-paste bug using is_arch instead of is_branch in test_decompose 2026-04-10 16:01:35 +00:00
razzeee
f5f70a511e tests: Add messages for missing os-release and pre-create directory checks 2026-04-10 15:52:46 +00:00
razzeee
cff9812514 repair: disable auto-pin to preserve pin state across reinstalls
When repair (re)installs runtimes via a transaction, the transaction
auto-pins every runtime it touches. This causes repair --reinstall-all
to pin every installed runtime, cluttering the pin list with runtimes
that were never explicitly pinned by the user and preventing
flatpak remove --unused from cleaning them up.

Fix this by disabling auto-pinning on the repair transaction so that
the pin state is left exactly as it was before the repair.

Fixes https://github.com/flatpak/flatpak/issues/6565
2026-04-10 15:36:00 +00:00
Sebastian Wick
1364527683 tests: Check that flatpak-run fd-arguments do not leak to the command
flatpak-run takes a number of arguments which are file descriptor
numbers. Those file descriptors are supposed to set something up in the
way the instance gets spawned, but should never make it to the wrapper
command.
2026-04-10 14:50:21 +00:00
razzeee
3eadc2c379 tests: remove duplicate g_set_print_handler call in test_format_choices teardown 2026-04-10 14:50:09 +00:00
Simon McVittie
50dda82eb0 libtest: Allow adding a new ref to an existing temporary ostree repo
When we run `tests/test-run-custom.sh` as a build-time test,
we expect to already have the necessary runtimes, apps, etc. in
`${builddir}/tests/runtime-repo`. However, when running "as-installed"
tests, we're using a fresh temporary ostree repo for each test.
Merely having the repo exist is not enough: for some tests, and in
particular `tests/test-run-custom.sh`, it needs to have more than one
runtime available.

Resolves: https://github.com/flatpak/flatpak/issues/6591
Signed-off-by: Simon McVittie <smcv@collabora.com>
2026-04-10 14:13:39 +00:00
bbhtt
79cb10e880 tests: Add test for NoRuntime extra-data app 2026-04-10 11:37:40 +00:00
Sebastian Wick
8599a5109c tests/test-run-custom: Test --bind-fd and --ro-bind-fd 2026-04-08 23:19:02 +00:00
Sebastian Wick
a8e3c72454 tests/test-run-custom: Test --usr-path, --usr-fd, --app-path, --app-fd 2026-04-08 23:19:02 +00:00
Kolja Lampe
3178d97321 common: allow automatic branch following for extensions
When an application or runtime is updated and its metadata requests a
new branch of an extension, Flatpak should automatically pull the new
branch if the user already has at least one branch of that extension
installed.

This ensures that "no-autodownload" extensions (like GIMP plugins)
stay functional after an update that requires a new branch, while still
respecting the user's explicit opt-in (the existing installation of
a previous branch).

Fixes: https://github.com/flatpak/flatpak/issues/4208
2026-03-29 19:25:09 +00:00
Kolja Lampe
f2ff272157 tests: Add test-preinstall.sh to the test matrix source
test-preinstall.sh was present in the generated test-matrix/meson.build
but missing from TEST_MATRIX_SOURCE in update-test-matrix, meaning it
would be dropped if the matrix were regenerated.
2026-03-28 14:23:02 +00:00
Simon McVittie
0c9a818f8d tests: Mention [systemd-]localed in debug messages, not "located"
This was not a typo for "located": the daemon is systemd-localed,
or localed for short.

Fixes: bb549168 "fix: cross typos, detail below"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2026-03-19 21:16:19 +05:30
rezky_nightky
bb54916814 fix: cross typos, detail below
What I did
Repository rules / “don’t edit” areas
From CONTRIBUTING.md and subprojects/README.md, subprojects/ contains vendored/submodule/copylib code (bubblewrap, libglnx, dbus-proxy, variant-schema-compiler). I treated subprojects/ as third-party and excluded it from typo fixing.

You already skip po/ (translations) and node_modules/, and I kept those exclusions.

Typos fixed (project-owned files only)
I ran codespell with write mode and exclusions, and fixed the reported typos across:

NEWS
app/…
common/…
doc/…
tests/…
session-helper/…
portal/…
data/…
Then I handled the remaining items individually:

NEWS: thse -> these
common/flatpak-utils-private.h: Thse -> These
app/flatpak-polkit-agent-text-listener.c: identies -> identities
tests/test-auth.sh: Propertly -> Properly
tests/testlibrary.c: remore -> remote
common/flatpak-transaction.c: improved wording to avoid the xwindows typo (X11 window ID)
Added .codespellrc
Created .codespellrc:

skip: node_modules,po,subprojects
ignore-regex: .*(ratatui|Affinitized|affinitized).*
ignore-words-list: nd,ot,THUR,IST,fo,hel,bu
(these were confirmed as legitimate tokens/abbreviations/namespace prefix/test strings in this repo, so they should not be “fixed”)
Verification:

codespell --config .codespellrc . now exits clean.

Signed-off-by: rezky_nightky <with.rezky@gmail.com>
2026-01-21 17:58:19 +00:00
Simon McVittie
c324778b07 tests: Tell "as-installed" tests where they can find triggers
Since commit d10e1148 "Add initial support for preinstalling flatpaks",
the test suite sets FLATPAK_DATA_DIR to a temporary directory, both
while running uninstalled and as-installed.

While running uninstalled we already set FLATPAK_TRIGGERSDIR to the
trigger scripts in the source tree, but when running "as-installed",
we need to run the triggers that the OS installs as part of the flatpak
package (or equivalent).

Not having this caused autopkgtests (automated as-installed tests) in
Debian to regress with 1.17.x.

Fixes: d10e1148 "Add initial support for preinstalling flatpaks"
Signed-off-by: Simon McVittie <smcv@debian.org>
2025-12-18 14:52:35 +00:00
Sebastian Wick
6667e1d361 context: Use the new permission system for shares and features
This gives us conditionals for shares and features. So far we have no
use case for this, but the system already exists, it makes the code
simpler, and when we need this in the future, we don't have to wait for
it to roll out.
2025-12-08 19:33:09 +00:00
Sebastian Wick
f242199eca tests: Test signed OCI images 2025-12-08 19:09:56 +00:00
Sebastian Wick
725fdc75ce tests/test-preinstall.sh: Add test for sideloading with network failure
If there is a sideload repo we should be able to pick it up when there
are non-sideload repos which cannot be reached.
2025-12-08 19:04:45 +00:00
Sebastian Wick
e807ca3539 tests/test-history.sh: Make testing for working journalctl more robust
journalctl also prints something when the message didn't make it to
whatever journalctl connects to. Check for the specific message showing
up instead to make sure it all works as expected.
2025-12-01 17:19:09 +00:00
Sebastian Wick
9ebe43a0c7 tests: Do not redirect stdout twice in test-unused.sh
The '&>' already redirects both stdout and stderr. Adding another '>'
makes it ambiguous where stdout gets redirected to.
2025-12-01 17:19:09 +00:00
Sebastian Wick
40640819d4 tests/asan: Update the asan suppression file
If gdk-pixbuf uses glycin, there might be a leak.
2025-11-21 14:21:13 +00:00
Sebastian Wick
e9e713fa0d tests: Add test-extra-data.sh to test extra-data installation
There are two sub-tests, one testing it with a ostree remote and one
with a OCI remote.
2025-11-20 23:14:18 +00:00
Sebastian Wick
e4edecdef5 utils-http: Drop libsoup2 support in favor of libcurl
A few years ago there was a very painful attempt at porting from
libsoup2 to libsoup3. Flatpak libsoup3 support never landed and it seems
like a large amount of distros have switched over to libcurl instead.

This commit removes libsoup2 support completely instead of growing
libsoup3 support.

Closes #5915
Closes #4582
2025-11-20 17:40:57 +00:00
Owen W. Taylor
c8e73a0993 test-oci-registry.sh: add a test for zstd layers 2025-11-20 17:30:07 +00:00
JakobDev
9b51edf31a portal: Allow passing device permissions to subsandbox 2025-11-20 17:19:42 +00:00
Sebastian Wick
842472d234 transaction: Preinstall from first remote with ref
We could previously just assume that the first enabled remote
(potentially matching the collection ID) contains the ref, but that
obviously is not always the case.

The change here looks up the remote state of the remotes to figure out
if they actually contain the ref, and adds the first matching remote to
the transaction.
2025-10-30 11:21:35 +00:00
Achill Gilgenast
bd468a8959 tests: Dont add locales to test runtime on musl
musl libc doesn't provides locales under /usr/share/locales. The tests
still run fine without copying locale under musl.
2025-10-14 09:53:05 +00:00
Sebastian Wick
8a21f2dfe1 tests/test-http-utils.sh: Only use have_xattr if we have setfattr
Otherwise we try to call setfattr which fails and have_xattr reports
that there is no xattr support. This might then obviously be wrong and
the test can fail because of that.
2025-10-13 18:42:55 +00:00
Sebastian Wick
78b3c47c13 tests/test-run.sh: Only test for trigger results if we have the deps
If the binaries are not available in the environment, the trigger will
not do anything. The tests will not know about this and fail. So only
test for the results of the triggers if they have the dependencies they
require.
2025-10-13 18:42:55 +00:00