mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2026-09-09 04:40:06 +00:00
tests/realtek: Cover duplicate enrollment errors
Extend the 2541:fa03 storage-error fixture to enroll the same finger twice and assert FP_DEVICE_ERROR_DATA_DUPLICATE, reusing the device session the delete test already opened rather than starting a second one. Compact redundant polling transactions while preserving the recorded protocol state changes.
This commit is contained in:
Binary file not shown.
@@ -6,9 +6,11 @@
|
|||||||
# point of this test: before the fix it read freed memory, and the GError was
|
# point of this test: before the fix it read freed memory, and the GError was
|
||||||
# freed a second time when the GTask finalized.
|
# freed a second time when the GTask finalized.
|
||||||
#
|
#
|
||||||
# No enrollment is involved, so this needs no recorded finger presses: the print
|
# The print below is a stored realtek print, serialized, whose template is
|
||||||
# below is a stored realtek print, serialized, whose template is deliberately
|
# deliberately not on the device.
|
||||||
# not on the device.
|
#
|
||||||
|
# The same session then enrolls a finger and enrolls it again, checking that the
|
||||||
|
# duplicate is reported as FP_DEVICE_ERROR_DATA_DUPLICATE rather than PROTO.
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import traceback
|
import traceback
|
||||||
@@ -62,6 +64,34 @@ else:
|
|||||||
del p
|
del p
|
||||||
print("delete attempt done")
|
print("delete attempt done")
|
||||||
|
|
||||||
|
# Storage is still empty, so enrolling the same finger twice must report the
|
||||||
|
# error class expected by fprintd.
|
||||||
|
|
||||||
|
def enroll_progress(*args):
|
||||||
|
print('enroll progress: ' + str(args))
|
||||||
|
|
||||||
|
template = FPrint.Print.new(d)
|
||||||
|
|
||||||
|
print("enrolling")
|
||||||
|
assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE
|
||||||
|
p = d.enroll_sync(template, None, enroll_progress, None)
|
||||||
|
assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE
|
||||||
|
print("enroll done")
|
||||||
|
|
||||||
|
print("enrolling duplicate")
|
||||||
|
template = FPrint.Print.new(d)
|
||||||
|
assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE
|
||||||
|
try:
|
||||||
|
d.enroll_sync(template, None, enroll_progress, None)
|
||||||
|
except GLib.Error as error:
|
||||||
|
assert error.matches(FPrint.DeviceError.quark(),
|
||||||
|
FPrint.DeviceError.DATA_DUPLICATE)
|
||||||
|
else:
|
||||||
|
raise AssertionError("Duplicate enrollment unexpectedly succeeded")
|
||||||
|
assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE
|
||||||
|
print("duplicate enrollment rejected")
|
||||||
|
|
||||||
|
d.delete_print_sync(p)
|
||||||
d.close_sync()
|
d.close_sync()
|
||||||
|
|
||||||
del d
|
del d
|
||||||
|
|||||||
Reference in New Issue
Block a user