Commit Graph

640 Commits

Author SHA1 Message Date
756a80a63e tests/fprintd: Ensure we throw NoActionInProgress on *Stop() 2020-03-17 17:14:35 +01:00
b861500a9f device: Throw AlreadyInUse error if stopping an enroll during verification
When starting an enroll when verification is in progress (and vice-versa) we
emit an AlreadyInUse error, however when calling VerifyStop() during an
enrollment (and vice-versa) we just return a NoActionInProgress error, which
is not the case.

So let's be consistent and change the error type.
2020-03-17 17:14:33 +01:00
154d0c0373 device: Use proper function name in debug 2020-03-17 17:10:17 +01:00
b2cdc1ed1e tests/fprint: Check current API user permissions 2020-03-17 17:10:17 +01:00
ab47e03f05 tests/fprintd: Ensure device open is correctly handled 2020-03-17 17:10:17 +01:00
f92801a15c tests/fprintd: Ensure that verify fails on storage read failure 2020-03-17 17:10:17 +01:00
086ceb98ab tests/fprintd: Ensure enroll fails on storage save failure 2020-03-17 17:10:17 +01:00
8bdbc7e2b0 tests/fprintd: Ensure that we can't verify without enrolled fingers 2020-03-17 17:10:17 +01:00
1f8bb1abd4 tests/fprintd: Ensure that devices are available on name appeared
Given we don't support adding devices after we created the manager (yet) we
must ensure that once the name appeared we have them all
2020-03-17 17:10:17 +01:00
47d55a97c4 tests/fprintd: Add tests for Manager methods 2020-03-17 17:10:17 +01:00
657b90a066 tests/fprintd: Move assertFprintError to FPrintdTest
This may be used by any class inheriting FPrintdTest, so let's move it at
lower level.
2020-03-17 17:10:17 +01:00
3821b96ca5 tests/fprintd: Only enable 'virtual_image' driver
When we run tests in a system with real devices, we may try to initialize
the real ones, while we can just ignore them all in tests.

We do it in setUp instead of setUpClass to allow tests to change this if
they need to, but just for temporary.
2020-03-17 17:10:17 +01:00
22ad9b5ae8 tests/fprintd: Check all the error types during verify/enroll
Ensure that we properly handle all the errors that a driver may return us
2020-03-17 17:10:17 +01:00
2ddc8a86a2 tests/fprind: Add verify retry tests for all the cases
The tests are repeated for both verify and identify actions
2020-03-17 17:10:17 +01:00
930cae4647 tests/fprind: Add enroll retry tests for all the cases 2020-03-17 17:10:17 +01:00
5e9624bef5 device: Fix verify-disconnected state name
Respect protocol, and use proper name
2020-03-17 17:10:17 +01:00
efac52d94f device: Fix retry enroll error names
Use proper names for enroll retry errors, fixing a copy/paste error from the
verify code.
2020-03-17 17:10:17 +01:00
af18aa35e5 tests/fprintd: Add tests to verify permissions on prints management 2020-03-17 17:10:16 +01:00
0d7a703200 tests/fprintd: Split claimed device tests to a single class
Avoid doing fo reach test the Claim/Release procedure manually if it is just
a prerequisite for the test.
2020-03-17 17:09:19 +01:00
ad19c49e2e tests/fprintd: Move tests which need a claimed device 2020-03-17 17:09:19 +01:00
a8de1003a4 tests/fprintd: Use addCleanup to always terminate daemons
Ensure that the daemons are always terminated after each test, even on
failure, so that we don't have to do hacks such as always trying to stop
them
2020-03-17 17:09:19 +01:00
cefe939141 tests/fprintd: Use addCleanup to ensure we remove the test dir 2020-03-17 17:09:19 +01:00
24cd986476 tests/fprintd: Use GTestDBus unset to undefine envs
Unset the dbus environment that may affect the dbus tests using GTestDBus
utility, instead of doing it manually.
2020-03-17 17:09:19 +01:00
06480c7994 tests/fprintd: Use a new bus for each test unit
When creating a new unit we used to get the system bus via Gio.bus_get_sync,
however this has a singleton implementation, and so would always return the
same connection, creating issues in tests when a new test suite is added
because the newly got connection would be already closed.

So, just manually create a new bus connection, also close the bus and
cleanup the test bus in dbus.
2020-03-17 17:09:19 +01:00
b2ad590891 tests/fprintd: Call the super class on setup 2020-03-17 17:09:19 +01:00
85aad7bb01 tests/fprintd: Remove usage of never-used self.client variable 2020-03-17 17:09:19 +01:00
0fb4f3b021 tests/fprintd: Cleanup the client proxies on tearDown
Ensure we nullify them when the test is done.
2020-03-17 17:09:19 +01:00
21564885ea tests/fprintd: Do the parent tearDown after we've done our stuff 2020-03-17 17:09:19 +01:00
6064e30200 tests/fprintd: Remove the force-exit timeout
Since we rely on meson now to do this, we don't need to have manual
management of the timeout
2020-03-17 17:09:19 +01:00
fd8297306c tests/fprintd: Ensure that we get an error on early release
Ensure that we get an error when releasing a device that is in process of
enrollment, verification or identification
2020-03-17 17:09:19 +01:00
e7f804e9fc device: Cancel the ongoing operation when releasing the device
If a device is currently verifying, identifying or enrolling we may want the
user to stop the operation before we actually release the device.

Otherwise we may end-up in trying to close (failing) the internal device,
while fprintd is still considering the device active, causing a dead-lock
(the device can't be released, but neither claimed again or stop the current
action).

In fact calling Claim() -> EnrollStart() -> Release(), we would fail with
the error

  net.reactivated.Fprint.Error.Internal:
  Release failed with error: The device is still busy with another
  operation, please try again later. (36)"

However, if we try to call VerifyStop, after this error, we'd fail because
for the fprintd logic, the device is not claimed anymore, but actually
closed, and we'd need to claim it again, but... That would still cause an
internal error.

To avoid this, in case Relase() is called cancel the ongoing operation,
and wait until it's done before completing the release call.
2020-03-17 17:09:19 +01:00
0e993d92e2 device: Return 'verify-no-match' on cancelled verification
We were returning a 'verify-unknown-error' while we actually know what
happened, so better to return a soft operation failure.
2020-03-17 17:09:19 +01:00
b312a5e540 device: Return 'enroll-failed' on cancelled enrollment
We were returning an 'enroll-unknown-error' while we actually know what
happened, so better to return a soft operation failure.
2020-03-17 17:09:19 +01:00
c12778ec5b tests/fprintd: Verify that each enroll stage happens
Instead of automatically replying with the 'whorl' image for every enroll
state signal with result 'enroll-stage-passed', only perform the number
of required enroll stages and ensure that we get the expected results.

This also will allow to manually perform enroll steps in other tests.
2020-03-17 17:09:19 +01:00
dbabd4d7d3 tests/fprintd: Deduplicate enrollment code 2020-03-17 15:54:14 +01:00
db1865eb3e tests/fprintd: Deduplicate result wait code 2020-03-17 15:49:40 +01:00
10a3e75937 ci: Fix unknown keys in CI
Fix:
root config contains unknown keys: container_fedora_build
2020-03-17 15:31:08 +01:00
01ea517a97 ci: Fix CI syntax error
Fix CI syntax error:
container_fedora_build: unknown keys in `extends` (.fedora@container-build)
Caused by changes in the wayland CI templates:
4a73f030d0
2020-03-17 15:29:37 +01:00
3a98ef646b ci: Re-enable stable branch
Now that libfprint v2 has landed in rawhide.
2020-02-19 13:07:27 +01:00
750a815fdf ci: Use extends to repeat libfprint builds
This syntax is just nicer and more maintainable than the YAML anchors
2020-02-18 14:08:32 +01:00
53fcf52989 ci: Factorize the similar parameters in build jobs 2020-02-18 14:06:32 +01:00
52e12459df main: Improve comments on fprint manager creation
Explain why the manager creation is async better in both in the main file
and in the manager itself
2020-02-14 16:01:01 +01:00
554df2a8d9 utils: Fix memory leak when error is ignored in list
If we get a `NoEnrolledPrints` error while list, we don't consider it an
hard error and in such case we proceed to releasing the device, but without
clearing the previously set error first.
2020-02-14 16:00:20 +01:00
681bd1ed2a device: Fix leaked matched print on identify
When starting an identify operation we allocate a gallery of prints from the
gallery, although if we match one of them we get that back in the finish
callback but with a further reference added.

So, in order to clean it up, use an auto-pointer or we'd end up in leaking
it, and the address sanitizer was catching this in our tests already:

  Indirect leak of 12020 byte(s) in 5 object(s) allocated from:
    #0 0x7fe8bc638ce6 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10dce6)
    #1 0x7fe8bc37ffd0 in g_malloc0 ../../glib/glib/gmem.c:132
    #2 0x55d100635c01 in load_from_file ../src/file_storage.c:159
    #3 0x55d100635c01 in file_storage_print_data_load ../src/file_storage.c:182
    #4 0x55d10063e950 in fprint_device_verify_start ../src/device.c:882
    #5 0x55d10064036b in dbus_glib_marshal_fprint_device_VOID__STRING_POINTER src/device-dbus-glue.h:96
    #6 0x7fe8bc50f6f5  (/usr/lib/x86_64-linux-gnu/libdbus-glib-1.so.2+0xd6f5)
2020-02-14 15:55:09 +01:00
8890732194 device: Don't leak the user on claim error while deleting prints
When using the delete method we check if the device was claimed, if this
fails because the device is already in use we return an error, but we don't
free the user.

While this could be fixed by just a further g_free call, let's just remove
remove the other manual free calls, and use an auto-pointer instead for this
function.
2020-02-14 15:55:09 +01:00
7dac81dcad device: Use g_clear_error instead of doing the same manually
We've now an utility function that can help us to free and unset an error
double pointer, so let's use it.
2020-02-14 15:55:09 +01:00
1ecae1d014 delete: Clear the error in case we ignore it
If we get a `NoEnrolledPrints` error during delete, we don't consider it an
hard error and in such case we proceed to releasing the device, but without
clearing the previously set error first.
2020-02-14 15:55:09 +01:00
ba7a45d3f8 device: Always free error in delete enrolled fingers2
During delete enrolled fingers2 call, if the check-claimed control fails, we
would return the error without freeing it.

While this could be fixed by just a further g_error_free call, let's just
remove the other manual free call, and use an auto-pointer instead for this
function.
2020-02-14 15:55:09 +01:00
49dced5566 device: Always free error in delete enrolled fingers
During delete enrolled fingers call, if the check-claimed control fails, and
we get an error different from FPRINT_ERROR_CLAIM_DEVICE, we would return
the error without freeing it.

While this could be fixed by just a further g_error_free call, let's just
remove all the manual free calls, and use an auto-pointer instead for this
function.
2020-02-14 15:55:09 +01:00
e25544a8f0 manager: Remove unused path variable 2020-02-14 15:55:09 +01:00