Commit graph

81 commits

Author SHA1 Message Date
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
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)
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)
b2cae5cccf tests/fprintd: Check that identification with multiple images works 2020-11-06 11:06:25 +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
Benjamin Berg
6dc699ae6f tests: Fix test not failing on error
An assertion that is raised within a callback will not be swallowed by
the C code that called the function. To ensure that errors will be
noticable, pass the result back to the surrounding scope and check it
there.
2020-10-02 17:54:20 +02:00
Benjamin Berg
e075d37590 tests: Check that a verify operation can be immediately restarted
This excercises the path where we early-report a result and the
VerifyStop call must wait for the operation to complete intenernally.

Note that this test cannot fail right now due to the FpImageDevice
internal code still trying to hide the deactivation delay internally.

See libfprint!174
2020-10-01 12:19:35 +00:00
Marco Trevisan (Treviño)
714f499ab6 tests: Double the timeouts when testing with address sanitizer 2020-04-01 13:58:08 +00:00
Marco Trevisan (Treviño)
d72c802415 tests/fprintd: Ensure that the daemon doesn't crash or abort
An application terminating because of a signal like SIGSEGV, SIGABRT and
friends, will exit with a signal number that is 128 + $SIGNAL_NUMBER, so
let's ensure that the daemon has not been terminated because of a such error

This makes even more sense with address sanitizer builds, as the daemon
would exit with abort.
2020-04-01 13:58:08 +00:00
Marco Trevisan (Treviño)
90298134a2 tests/fprintd: Add checks for delete enrolled fingers permissions
The test doesn't need any assertion because we're calling DeleteEnrolledFingers
and in case it fails a net.reactivated.Fprint.Error.PermissionDenied error
would be thrown, and thus an exception would be raised at python level, making
the test to fail.
2020-03-27 20:45:59 +01:00
Bastien Nocera
8ff4360750 tests: Add test for STATE_DIRECTORY being multiple paths 2020-03-27 17:05:13 +01:00
Bastien Nocera
6a1fffae82 tests/fprintd: Fix claim_from_other_client_is_released_when_vanished on CI
test_claim_from_other_client_is_released_when_vanished would fail on
the CI but work on a local system because we wouldn't want long enough
for the "vanished" code path to be taken into account. Add a small
timeout to make sure it works on the CI as well.
2020-03-27 16:57:16 +01:00
Bastien Nocera
47bd3f7fbb tests/fprintd: Fix test_enroll_invalid_storage_dir test
enroll_image() was always waiting for enroll-completed rather than for
what the caller expected as the result.

======================================================================
FAIL: test_enroll_invalid_storage_dir (__main__.FPrintdVirtualDeviceClaimedTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/hadess/Projects/jhbuild/fprintd/tests/fprintd.py", line 661, in test_enroll_invalid_storage_dir
    self.enroll_image('whorl', expected_result='enroll-failed')
  File "/home/hadess/Projects/jhbuild/fprintd/tests/fprintd.py", line 384, in enroll_image
    self.wait_for_result('enroll-completed')
  File "/home/hadess/Projects/jhbuild/fprintd/tests/fprintd.py", line 373, in wait_for_result
    self.assertEqual(self._last_result, expected)
AssertionError: 'enroll-failed' != 'enroll-completed'
- enroll-failed
+ enroll-completed
2020-03-27 16:26:28 +01:00
Marco Trevisan (Treviño)
eccd790df7 tests/fprintd: Add missing implementation of list_tests
Use unittest_inspector that we provide for meson tests inspection as well
2020-03-27 02:01:14 +01:00
Timothy Gu
4a3ae5ccaf
tests/fprintd: Allow tests to run even when virtual device is not available
The test file calls self.daemon_start() in order to start fprintd and
locate the virtual image device that's needed for the test to run.
However, since the virtual image driver is not available on all
libfprint installations, the test should be skipped if the driver is not
available.

The skipping mechanism used to work, by checking if self.device is None.
This is based on the assumption that self.device would be set to None in
cases where the driver is not available. However, even in the past
self.device is only set to None in the tearDown method and not in setUp,
so presumably in edge cases it didn't entirely work.

However, since 0fb4f3b021 which
consistently removes the self.device attribute rather than setting it to
None, the "self.device is None" check no longer works. In particular,
the following error message is shown:

    test_manager_get_default_device (__main__.FPrintdManagerTests) ...
    Did not find virtual device! Probably libfprint was build without
    the corresponding driver!
    ERROR

After this patch, the following is shown:

    test_manager_get_default_device (__main__.FPrintdManagerTests) ...
    Did not find virtual device! Probably libfprint was build without
    the corresponding driver!
    skipped 'Need virtual_image device to run the test'

We fix this bug by consistently setting self.device to None, in both the
setUp method before daemon_start gets called, and in tearDown. We also
make the same change to self.manager for consistency.

The issue was not caught on CI, as the CI configuration always installs
a libfprint version that has the virtual_image device explicitly enabled
in the preparation phase.
2020-03-23 12:22:20 -04:00
Marco Trevisan (Treviño)
08339a0648 tests/fprintd: Skip some tests in CI depending on permissions 2020-03-17 17:14:35 +01:00
Marco Trevisan (Treviño)
3dd10b4b37 tests/fprind: Check that device is released when Caller operation is done
Add support to run fprintd-utils to test fprint daemon, and ensure that a
device is released and its operation cancelled once a caller goes away.

Related to https://gitlab.freedesktop.org/libfprint/fprintd/issues/37
2020-03-17 17:14:35 +01:00
Marco Trevisan (Treviño)
bee2e154b1 tests/fprintd: Ensure that other clients can't interfere with claimer 2020-03-17 17:14:35 +01:00
Marco Trevisan (Treviño)
27f0b64d03 tests/fprintd: Add tests for verification through finger id 2020-03-17 17:14:35 +01:00
Marco Trevisan (Treviño)
04829ed39f tests/fprintd: Check that we can't mix Enroll and Verify operations 2020-03-17 17:14:35 +01:00
Marco Trevisan (Treviño)
756a80a63e tests/fprintd: Ensure we throw NoActionInProgress on *Stop() 2020-03-17 17:14:35 +01:00
Marco Trevisan (Treviño)
b2cdc1ed1e tests/fprint: Check current API user permissions 2020-03-17 17:10:17 +01:00
Marco Trevisan (Treviño)
ab47e03f05 tests/fprintd: Ensure device open is correctly handled 2020-03-17 17:10:17 +01:00
Marco Trevisan (Treviño)
f92801a15c tests/fprintd: Ensure that verify fails on storage read failure 2020-03-17 17:10:17 +01:00
Marco Trevisan (Treviño)
086ceb98ab tests/fprintd: Ensure enroll fails on storage save failure 2020-03-17 17:10:17 +01:00
Marco Trevisan (Treviño)
8bdbc7e2b0 tests/fprintd: Ensure that we can't verify without enrolled fingers 2020-03-17 17:10:17 +01:00
Marco Trevisan (Treviño)
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