From bee2e154b143b19c972b9ba7f921567e37f2e285 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 11 Feb 2020 05:07:33 +0100 Subject: [PATCH] tests/fprintd: Ensure that other clients can't interfere with claimer --- tests/fprintd.py | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/fprintd.py b/tests/fprintd.py index 7f36426..e82d29f 100755 --- a/tests/fprintd.py +++ b/tests/fprintd.py @@ -293,6 +293,22 @@ class FPrintdTest(dbusmock.DBusTestCase): con.sendall(encoded_img) + def call_device_method_from_other_client(self, method, args=[]): + try: + return subprocess.check_output([ + 'gdbus', + 'call', + '--system', + '--dest', + self.device.get_name(), + '--object-path', + self.device.get_object_path(), + '--method', + '{}.{}'.format(self.device.get_interface_name(), method), + ] + args, stderr=subprocess.STDOUT, timeout=5) + except subprocess.CalledProcessError as e: + raise GLib.GError(e.output) + class FPrintdVirtualDeviceBaseTest(FPrintdTest): @@ -547,6 +563,11 @@ class FPrintdVirtualDeviceTest(FPrintdVirtualDeviceBaseTest): with self.assertFprintError('Internal'): self.device.Claim('(s)', 'testuser') + def test_claim_from_other_client_is_released_when_vanished(self): + self.call_device_method_from_other_client('Claim', ['testuser']) + self.device.Claim('(s)', 'testuser') + self.device.Release() + class FPrintdVirtualDeviceClaimedTest(FPrintdVirtualDeviceBaseTest): @@ -821,6 +842,26 @@ class FPrintdVirtualDeviceClaimedTest(FPrintdVirtualDeviceBaseTest): with self.assertFprintError('PermissionDenied'): self.device.DeleteEnrolledFingers2() + def test_delete_enrolled_fingers_from_other_client(self): + with self.assertFprintError('AlreadyInUse'): + self.call_device_method_from_other_client('DeleteEnrolledFingers', ['testuser']) + + def test_release_from_other_client(self): + with self.assertFprintError('AlreadyInUse'): + self.call_device_method_from_other_client('Release') + + def test_enroll_start_from_other_client(self): + with self.assertFprintError('AlreadyInUse'): + self.call_device_method_from_other_client('EnrollStart', ['left-index-finger']) + + def test_verify_start_from_other_client(self): + with self.assertFprintError('AlreadyInUse'): + self.call_device_method_from_other_client('VerifyStart', ['any']) + + def test_verify_start_finger_from_other_client(self): + with self.assertFprintError('AlreadyInUse'): + self.call_device_method_from_other_client('VerifyStart', ['left-thumb']) + class FPrintdVirtualDeviceEnrollTests(FPrintdVirtualDeviceBaseTest): @@ -898,6 +939,10 @@ class FPrintdVirtualDeviceEnrollTests(FPrintdVirtualDeviceBaseTest): with self.assertFprintError('AlreadyInUse'): self.device.VerifyStop() + def test_enroll_stop_from_other_client(self): + with self.assertFprintError('AlreadyInUse'): + self.call_device_method_from_other_client('EnrollStop') + class FPrintdVirtualDeviceVerificationTests(FPrintdVirtualDeviceBaseTest): @@ -981,6 +1026,10 @@ class FPrintdVirtualDeviceVerificationTests(FPrintdVirtualDeviceBaseTest): with self.assertFprintError('AlreadyInUse'): self.device.EnrollStop() + def test_verify_stop_from_other_client(self): + with self.assertFprintError('AlreadyInUse'): + self.call_device_method_from_other_client('VerifyStop') + class FPrintdVirtualDeviceIdentificationTests(FPrintdVirtualDeviceVerificationTests): '''This class will just repeat the tests of FPrintdVirtualDeviceVerificationTests