Commit graph

110 commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
d2c8a383e6 tests/fprintd: Implement device removal via the 'UNPLUG' command 2021-01-26 04:38:09 +01:00
Marco Trevisan (Treviño)
9a85bfa57f tests/fprintd: Ensure the scan type can be changed and is notified 2021-01-25 19:50:46 +01:00
Marco Trevisan (Treviño)
7f2133cc79 tests/fprintd: Verify using no-identification device with 'any' finger 2021-01-25 19:50:46 +01:00
Marco Trevisan (Treviño)
8491d35eef tests/fprintd: Verify that we can enroll with one stage only 2021-01-25 19:50:46 +01:00
Marco Trevisan (Treviño)
32ae65fae6 tests/fprintd: Reduce the enroll stages when possible to avoid operations 2021-01-25 19:50:46 +01:00
Marco Trevisan (Treviño)
8799fd296a tests/fprintd: Repeat all relevant tests with the storage device
Now that FPrintdVirtualStorageDeviceBaseTest is a
FPrintdVirtualDeviceBaseTest we can implement the needed `send_*`
functions that we use in the tests in order to get easily an interface
that can be used to repeat all the tests we've already written with the
new virtual device.

To do this, we've only to create new test classes that use the
FPrintdVirtualStorageDeviceBaseTest as main base class and that
also implement the test class.
2021-01-25 19:50:40 +01:00
Marco Trevisan (Treviño)
0b80245e8a tests/fprintd: Inherit storage tests from FPrintdVirtualDeviceBaseTest
We can avoid lots of duplication
2021-01-25 18:18:40 +01:00
Marco Trevisan (Treviño)
72a2504fc4 device: Wait device to finish for a timeout before completing VerifyStop
When a device has reported the verification status the client should
call VerifyStop to stop the device, however this under the hood may lead
to a premature cancellation, causing the device not to react as expected
in case the finger is still on the sensor or in case it may return to us
some errors that we may want to handle (like the data-missing one).

So, in case we are about to stop the verification and the operation is
still in process, wait for a maximum timeout before proceed to the
cancellation.

However, while waiting, the action may be also cancelled because of a
call to Release() or because the client vanished, and in such case we
have to ensure that the current invocation is saved for being invoked by
stoppable_action_completed() when callback will return. That will also
unset it, and that's a clear indication for us that it has been already
consumed, and thus that we can just return doing nothing else.

Fixes: #100
2021-01-25 18:18:40 +01:00
Marco Trevisan (Treviño)
8d8c181f31 tests/fprintd: Check that errors happening after we got a result are ignored 2021-01-25 18:18:40 +01:00
Marco Trevisan (Treviño)
cce9551c98 tests/fprintd: Be more flexible in accepting async results with exceptions
Some tests may have different behaviors depending on the CPU load when
using parallel tests, so async results could arrive in different order.

Then we need to accept multiple results:
  - A specific exception has to happen all the times
  - One of the accepted exception has to happen all the times
  - No exception or one of the allowed exception may happen

Depending on the test, use one of the possible strategies.
2021-01-25 18:18:40 +01:00
Marco Trevisan (Treviño)
c8c543672d tests/fprintd: Make assertFprintError to accept list of errors we accept
It can be used to check if any of the error that is passed is raised
2021-01-25 18:18:40 +01:00
Marco Trevisan (Treviño)
5acf13cf51 tests/fprintd: Ensure that all the methods can be called concurrently
As per GDBus we can now get async calls (from the same client) happening
while we're still processing a previous request, so we need to ensure
that we react properly.
2021-01-25 18:18:40 +01:00
Marco Trevisan (Treviño)
f3a8adf3c8 tests/fprintd: Make possible to organize async replies per proxy and method 2021-01-25 18:18:40 +01:00
Marco Trevisan (Treviño)
c32737f4d4 tests/fprintd: Use global definitions for Fprint namespace and paths
So avoid repeating it everywhere
2021-01-25 18:18:40 +01:00
Marco Trevisan (Treviño)
804aff3c30 tests/fprintd: Use a class to compare permissions easily 2021-01-25 18:18:40 +01:00
Marco Trevisan (Treviño)
457cbd46cd device: Stop any further EnrollStop/VerifyStop request once we got one
In case we get concurrent requests on EnrollStart/EnrollStop we'd just
continue with the operation, making the first processed request to start
the process and the second to hang (in code before the introduction of
stoppable_action_stop()) or to crash (in the current code).

So in such case we should always check that we're not handling already
the request, by checking priv->current_cancel_invocation value.

Add tests to verify the race.
2021-01-25 18:18:39 +01:00
Marco Trevisan (Treviño)
0f29cfc0c7 tests/fprintd: Check the storage errors are emitted if we fail delete prints 2021-01-22 15:19:21 +01:00
Marco Trevisan (Treviño)
3fa0f232ef tests/fprintd: Ensure DeleteEnrolledFingers2 works for multiple fingers 2021-01-22 15:19:21 +01:00
Marco Trevisan (Treviño)
3c91ac9a3f tests/fprintd: Add utility functions to check if prints are stored 2021-01-22 15:19:20 +01:00
Marco Trevisan (Treviño)
3fe268f6f2 tests/fprintd: Move permissions checks to a single function 2021-01-22 15:18:39 +01:00
Marco Trevisan (Treviño)
0203c8aed8 tests: Add more tests to verify AlreadyInUse error on deletion methods 2021-01-22 15:17:57 +01:00
Marco Trevisan (Treviño)
7d87f5e664 device: Set an error if trying to delete a print that is not enrolled 2021-01-22 15:17:57 +01:00
Marco Trevisan (Treviño)
fd72c0b81b device: Support deleting a single fingerprint for user
Add a method to delete only a Fingerprint for a device, this is required
by they g-c-c UI design and at the same time it reflects the libfprint
API, where so far only a fingerprint at time can be deleted.
2021-01-22 15:17:57 +01:00
Marco Trevisan (Treviño)
1835d99265 device: Expose finger status as DBus properties
libfprint v1.90.4 introduced a new finger status API to expose to the UI
the finger status on sensor.

Add two new properties to the Device interface that represent the
possible values.

Add new tests.
2021-01-22 14:10:04 +00:00
Benjamin Berg
eadf4fced8 tests: Add test to verify deletion
This enrolls a few prints, deletes them. Then checks that all the new
prints have been deleted, but all the garbage prints still exist.
2021-01-20 23:25:52 +01:00
Benjamin Berg
27a76c9b79 tests: Add test to check order of garbage collection 2021-01-20 23:25:52 +01:00
Benjamin Berg
9301693c83 tests: Allow use of other virtual devices 2021-01-20 23:25:52 +01:00
Benjamin Berg
0e428d34ec tests: Make tests executable
This makes it easier to use them in out-of-tree tests.
2021-01-13 14:47:00 +01:00
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)
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
Marco Trevisan (Treviño)
0122d351f9 fprintd: Add tests for device properties values 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
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