mirror of
https://gitlab.com/mishakmak/pam-fprint-grosshack.git
synced 2026-04-08 20:03:34 +02:00
device: Remove local storage prints if they've been removed from device
If a print we have stored locally is not available in device anymore, we need to cleanup the local database. We do not get a proper DATA_NOT_FOUND error for most devices (indeed, at this point no device does this properly). As such, do this when we see a DATA_NOT_FOUND error and the first time that we get a verify-no-match results on a device which is capable of listing all known prints. Co-Authored-by: Marco Trevisan (Treviño) <mail@3v1n0.net>
This commit is contained in:
@ -1086,6 +1086,51 @@ class FPrintdVirtualStorageDeviceTests(FPrintdVirtualStorageDeviceBaseTest):
|
||||
prints = self.get_stored_prints()
|
||||
self.assertEqual(set(prints), set(garbage_prints))
|
||||
|
||||
def test_local_storage_cleanup_data_error(self):
|
||||
# Enroll a print and delete it
|
||||
self.enroll_print('deleted-print', finger='left-thumb')
|
||||
self.send_command('REMOVE', 'deleted-print')
|
||||
|
||||
# Note: would be thrown anyway by the storage device if we scan something
|
||||
self.send_error(FPrint.DeviceError.DATA_NOT_FOUND)
|
||||
self.device.VerifyStart('(s)', 'any')
|
||||
|
||||
self.wait_for_result('verify-no-match')
|
||||
self.device.VerifyStop()
|
||||
|
||||
# At this point, there is no print left
|
||||
with self.assertFprintError('NoEnrolledPrints'):
|
||||
self.device.ListEnrolledFingers('(s)', 'testuser')
|
||||
|
||||
def test_local_storage_cleanup_no_match(self):
|
||||
# Enroll a print and delete it
|
||||
self.enroll_print('existing-print', finger='right-index-finger')
|
||||
self.enroll_print('deleted-print', finger='left-thumb')
|
||||
self.send_command('REMOVE', 'deleted-print')
|
||||
|
||||
# We need to send a print that is known to the device
|
||||
self.send_image('other-print')
|
||||
self.device.VerifyStart('(s)', 'right-index-finger')
|
||||
|
||||
self.wait_for_result('verify-no-match')
|
||||
self.device.VerifyStop()
|
||||
|
||||
# At this point, the deleted print has disappeared
|
||||
self.assertEqual(set(self.device.ListEnrolledFingers('(s)', 'testuser')), {'right-index-finger'})
|
||||
|
||||
# Now, do the same thing, and the print will not be deleted
|
||||
self.enroll_print('deleted-print', finger='left-thumb')
|
||||
self.send_command('REMOVE', 'deleted-print')
|
||||
|
||||
self.send_image('other-print')
|
||||
self.device.VerifyStart('(s)', 'right-index-finger')
|
||||
|
||||
self.wait_for_result('verify-no-match')
|
||||
self.device.VerifyStop()
|
||||
|
||||
# At this point, the deleted print is still there
|
||||
self.assertEqual(set(self.device.ListEnrolledFingers('(s)', 'testuser')), {'right-index-finger', 'left-thumb'})
|
||||
|
||||
def test_enroll_with_one_stage_only(self):
|
||||
self._maybe_reduce_enroll_stages(stages=1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user