Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f2bc7b73 authored by Martin Brabham's avatar Martin Brabham
Browse files

SM: Add JustWorks cert tests

Add some classic JustWorks use cases as cert tests.

Bug: 145638034
Test: ./cert/run_cert_facade_only.sh
Change-Id: I56a1ba5fb42a97e8b87e5f8d87722a93bba0f08f
parent 11f37fb4
Loading
Loading
Loading
Loading
+36 −10
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ class SimpleSecurityTest(GdFacadeOnlyBaseTestClass):
            data=acl)
        self.cert_device.hci.SendAclData(acl_msg)

    def test_dut_connects(self):
    def pair_justworks(self, cert_iocap_reply, expected_ui_event):
        # Cert event registration
        self.register_for_event(hci_packets.EventCode.LINK_KEY_REQUEST)
        self.register_for_event(hci_packets.EventCode.IO_CAPABILITY_REQUEST)
@@ -174,13 +174,7 @@ class SimpleSecurityTest(GdFacadeOnlyBaseTestClass):
                lambda event: logging.debug(event.event) or hci_packets.EventCode.IO_CAPABILITY_REQUEST in event.event
            )

            self.enqueue_hci_command(
                hci_packets.IoCapabilityRequestReplyBuilder(
                    dut_address.decode('utf8'),
                    hci_packets.IoCapability.DISPLAY_YES_NO,
                    hci_packets.OobDataPresent.NOT_PRESENT,
                    hci_packets.AuthenticationRequirements.
                    DEDICATED_BONDING_MITM_PROTECTION), True)
            self.enqueue_hci_command(cert_iocap_reply, True)

            cert_hci_event_asserts.assert_event_occurs(
                lambda event: logging.debug(event.event) or hci_packets.EventCode.USER_CONFIRMATION_REQUEST in event.event
@@ -193,8 +187,7 @@ class SimpleSecurityTest(GdFacadeOnlyBaseTestClass):
            ui_id = -1

            def get_unique_id(event):
                if (event.message_type ==
                        security_facade.UiMsgType.DISPLAY_YES_NO_WITH_VALUE):
                if (event.message_type == expected_ui_event):
                    nonlocal ui_id
                    ui_id = event.unique_id
                    return True
@@ -212,3 +205,36 @@ class SimpleSecurityTest(GdFacadeOnlyBaseTestClass):
            dut_bond_asserts.assert_event_occurs(
                lambda bond_event: bond_event.message_type == security_facade.BondMsgType.DEVICE_BONDED
            )

    def test_display_only(self):
        dut_address = self.device_under_test.hci_controller.GetMacAddress(
            empty_proto.Empty()).address
        self.pair_justworks(
            hci_packets.IoCapabilityRequestReplyBuilder(
                dut_address.decode('utf8'),
                hci_packets.IoCapability.DISPLAY_ONLY,
                hci_packets.OobDataPresent.NOT_PRESENT, hci_packets.
                AuthenticationRequirements.DEDICATED_BONDING_MITM_PROTECTION),
            security_facade.UiMsgType.DISPLAY_YES_NO_WITH_VALUE)

    def test_no_input_no_output(self):
        dut_address = self.device_under_test.hci_controller.GetMacAddress(
            empty_proto.Empty()).address
        self.pair_justworks(
            hci_packets.IoCapabilityRequestReplyBuilder(
                dut_address.decode('utf8'),
                hci_packets.IoCapability.NO_INPUT_NO_OUTPUT,
                hci_packets.OobDataPresent.NOT_PRESENT, hci_packets.
                AuthenticationRequirements.DEDICATED_BONDING_MITM_PROTECTION),
            security_facade.UiMsgType.DISPLAY_YES_NO)

    def test_display_yes_no(self):
        dut_address = self.device_under_test.hci_controller.GetMacAddress(
            empty_proto.Empty()).address
        self.pair_justworks(
            hci_packets.IoCapabilityRequestReplyBuilder(
                dut_address.decode('utf8'),
                hci_packets.IoCapability.DISPLAY_YES_NO,
                hci_packets.OobDataPresent.NOT_PRESENT, hci_packets.
                AuthenticationRequirements.DEDICATED_BONDING_MITM_PROTECTION),
            security_facade.UiMsgType.DISPLAY_YES_NO_WITH_VALUE)