From fc1f7be069937130c8b21c742669aca381ae26c5 Mon Sep 17 00:00:00 2001 From: Martin Brabham Date: Tue, 17 Nov 2020 16:17:03 -0800 Subject: [PATCH] HciMatchers: enforce argument requirement If the command complete opcode is not specified then it will match ANY command complete event which can prove to be troubles some when getting a series of CommandComplete() matches. Bug: 162984360 Tag: #gd-refactor Test: cert/run --host SecurityTest Change-Id: Ia42c74c6476fd9d0763afa87ad1f61a243942e27 --- gd/cert/matchers.py | 2 +- gd/security/cert/cert_security.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/gd/cert/matchers.py b/gd/cert/matchers.py index a91297325..46a690f04 100644 --- a/gd/cert/matchers.py +++ b/gd/cert/matchers.py @@ -31,7 +31,7 @@ from bluetooth_packets_python3.l2cap_packets import LeCreditBasedConnectionRespo class HciMatchers(object): @staticmethod - def CommandComplete(opcode=None): + def CommandComplete(opcode): return lambda msg: HciMatchers._is_matching_command_complete(msg.payload, opcode) @staticmethod diff --git a/gd/security/cert/cert_security.py b/gd/security/cert/cert_security.py index ef11082e3..a91c7bbb0 100644 --- a/gd/security/cert/cert_security.py +++ b/gd/security/cert/cert_security.py @@ -265,7 +265,8 @@ class CertSecurity(PySecurity): 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()) + assertThat(self._hci_event_stream).emits( + HciMatchers.CommandComplete(hci_packets.OpCode.IO_CAPABILITY_REQUEST_REPLY)) logging.info("Cert: Waiting for SIMPLE_PAIRING_COMPLETE") ssp_complete_capture = HciCaptures.SimplePairingCompleteCapture() assertThat(self._hci_event_stream).emits(ssp_complete_capture) -- 2.11.0