From a30c45629e9d152c6dceab944fafb13ee2fa045d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 4 Dec 2020 21:22:19 +0100 Subject: [PATCH] tests/pam: Ensure that we fail in case the user has no prints enrolled This is both in case in we start the authentication and in the absurd but (hey, testing!) situation in which prints gets deleted in between the device claiming and the verification start. To handle this second scenario we need to instruct fprintd mock to raise an error on some special command --- tests/pam/test_pam_fprintd.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) mode change 100755 => 100644 tests/pam/test_pam_fprintd.py diff --git a/tests/pam/test_pam_fprintd.py b/tests/pam/test_pam_fprintd.py old mode 100755 new mode 100644 index 7d036a8..4398608 --- a/tests/pam/test_pam_fprintd.py +++ b/tests/pam/test_pam_fprintd.py @@ -139,6 +139,28 @@ class TestPamFprintd(dbusmock.DBusTestCase): self.assertRegex(res.info[0], r'Swipe your left little finger across the fingerprint reader') self.assertEqual(len(res.errors), 0) + def test_pam_fprintd_no_fingers(self): + self.setup_device() + self.device_mock.SetEnrolledFingers('toto', dbus.Array(set([]), signature='s')) + script = [ + ( 'verify-match', True, 1 ) + ] + self.device_mock.SetVerifyScript(script) + + tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rv=PAM_AUTHINFO_UNAVAIL) + res = pypamtest.run_pamtest("toto", "fprintd-pam-test", [tc], [ 'unused' ]) + + def test_pam_fprintd_no_fingers_while_verifying(self): + self.setup_device() + script = [ + ( 'MOCK: no-prints', True, 1), + ( 'verify-match', True, 1 ) + ] + self.device_mock.SetVerifyScript(script) + + tc = pypamtest.TestCase(pypamtest.PAMTEST_AUTHENTICATE, expected_rv=PAM_USER_UNKNOWN) + res = pypamtest.run_pamtest("toto", "fprintd-pam-test", [tc], [ 'unused' ]) + def test_pam_fprintd_dual_reader_auth(self): device_path = self.obj_fprintd_mock.AddDevice('FDO Sandpaper Reader', 3, 'press') sandpaper_device_mock = self.dbus_con.get_object('net.reactivated.Fprint', device_path)