Commit graph

189 commits

Author SHA1 Message Date
Benjamin Berg
506d99e90c tests: Check that two consecutive runs work 2021-01-11 12:59:06 +00:00
Benjamin Berg
e7f47e28d7 tests: Add finger and connection sharing for virtual image
This allows testing some more conditions (e.g. forcing VerifyStop to run
into a cancellation).
2021-01-11 12:59:06 +00:00
Marco Trevisan (Treviño)
fd02922608 pam: Pick the device with more enrolled finger prints
When multiple devices are available PAM module will just pick the first
one, even if it has not enrolled fingers.

Since this can't be user configured (yet) we can be a bit smarter and
select the device that has more fingerprints configured for the user.
2021-01-05 12:16:09 +00:00
Marco Trevisan (Treviño)
195f7eaf5f tests/fprintd: Check that fingers deletion will remove user print
But will keep state dir where it is
2021-01-05 13:07:19 +01:00
Torstein Husebø
ab8dcfaa61 treewide: fix typos 2021-01-04 11:04:13 +01:00
Benjamin Berg
25a97c8276 tests: Add disconnect tests for enroll/verify/identify
We test both the scenario where VerifyStop/EnrollStop is not called
while the operation is still ongoing or when the operation is already
finished.
2021-01-04 11:00:18 +01:00
Benjamin Berg
8057e49d31 tests: Allow claiming in secondary bus helper
This saves an extra step when creating tests that disconnect.
2021-01-04 11:00:18 +01:00
Benjamin Berg
f75e800d5c tests: Allow enrolling from different device
This simplfies disconnect tests as we can do the enroll from the client
that will disconnect later on.
2021-01-04 11:00:18 +01:00
Benjamin Berg
6ae4f5e939 tests: Add get_secondary_bus_and_device helper
It returns a new bus object and the device on that bus. This allows
testing what happens if a client disconnects from the bus.
2021-01-04 11:00:18 +01:00
Benjamin Berg
c6647ba875 tests: Add test that enforces a verify/identify operation restart
In the usual test we cancel the operation immediately by calling
VerifyStop. This (often) tests the case where we don't end up restarting
the Verify operation internally.

We can easily force fprintd to have restarted already internally, so add
a test that does so by sleeping a bit. This should give us a slightly
higher branch coverage in the verify_cb/identify_cb tests.
2020-12-16 14:44:23 +01:00
Benjamin Berg
988ee01f66 tests: Add retry test for PAM 2020-12-16 14:12:37 +01:00
Marco Trevisan (Treviño)
ca216a32af test_pam_fprintd: Add test verifying the case in which we've no devices 2020-12-08 21:14:24 +01:00
Marco Trevisan (Treviño)
0122d351f9 fprintd: Add tests for device properties values 2020-12-07 15:27:14 +01:00
Benjamin Berg
4435706d20 tests: Add test that PAM gives up when daemon disappears 2020-12-07 15:27:14 +01:00
Benjamin Berg
a170a3a09f tests: Check that PAM stops if the device could not be claimed 2020-12-07 15:27:14 +01:00
Marco Trevisan (Treviño)
34a24eac77 tests/pam: Ensure that we ignore verify events before VerifyStart has completed
We had a race that was causing the events to be handled even if we were
not ready to accept them, causing a potential non-authentication.

So simulate this case, by sending a 'verify-match' event before we
started the verification and ensure that we ignore it.
2020-12-07 15:27:14 +01:00
Marco Trevisan (Treviño)
a30c45629e tests/pam: Ensure that we fail in case the user has no prints enrolled
This is both in case in we start the authentication and in the absurd
but (hey, testing!) situation in which prints gets deleted in between
the device claiming and the verification start.

To handle this second scenario we need to instruct fprintd mock to raise
an error on some special command
2020-12-07 15:27:14 +01:00
Marco Trevisan (Treviño)
3242b99410 dbusmock/fprintd: Support more complex verify scripts
This now allows:
 * Sending signals before and after method return
 * Exiting the daemon
 * Emulating NoEnrolledPrints DBus method error

Co-authored-by: Benjamin Berg <bberg@redhat.com>
2020-12-07 15:27:14 +01:00
Benjamin Berg
5ccb9ba0ec tests: Do not eat fprintd output in PAM test
It may be useful, just let it go to stdout/stderr.
2020-12-07 15:27:14 +01:00
Benjamin Berg
34b21fa917 tests: Port test to use the OutputChecker 2020-12-07 15:27:14 +01:00
Benjamin Berg
8c46fddd03 verify: Fix verify script to work correctly
The verify script would start an async routine. However, this blocks the
dbus return, which really is needed.

Also, we should only return one item of the script for each VerifyStart
run. So, fix things by pop'ing the first item and putting it on the bus
from a GLib.add_timeout handler.
2020-12-07 15:27:14 +01:00
Benjamin Berg
3a00643d5b tests: Add OutputChecker class to improve test code 2020-12-07 15:27:14 +01:00
Benjamin Berg
fc7e4d0e5c device: Do not require authentication for release/stop
If someone has started an operation, then we don't really need to
confirm they are permitted to stop it again. Not doing this has the
advantage that we cannot run into a second interactive authorization
step accidentally.
2020-12-07 15:14:07 +01:00
Benjamin Berg
c0ad5880a4 tests: Call VerifyStop in enroll_verify_list_delete test
The test didn't call this and the device would be left in an
inconsistent state, causing an error at shutdown time.
2020-12-07 12:02:32 +01:00
Marco Trevisan (Treviño)
3b0d93bcc2 tests: Add more authorization tests 2020-12-07 12:00:58 +01:00
Marco Trevisan (Treviño)
29f34cf23c tests/fprintd: Do not hang if we error on name appeared callback
But instead only wait for name to appear and do the tests in the main
function so that we can properly check the exception and depending on
its type skip the test or raise it so that it can be caught by the test
suite
2020-12-04 22:56:37 +01:00
Benjamin Berg
3b83240e57 tests: Fix detection of non-functional file permissions
If we rely on CI_PROJECT_NAME being set, then the test will fail in
similar environments outside of the fprintd main CI. So just add a
os.stat call afterwards to check whether the permission changes took
effect, and if not, then skip.

So, instead try to create a file and check that this fails.
2020-12-01 14:22:55 +01:00
Benjamin Berg
897cbd341e tests: Skip flaky test_enroll_verify_list_delete test with old libfprint
The test can hang forever unless a fixed libfprint version is used.
2020-12-01 12:46:17 +01:00
Benjamin Berg
9d0305ea05 tests: Use system utils outside of the test environment
The code to pick up the utilities from the test environment would fail
if the environment variables are not set. In that case, we can just use
the binary name and rely on PATH though.
2020-12-01 11:41:11 +01:00
Benjamin Berg
3dbfdabe01 tests: Translate skips into error code 77
This makes the meson output nicer, as it will correctly display that the
test has been skipped. It only happens if all tests in the run were
skipped, but meson always does one test a time.
2020-12-01 10:04:11 +01:00
Benjamin Berg
45cf63d589 tests: Skip hotplug test if "removed" property does not exist
The test requires libfprint 1.90.4 to work, otherwise it will just hang
forever.
2020-12-01 10:04:11 +01:00
Marco Trevisan (Treviño)
57ca0dc95e tests/pam: Don't run PAM tests in parallel
Given they could re-use the same pam-wrapper temporary dir, it's better
to avoid running them concurrently.
2020-11-27 19:30:08 +01:00
Marco Trevisan (Treviño)
85ba309e9d tests: Remove pam-wrapper temporary folder on test completion
PAM wrapper creates /tmp/pam.X files during its execution (strictly as
it does not follow $TMPDIR either), however given the low number of
combinations, we may end up in re-using the same pam.* folder during
meson test, causing a failure.

As per this, remove these temporary files on tearDown so that we won't
try reusing the same folder multiple times.
2020-11-27 19:12:06 +01:00
Benjamin Berg
ab8118bde2 tests: Add device removal test 2020-11-25 19:09:00 +01:00
Benjamin Berg
8ed77829a7 tests: Add test for a client vanishing during claim
Note that this test only works if the virtual_image driver opens up a
window for race condition by delaying the open callback.
2020-11-25 19:05:47 +01:00
Benjamin Berg
fd9a86eca4 tests: Fail test if return code is less than 0
This means that the application received a signal.
2020-11-25 19:04:44 +01:00
Marco Trevisan (Treviño)
1a860aa882 tests/fprintd: Add tests ensuring that concurrent calls to fprintd work
Simulate the case in which multiple users are trying to access a device
at the same time, verifying that the access is granted only to the one
that first completes the authorization phase and that no other client is
then allowed.
2020-11-10 14:45:59 +01:00
Marco Trevisan (Treviño)
a183b779ec tests/fprintd: Make easier to call device methods asynchronously 2020-11-10 14:45:59 +01:00
Marco Trevisan (Treviño)
9d6c7eb1a9 dbusmock/polkitd: Add ability to simulate call hangs or delays
Added various methods that allow to make methods to delay to return a
value, both by using timing functions and using a way to manually
stop and restart the calls.

This is mostly done using async callbacks in dbus methods
2020-11-10 14:45:59 +01:00
Marco Trevisan (Treviño)
110c0018a2 tests/fprintd: Make possible to call gdbus client as an async process
As per this refactor the sync call we already had so that reuses the
same code.
2020-11-10 14:45:59 +01:00
Marco Trevisan (Treviño)
5611317c72 tests: Add standalone PolkitD implementation
We need to be able to hack this to be an async daemon to perform some
multi-thread tests, so replacing default implementation with a simple
one that for now just does same of default
2020-11-10 14:45:59 +01:00
Marco Trevisan (Treviño)
0904c8a527 tests/fprintd: Ensure we can claim and release with only the verify permission 2020-11-10 14:45:59 +01:00
Marco Trevisan (Treviño)
93bad82540 fprintd: Use GDBus codegen based implementation
Fprintd is dependent on the deprecated dbus-glib, also this doesn't provide
various features we can take advantage of, like the ones for async
authentication mechanism.

So, remove all the dbus-glib dependencies and simplify the code, but without
any further refactor, and keeping everything as it used to work, while this
will give room for further improvements in subsequent commits.

Internally, we just use dbus-codegen to generate the skeletons, and we
use the generated FprintdDBusManager with composition, while we
implement the device skeleton interface in FprintDevice, so that we
don't have to use it as a proxy, and keep being closer to what it used
to be with dbus-glib.

Fixes: #61
2020-11-10 14:45:59 +01:00
Marco Trevisan (Treviño)
b2cae5cccf tests/fprintd: Check that identification with multiple images works 2020-11-06 11:06:25 +01:00
Marco Trevisan (Treviño)
3419901f65 build: Don't add the utils tests under the daemon suite 2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
c85ca09e35 tests/fprintd-utils: Ensure that we exit with error if we have no device 2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
091f373109 tests/fprintd-utils: Check the tools return values in some tests 2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
f6eb3b3ea5 verify: Pass the "any" finger parameter to the daemon
fprintd supports "any" finger parameter for the VerifyStart call, and it's
up to the daemon to pick the first known if the device doesn't support
identification.

So remove the check to verify utility and add a test to verify this is
respected.
2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
d7ca9e6095 tests/fprintd-utils: Verify happens on first finger if device has no identification
Ensure that this is true when using the utility
2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
6797928884 dbusmock/fprintd: Add ability to add a device with Identification support
Devices which have identification support "any" finger and do not fallback
to a single-finger check.
2020-11-04 21:06:13 +01:00