device: Do not set the device in verification state if we've errored

During VerifyStart we may return early if there are no enrolled prints.
In such case we don't require the verification to be stopped if we're
using identification, but in the verification case we may leave the
device into the verification state.

So ensure we only set the device current state only when we're about to
start it.

Add tests ensuring those cases
This commit is contained in:
Marco Trevisan (Treviño)
2021-03-02 17:07:40 +01:00
parent 6d21128b89
commit 8da1b5e7f5
2 changed files with 20 additions and 2 deletions

View File

@ -1780,6 +1780,25 @@ class FPrintdVirtualDeviceClaimedTest(FPrintdVirtualDeviceBaseTest):
with self.assertFprintError('NoEnrolledPrints'):
self.device.VerifyStart('(s)', 'right-thumb')
def test_verify_finger_not_enrolled_stops_verification(self):
self.enroll_image('whorl', finger='left-thumb')
with self.assertFprintError('NoEnrolledPrints'):
self.device.VerifyStart('(s)', 'right-thumb')
with self.assertFprintError('NoActionInProgress'):
self.device.VerifyStop()
def test_identify_finger_not_enrolled(self):
with self.assertFprintError('NoEnrolledPrints'):
self.device.VerifyStart('(s)', 'any')
def test_identify_finger_not_enrolled_stops_verification(self):
with self.assertFprintError('NoEnrolledPrints'):
self.device.VerifyStart('(s)', 'any')
with self.assertFprintError('NoActionInProgress'):
self.device.VerifyStop()
def test_unallowed_enroll_start(self):
self._polkitd_obj.SetAllowed([''])