Commit graph

692 commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
3df730faeb tests/fprintd: Make possible to store duplicated prints for an user
Since we so far we had no duplicated-check for prints in fprintd an user
may have enrolled the same print for multiple accounts or even for
different fingers, so we need to simulate this case.

Given that fprintd may not allow to enroll duplicated prints soon, it's
better to just copy the storage value so that we simulate a duplicated
enrollment in the past.
2021-01-26 20:52:29 +01:00
Marco Trevisan (Treviño)
f2514f43f6 tests/fprintd: Return more data about the enrolled prints
It may be useful to be able to associate them to their user
2021-01-26 20:52:29 +01:00
Marco Trevisan (Treviño)
8ef255a3bd tests/fprintd: Add option to claim device for user on enroll_image 2021-01-26 20:52:29 +01:00
Marco Trevisan (Treviño)
15b41aa7c2 tests/fprintd: Add function and tests to enroll multiple users fingers/images
Allow to enroll multiple data in a single shot so that we don't have to
do it for each user, and add a test that uses it to match each possible
combination.
2021-01-26 20:52:29 +01:00
Marco Trevisan (Treviño)
bec42959ad tests/fprintd: Add an utility function to easily check for match/no-match 2021-01-26 20:52:29 +01:00
Marco Trevisan (Treviño)
5e00b01cf1 tests/fprintd: Ensure that the selected finger is emitted as expected 2021-01-26 19:41:53 +01:00
Marco Trevisan (Treviño)
b3bf4ac1a3 tests/fprintd: Unset the values we monitor for results on wait_for_result
We need to ensure those assume the value we want after waiting
2021-01-26 19:41:48 +01:00
Marco Trevisan (Treviño)
4aa70fb6c6 tests/fprintd: Reimplement the tests relying on specific image driver features
Some tests were delaying VerifyStop by not reporting the finger status
in the image driver, we can do the same using sleeps in the virtual
device driver, so let's reimplement such calls
2021-01-26 16:56:31 +01:00
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)
157bcf0ff5 device: Check if the device is open if we didn't fail in claiming it
When claiming a device for delete operation we'd not get an error in
case we can claim it but it's not already claimed, so in such case we
should explicitly check that the device has been opened.
2021-01-25 19:15:09 +01:00
Marco Trevisan (Treviño)
d7431c9654 ci: Do not use verbose logging for tests, just rely on artifacts
Only print errors if any
2021-01-25 19:15:09 +01:00
Marco Trevisan (Treviño)
2348876ba0 ci: Enable Virtual Device (with storage or not) tests 2021-01-25 19:15:05 +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)
f87cb27163 device: Fix debug statement string ordering and be more consistent
We were inverting the values in the `Authorization granted` message, so
be consistent in the ordering we show the message.
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)
32b70c0edc device: Add an unique function to check if we can stop the current action 2021-01-25 18:18:13 +01:00
Marco Trevisan (Treviño)
ff798edc51 device: Move duplicated code for stopping a stoppable action into a function
We can handle this in a generic way for all the cancellable cases.
2021-01-22 22:06:07 +01:00
Marco Trevisan (Treviño)
56436fb8b1 device: Always use stoppable_action_completed to terminate actions
Avoid having repeated code for doing the same, nothing changes as before
we were doing the same only in case we had not a cancellable set.
2021-01-22 22:06:01 +01:00
Marco Trevisan (Treviño)
dbf01399ad device: Throw an error if we failed to delete a device storage print
Although this error is not fatal as the local print reference has been
properly removed.
2021-01-22 15:19:21 +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)
e0a643f3b9 device: Return more specific error if we failed cleaning up the storage 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)
76c6e9e030 device: Return errors on deletion of prints from storage 2021-01-22 15:17:57 +01:00
Marco Trevisan (Treviño)
5dde80c136 device: Expose an error if we are not able to remove a print from storage
This is case we should notify, as in such case the print will still
usable.
2021-01-22 15:17:57 +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
Marco Trevisan (Treviño)
30eaaf2def device: Take advantage of the DBus skeleton properties caching
The device DBus skeleton interface already implements caching for the
properties and can smartly handle their update sending (batched) dbus
events on changes.

Even if the default properties are only read only and we don't care, we
are going to introduce properties that will change values, and so having
the skeleton to handle this for us is quite convenient.

Given that we don't really need to override those properties, we can
just set them at start and leave the skeleton cache to handle the rest.

In case we'd ever need to override them, however the skeleton also
provides a way to override all the properties and to get a reference of
the number of properties it defines, ensuring to keep the order they are
defined.
This would allow us to get back the parent's properties IDs and to use
this to implement ours properties getters/setters using the parent one
as fallback.
2021-01-22 14:10:04 +00:00
Benjamin Berg
657f58fd64 pam: Handle sigint by using a signalfd
It makes sense to allow interrupting fingerprint authentication, but PAM
does not provide a way to define an interruptable operation.

We can work around this somewhat though by at least reacting to SIGINT
in an interactive terminal. Obviously, we shouldn't override the signal
handler, because that would be too intrusive. But creating a signalfd is
easy enough and doesn't affect the rest of the process state as much.
2021-01-22 13:23:36 +00:00
Benjamin Berg
584933aad7 pam_fprintd: Fix a few issues found by static analysis
Just dead stores and an ignored return value that we really do not care
about.
2021-01-22 13:16:19 +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
00fbf19079 device: Prefer older prints when garbage collecting
This makes garbage collection a bit more predictable overall. Note that
we'll first delete prints that we do not know the age of.

If we cannot sort them by age, then randomize the order so that we don't
end up deleting in the order that the device returned the prints.
2021-01-20 23:25:52 +01:00