Commit graph

178 commits

Author SHA1 Message Date
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
Marco Trevisan (Treviño)
d6c70be822 dbusmock/fprintd: Add ability to remove devices 2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
d33a7c7e9d tests/fprintd-utils: Check that all fingers are listed 2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
94d3a18dcd tests/fprintd-utils: Check that verify returns an error if no finger is set 2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
5635383c96 tests/fprintd-utils: Check that fprintd-verify requests the expected finger 2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
ac98b881be dbusmock/fprintd: Make possible to retrieve the finger selected for verification
So that we can ensure that the client requested the one we expect
2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
629f7fcc11 dbusmock/fprintd: Reset the current action on release
So it happens in the real daemon
2020-11-04 21:06:13 +01:00
Marco Trevisan (Treviño)
5a703baa20 verify: Fail if we try to verify a non-enrolled finger
Since we list the fingers available fail early in case it's not found
2020-11-04 21:06:10 +01:00
Marco Trevisan (Treviño)
6641cb6da8 tests/fprintd-utils: Verify that we can match all the enrolled fingers 2020-11-04 21:04:21 +01:00
Marco Trevisan (Treviño)
870b48637a tests/fprintd-utils: Verify errors if the device is already claimed 2020-11-04 21:04:21 +01:00
Marco Trevisan (Treviño)
4b0cde81fd tests/fprintd-utils: Add utility function to stop the utility process
This avoids addCleanup ordering errors and also errors when we may try to
print an invalid stdout pipe (like when we have processed it all), as python
might fail with something like:

 ======================================================================
 ERROR: test_fprintd_multiple_verify_fails (__main__.TestFprintdUtilsVerify)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "~/GNOME/fprintd/tests/test_fprintd_utils.py", line 102, in <lambda>
     self.addCleanup(lambda: print(process.stdout.read()))
   File "/usr/lib/python3.8/codecs.py", line 321, in decode
     data = self.buffer + input
 TypeError: can't concat NoneType to bytes
2020-11-04 21:04:21 +01:00
Marco Trevisan (Treviño)
59b3d2af8d tests/fprintd-utils: Call addCleanup actions in reverse order
unittest addCleanup calls are called in reverse order, so we need to reverse
the order of the calls as well, otherwise we won't correctly terminate the
subprocess children
2020-11-04 21:04:21 +01:00