tests/fprintd: Test enroll multiple prints with duplicates

This commit is contained in:
Marco Trevisan (Treviño)
2021-04-01 21:37:29 +02:00
parent 4e075ba491
commit 41086ac4c6

View File

@ -676,7 +676,11 @@ class FPrintdVirtualDeviceBaseTest(FPrintdVirtualImageDeviceBaseTests):
ctx.iteration(False) ctx.iteration(False)
self.assertTrue(self.finger_needed) self.assertTrue(self.finger_needed)
if expected_result == 'enroll-duplicate':
stages = 1
else:
stages = self.num_enroll_stages stages = self.num_enroll_stages
for stage in range(stages): for stage in range(stages):
self.send_image(img) self.send_image(img)
if stage < stages - 1: if stage < stages - 1:
@ -733,9 +737,12 @@ class FPrintdVirtualDeviceBaseTest(FPrintdVirtualImageDeviceBaseTests):
self.device.Claim('(s)', user) self.device.Claim('(s)', user)
for finger, p in print_map.items(): for finger, p in print_map.items():
if allow_duplicates and p in enrolled_prints: if allow_duplicates and p in enrolled_prints:
duplicates_prints_info[p] = (user, finger) prints_infos = duplicates_prints_info.get(p, [])
# FIXME: as further test we can still try enroll and expect prints_infos.append((user, finger))
# for enrollment error. duplicates_prints_info[p] = prints_infos
if self.has_identification:
self.enroll_image(p, finger=finger,
expected_result='enroll-duplicate')
continue continue
self.enroll_image(p, finger=finger) self.enroll_image(p, finger=finger)
enrolled_prints.append(p) enrolled_prints.append(p)
@ -746,7 +753,8 @@ class FPrintdVirtualDeviceBaseTest(FPrintdVirtualImageDeviceBaseTests):
# We can't just enroll duplicates prints, as fprint will check for # We can't just enroll duplicates prints, as fprint will check for
# duplicates prints, so we've to handle this manually, copying the # duplicates prints, so we've to handle this manually, copying the
# actual prints # actual prints
for print_image, print_info in duplicates_prints_info.items(): for print_image, print_infos in duplicates_prints_info.items():
for print_info in print_infos:
orig_username, orig_finger = enrolled_prints_info[print_image] orig_username, orig_finger = enrolled_prints_info[print_image]
dup_username, dup_finger = print_info dup_username, dup_finger = print_info
dup_fp_finger = FINGERS_MAP[dup_finger] dup_fp_finger = FINGERS_MAP[dup_finger]
@ -1813,6 +1821,17 @@ class FPrintdVirtualDeviceClaimedTest(FPrintdVirtualDeviceBaseTest):
self.device.Release() self.device.Release()
def test_enroll_users_duplicate_prints(self):
_enroll_map, prints_info = self.enroll_users_images(enroll_map={
'test-user1': {'left-thumb': 'whorl', 'right-thumb': 'whorl'},
'test-user2': {'left-index-finger': 'whorl'},
'test-user3': {'left-little-finger': 'tented_arch'},
}, allow_duplicates=True)
self.assertEqual(prints_info, {
'whorl': ('test-user1', 'left-thumb'),
'tented_arch': ('test-user3', 'left-little-finger'),
})
def test_verify_finger_not_enrolled(self): def test_verify_finger_not_enrolled(self):
self.enroll_image('whorl', finger='left-thumb') self.enroll_image('whorl', finger='left-thumb')
with self.assertFprintError('NoEnrolledPrints'): with self.assertFprintError('NoEnrolledPrints'):
@ -2225,6 +2244,12 @@ class FPrintdVirtualDeviceEnrollTests(FPrintdVirtualDeviceBaseTest):
def test_enroll_error_data_full(self): def test_enroll_error_data_full(self):
self.assertEnrollError(FPrint.DeviceError.DATA_FULL, 'enroll-data-full') self.assertEnrollError(FPrint.DeviceError.DATA_FULL, 'enroll-data-full')
def test_enroll_duplicate_image(self):
self.enroll_image('whorl', finger='left-thumb', start=False)
self.enroll_image('whorl', finger='right-thumb', stop=False,
expected_result='enroll-duplicate' if self.has_identification
else 'enroll-completed')
def test_enroll_start_during_enroll(self): def test_enroll_start_during_enroll(self):
with self.assertFprintError('AlreadyInUse'): with self.assertFprintError('AlreadyInUse'):
self.device.EnrollStart('(s)', 'left-thumb') self.device.EnrollStart('(s)', 'left-thumb')