From 37e6939fa93273f6ff20adfc9bf2bc2965269d35 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Sat, 31 Jul 2021 10:13:21 +0200 Subject: [PATCH] tests: Verify PAM VerifyStop/disconnect behaviour For verify-match, the PAM module should simply drop off the bus. In other cases it should correctly run VerifyStop and Release the device. Verify this for verify-match and verify-no-match. --- tests/pam/test_pam_fprintd.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/pam/test_pam_fprintd.py b/tests/pam/test_pam_fprintd.py index be66818..99f8259 100644 --- a/tests/pam/test_pam_fprintd.py +++ b/tests/pam/test_pam_fprintd.py @@ -143,6 +143,12 @@ 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) + # Check that we can stop verification and release the device. i.e. + # this has not been done by PAM already (the real fprintd would notice + # the disconnect, the mock service does not). + self.device_mock.VerifyStop() + self.device_mock.Release() + def test_pam_fprintd_no_fingers(self): self.setup_device() self.device_mock.SetEnrolledFingers('toto', dbus.Array(set([]), signature='s')) @@ -199,6 +205,13 @@ class TestPamFprintd(dbusmock.DBusTestCase): self.assertRegex(res.errors[0], r'Failed to match fingerprint') self.assertRegex(res.errors[0], r'Failed to match fingerprint') + # Check that we can cannot stop verification or release the device. i.e. + # PAM should have correctly done this after verification was done. + with self.assertRaisesRegex(dbus.exceptions.DBusException, r'net\.reactivated\.Fprint\.Error\.NoActionInProgress'): + self.device_mock.VerifyStop() + with self.assertRaisesRegex(dbus.exceptions.DBusException, r'net\.reactivated\.Fprint\.Error\.ClaimDevice'): + self.device_mock.Release() + def test_pam_fprintd_blocks_unexpected_auth2(self): self.setup_device() script = [