OSDN Git Service

CertSecurity: Add accept_oob_pairing function
authorMartin Brabham <optedoblivion@google.com>
Sat, 14 Nov 2020 00:06:35 +0000 (16:06 -0800)
committerMartin Brabham <optedoblivion@google.com>
Mon, 16 Nov 2020 18:22:15 +0000 (10:22 -0800)
Bug: 162984360
Tag: #gd-refactor
Test: cert/run --host SecurityTest
Change-Id: I27e6b6ceedd0fc001f25222db6f0f3189c006e3c

gd/security/cert/cert_security.py

index 1912aa1..c565652 100644 (file)
@@ -263,6 +263,24 @@ class CertSecurity(PySecurity):
             logging.info("Cert: Waiting for SIMPLE_PAIRING_COMPLETE")
             assertThat(self._hci_event_stream).emits(HciMatchers.SimplePairingComplete())
 
+    def accept_oob_pairing(self, dut_address):
+        logging.info("Cert: Waiting for IO_CAPABILITY_RESPONSE")
+        assertThat(self._hci_event_stream).emits(HciMatchers.IoCapabilityResponse())
+        logging.info("Cert: Waiting for IO_CAPABILITY_REQUEST")
+        assertThat(self._hci_event_stream).emits(HciMatchers.IoCapabilityRequest())
+        logging.info("Cert: Sending IO_CAPABILITY_REQUEST_REPLY")
+        oob_data_present = hci_packets.OobDataPresent.NOT_PRESENT
+        self._enqueue_hci_command(
+            hci_packets.IoCapabilityRequestReplyBuilder(
+                dut_address.decode('utf8'), self._io_caps, oob_data_present, self._auth_reqs), True)
+        assertThat(self._hci_event_stream).emits(HciMatchers.CommandComplete())
+        logging.info("Cert: Waiting for SIMPLE_PAIRING_COMPLETE")
+        ssp_complete_capture = HciCaptures.SimplePairingCompleteCapture()
+        assertThat(self._hci_event_stream).emits(ssp_complete_capture)
+        ssp_complete = ssp_complete_capture.get()
+        logging.info(ssp_complete.GetStatus())
+        assertThat(ssp_complete.GetStatus()).isEqualTo(hci_packets.ErrorCode.SUCCESS)
+
     def on_user_input(self, dut_address, reply_boolean, expected_ui_event):
         """
             Cert doesn't need the test to respond to the ui event