Fix fprintd AlreadyInUse error by respecting done flag
VerifyStart was called unconditionally on retry/no-match statuses, ignoring the done parameter from fprintd's VerifyStatus signal. When done=False the verify session is still active, causing AlreadyInUse errors. Now only restarts verification when done=True.
This commit is contained in:
parent
c759919367
commit
b8e060b850
@ -143,7 +143,8 @@ class FingerprintListener:
|
|||||||
return
|
return
|
||||||
|
|
||||||
if status in _RETRY_STATUSES:
|
if status in _RETRY_STATUSES:
|
||||||
# Retry silently — finger wasn't read properly
|
# Retry — finger wasn't read properly
|
||||||
|
if done:
|
||||||
self._device_proxy.VerifyStart("(s)", "any")
|
self._device_proxy.VerifyStart("(s)", "any")
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -151,5 +152,6 @@ class FingerprintListener:
|
|||||||
if self._on_failure:
|
if self._on_failure:
|
||||||
self._on_failure()
|
self._on_failure()
|
||||||
# Restart verification for another attempt
|
# Restart verification for another attempt
|
||||||
|
if done:
|
||||||
self._device_proxy.VerifyStart("(s)", "any")
|
self._device_proxy.VerifyStart("(s)", "any")
|
||||||
return
|
return
|
||||||
|
|||||||
@ -90,7 +90,22 @@ class TestFingerprintSignalHandling:
|
|||||||
|
|
||||||
on_success.assert_called_once()
|
on_success.assert_called_once()
|
||||||
|
|
||||||
def test_verify_no_match_calls_on_failure_and_retries(self):
|
def test_verify_no_match_calls_on_failure_and_retries_when_done(self):
|
||||||
|
listener = FingerprintListener.__new__(FingerprintListener)
|
||||||
|
listener._device_proxy = MagicMock()
|
||||||
|
listener._running = True
|
||||||
|
on_success = MagicMock()
|
||||||
|
on_failure = MagicMock()
|
||||||
|
listener._on_success = on_success
|
||||||
|
listener._on_failure = on_failure
|
||||||
|
|
||||||
|
listener._on_verify_status("verify-no-match", True)
|
||||||
|
|
||||||
|
on_failure.assert_called_once()
|
||||||
|
# Should restart verification when done=True
|
||||||
|
listener._device_proxy.VerifyStart.assert_called_once_with("(s)", "any")
|
||||||
|
|
||||||
|
def test_verify_no_match_calls_on_failure_without_restart_when_not_done(self):
|
||||||
listener = FingerprintListener.__new__(FingerprintListener)
|
listener = FingerprintListener.__new__(FingerprintListener)
|
||||||
listener._device_proxy = MagicMock()
|
listener._device_proxy = MagicMock()
|
||||||
listener._running = True
|
listener._running = True
|
||||||
@ -102,10 +117,10 @@ class TestFingerprintSignalHandling:
|
|||||||
listener._on_verify_status("verify-no-match", False)
|
listener._on_verify_status("verify-no-match", False)
|
||||||
|
|
||||||
on_failure.assert_called_once()
|
on_failure.assert_called_once()
|
||||||
# Should restart verification for retry
|
# Should NOT restart verification when done=False (still in progress)
|
||||||
listener._device_proxy.VerifyStart.assert_called_once_with("(s)", "any")
|
listener._device_proxy.VerifyStart.assert_not_called()
|
||||||
|
|
||||||
def test_verify_swipe_too_short_retries_without_failure(self):
|
def test_verify_swipe_too_short_retries_when_done(self):
|
||||||
listener = FingerprintListener.__new__(FingerprintListener)
|
listener = FingerprintListener.__new__(FingerprintListener)
|
||||||
listener._device_proxy = MagicMock()
|
listener._device_proxy = MagicMock()
|
||||||
listener._running = True
|
listener._running = True
|
||||||
@ -119,3 +134,19 @@ class TestFingerprintSignalHandling:
|
|||||||
on_success.assert_not_called()
|
on_success.assert_not_called()
|
||||||
on_failure.assert_not_called()
|
on_failure.assert_not_called()
|
||||||
listener._device_proxy.VerifyStart.assert_called_once_with("(s)", "any")
|
listener._device_proxy.VerifyStart.assert_called_once_with("(s)", "any")
|
||||||
|
|
||||||
|
def test_retry_status_does_not_restart_when_not_done(self):
|
||||||
|
listener = FingerprintListener.__new__(FingerprintListener)
|
||||||
|
listener._device_proxy = MagicMock()
|
||||||
|
listener._running = True
|
||||||
|
on_success = MagicMock()
|
||||||
|
on_failure = MagicMock()
|
||||||
|
listener._on_success = on_success
|
||||||
|
listener._on_failure = on_failure
|
||||||
|
|
||||||
|
listener._on_verify_status("verify-swipe-too-short", False)
|
||||||
|
|
||||||
|
on_success.assert_not_called()
|
||||||
|
on_failure.assert_not_called()
|
||||||
|
# Should NOT restart — verification still in progress
|
||||||
|
listener._device_proxy.VerifyStart.assert_not_called()
|
||||||
|
|||||||
@ -74,8 +74,23 @@ class TestFingerprintAuthFlow:
|
|||||||
listener._on_verify_status("verify-match", False)
|
listener._on_verify_status("verify-match", False)
|
||||||
assert len(unlock_called) == 1
|
assert len(unlock_called) == 1
|
||||||
|
|
||||||
def test_fingerprint_no_match_retries(self):
|
def test_fingerprint_no_match_retries_when_done(self):
|
||||||
"""verify-no-match should retry verification."""
|
"""verify-no-match with done=True should call on_failure and restart verification."""
|
||||||
|
from moonlock.fingerprint import FingerprintListener
|
||||||
|
|
||||||
|
listener = FingerprintListener.__new__(FingerprintListener)
|
||||||
|
listener._device_proxy = MagicMock()
|
||||||
|
listener._running = True
|
||||||
|
listener._on_success = MagicMock()
|
||||||
|
listener._on_failure = MagicMock()
|
||||||
|
|
||||||
|
listener._on_verify_status("verify-no-match", True)
|
||||||
|
|
||||||
|
listener._on_failure.assert_called_once()
|
||||||
|
listener._device_proxy.VerifyStart.assert_called_once()
|
||||||
|
|
||||||
|
def test_fingerprint_no_match_no_restart_when_not_done(self):
|
||||||
|
"""verify-no-match with done=False should call on_failure but not restart."""
|
||||||
from moonlock.fingerprint import FingerprintListener
|
from moonlock.fingerprint import FingerprintListener
|
||||||
|
|
||||||
listener = FingerprintListener.__new__(FingerprintListener)
|
listener = FingerprintListener.__new__(FingerprintListener)
|
||||||
@ -87,7 +102,7 @@ class TestFingerprintAuthFlow:
|
|||||||
listener._on_verify_status("verify-no-match", False)
|
listener._on_verify_status("verify-no-match", False)
|
||||||
|
|
||||||
listener._on_failure.assert_called_once()
|
listener._on_failure.assert_called_once()
|
||||||
listener._device_proxy.VerifyStart.assert_called_once()
|
listener._device_proxy.VerifyStart.assert_not_called()
|
||||||
|
|
||||||
def test_fingerprint_and_password_independent(self):
|
def test_fingerprint_and_password_independent(self):
|
||||||
"""Both auth methods should work independently."""
|
"""Both auth methods should work independently."""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user