device: Do not list invalid prints as enrolled

The user may have some invalid prints saved (like the ones enrolled with
fprintd 1) in the storage, this lead to list such prints as enrolled but
they're actually not valid.

So load the prints to ensure that those are of the valid type instead of
just discovering them.

We may make just store.discover_prints to be aware of this, but this
would break some assumptions we do in tests, so better to go this way.
This commit is contained in:
Marco Trevisan (Treviño)
2021-03-02 16:17:14 +01:00
parent 8f3b48e261
commit 1511eb93ea
2 changed files with 23 additions and 11 deletions

View File

@ -1265,6 +1265,15 @@ class FPrintdVirtualDeviceTest(FPrintdVirtualDeviceBaseTest):
with self.assertFprintError('NoEnrolledPrints'):
self.device.ListEnrolledFingers('(s)', 'testuser')
def test_unclaimed_list_enrolled_fingers_ignores_invalid(self):
print_path = self.get_print_file_path('testuser', FPrint.Finger.LEFT_INDEX)
os.makedirs(os.path.dirname(print_path), exist_ok=True)
with open(print_path, mode='wb') as new_print_file:
new_print_file.write(b'I am an invalid print!')
with self.assertFprintError('NoEnrolledPrints'):
self.device.ListEnrolledFingers('(s)', 'testuser')
def test_claim_device_open_fail(self):
os.rename(self.tmpdir, self.tmpdir + '-moved')
self.addCleanup(os.rename, self.tmpdir + '-moved', self.tmpdir)