Loading system/gd/cert/py_security.py +9 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ class PySecurity(Closable): self._bond_event_stream = EventStream(self._device.security.FetchBondEvents(empty_proto.Empty())) self._enforce_security_policy_stream = EventStream( self._device.security.FetchEnforceSecurityPolicyEvents(empty_proto.Empty())) self._disconnect_event_stream = EventStream(self._device.security.FetchDisconnectEvents(empty_proto.Empty())) def create_bond(self, address, type): """ Loading Loading @@ -180,6 +181,13 @@ class PySecurity(Closable): assertThat(self._enforce_security_policy_stream).emits( lambda event: event.result == expected_enforce_security_event or logging.info(event.result)) def wait_for_disconnect_event(self): """ The Address is expected to be returned """ logging.info("DUT: Waiting for Disconnect Event") assertThat(self._disconnect_event_stream).emits(lambda event: 1 == 1) def enforce_security_policy(self, address, type, policy): """ Call to enforce classic security policy Loading @@ -193,3 +201,4 @@ class PySecurity(Closable): safeClose(self._ui_event_stream) safeClose(self._bond_event_stream) safeClose(self._enforce_security_policy_stream) safeClose(self._disconnect_event_stream) system/gd/security/cert/cert_security.py +6 −0 Original line number Diff line number Diff line Loading @@ -206,5 +206,11 @@ class CertSecurity(PySecurity): """ pass def wait_for_disconnect_event(self): """ Cert side needs to pass """ pass def close(self): safeClose(self._hci) system/gd/security/cert/security_test.py +2 −1 Original line number Diff line number Diff line Loading @@ -274,4 +274,5 @@ class SecurityTest(GdBaseTestClass): self.cert_security.remove_bond(self.dut_security.get_address(), common.BluetoothAddressTypeEnum.PUBLIC_DEVICE_ADDRESS) time.sleep(.1) self.dut_security.wait_for_disconnect_event() self.cert_security.wait_for_disconnect_event() system/gd/security/facade.cc +18 −0 Original line number Diff line number Diff line Loading @@ -304,6 +304,23 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public return ::grpc::Status::OK; } ::grpc::Status FetchDisconnectEvents( ::grpc::ServerContext* context, const ::google::protobuf::Empty* request, ::grpc::ServerWriter<DisconnectMsg>* writer) override { security_module_->GetFacadeConfigurationApi()->SetDisconnectCallback( common::Bind(&SecurityModuleFacadeService::DisconnectEventOccurred, common::Unretained(this))); return disconnect_events_.RunLoop(context, writer); } void DisconnectEventOccurred(bluetooth::hci::AddressWithType peer) { LOG_INFO("%s", peer.ToString().c_str()); DisconnectMsg msg; msg.mutable_address()->mutable_address()->set_address(peer.ToString()); msg.mutable_address()->set_type(static_cast<facade::BluetoothAddressTypeEnum>(peer.GetAddressType())); disconnect_events_.OnIncomingEvent(msg); } void DisplayPairingPrompt(const bluetooth::hci::AddressWithType& peer, std::string name) { LOG_INFO("%s", peer.ToString().c_str()); UiMsg display_yes_no; Loading Loading @@ -412,6 +429,7 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public ::bluetooth::grpc::GrpcEventQueue<SecurityHelperMsg> helper_events_{"Events that don't fit any other category"}; ::bluetooth::grpc::GrpcEventQueue<EnforceSecurityPolicyMsg> enforce_security_policy_events_{ "Enforce Security Policy Events"}; ::bluetooth::grpc::GrpcEventQueue<DisconnectMsg> disconnect_events_{"Disconnect events"}; uint32_t unique_id{1}; std::map<uint32_t, common::OnceCallback<void(bool)>> user_yes_no_callbacks_; std::map<uint32_t, common::OnceCallback<void(uint32_t)>> user_passkey_callbacks_; Loading system/gd/security/facade.proto +5 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ service SecurityModuleFacade { rpc FetchHelperEvents(google.protobuf.Empty) returns (stream SecurityHelperMsg) {} rpc EnforceSecurityPolicy(SecurityPolicyMessage) returns (google.protobuf.Empty) {} rpc FetchEnforceSecurityPolicyEvents(google.protobuf.Empty) returns (stream EnforceSecurityPolicyMsg) {} rpc FetchDisconnectEvents(google.protobuf.Empty) returns (stream DisconnectMsg) {} } message OobDataMessage { Loading Loading @@ -155,3 +156,7 @@ message SecurityPolicyMessage { message EnforceSecurityPolicyMsg { bool result = 1; } message DisconnectMsg { facade.BluetoothAddressWithType address = 1; } Loading
system/gd/cert/py_security.py +9 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ class PySecurity(Closable): self._bond_event_stream = EventStream(self._device.security.FetchBondEvents(empty_proto.Empty())) self._enforce_security_policy_stream = EventStream( self._device.security.FetchEnforceSecurityPolicyEvents(empty_proto.Empty())) self._disconnect_event_stream = EventStream(self._device.security.FetchDisconnectEvents(empty_proto.Empty())) def create_bond(self, address, type): """ Loading Loading @@ -180,6 +181,13 @@ class PySecurity(Closable): assertThat(self._enforce_security_policy_stream).emits( lambda event: event.result == expected_enforce_security_event or logging.info(event.result)) def wait_for_disconnect_event(self): """ The Address is expected to be returned """ logging.info("DUT: Waiting for Disconnect Event") assertThat(self._disconnect_event_stream).emits(lambda event: 1 == 1) def enforce_security_policy(self, address, type, policy): """ Call to enforce classic security policy Loading @@ -193,3 +201,4 @@ class PySecurity(Closable): safeClose(self._ui_event_stream) safeClose(self._bond_event_stream) safeClose(self._enforce_security_policy_stream) safeClose(self._disconnect_event_stream)
system/gd/security/cert/cert_security.py +6 −0 Original line number Diff line number Diff line Loading @@ -206,5 +206,11 @@ class CertSecurity(PySecurity): """ pass def wait_for_disconnect_event(self): """ Cert side needs to pass """ pass def close(self): safeClose(self._hci)
system/gd/security/cert/security_test.py +2 −1 Original line number Diff line number Diff line Loading @@ -274,4 +274,5 @@ class SecurityTest(GdBaseTestClass): self.cert_security.remove_bond(self.dut_security.get_address(), common.BluetoothAddressTypeEnum.PUBLIC_DEVICE_ADDRESS) time.sleep(.1) self.dut_security.wait_for_disconnect_event() self.cert_security.wait_for_disconnect_event()
system/gd/security/facade.cc +18 −0 Original line number Diff line number Diff line Loading @@ -304,6 +304,23 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public return ::grpc::Status::OK; } ::grpc::Status FetchDisconnectEvents( ::grpc::ServerContext* context, const ::google::protobuf::Empty* request, ::grpc::ServerWriter<DisconnectMsg>* writer) override { security_module_->GetFacadeConfigurationApi()->SetDisconnectCallback( common::Bind(&SecurityModuleFacadeService::DisconnectEventOccurred, common::Unretained(this))); return disconnect_events_.RunLoop(context, writer); } void DisconnectEventOccurred(bluetooth::hci::AddressWithType peer) { LOG_INFO("%s", peer.ToString().c_str()); DisconnectMsg msg; msg.mutable_address()->mutable_address()->set_address(peer.ToString()); msg.mutable_address()->set_type(static_cast<facade::BluetoothAddressTypeEnum>(peer.GetAddressType())); disconnect_events_.OnIncomingEvent(msg); } void DisplayPairingPrompt(const bluetooth::hci::AddressWithType& peer, std::string name) { LOG_INFO("%s", peer.ToString().c_str()); UiMsg display_yes_no; Loading Loading @@ -412,6 +429,7 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public ::bluetooth::grpc::GrpcEventQueue<SecurityHelperMsg> helper_events_{"Events that don't fit any other category"}; ::bluetooth::grpc::GrpcEventQueue<EnforceSecurityPolicyMsg> enforce_security_policy_events_{ "Enforce Security Policy Events"}; ::bluetooth::grpc::GrpcEventQueue<DisconnectMsg> disconnect_events_{"Disconnect events"}; uint32_t unique_id{1}; std::map<uint32_t, common::OnceCallback<void(bool)>> user_yes_no_callbacks_; std::map<uint32_t, common::OnceCallback<void(uint32_t)>> user_passkey_callbacks_; Loading
system/gd/security/facade.proto +5 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ service SecurityModuleFacade { rpc FetchHelperEvents(google.protobuf.Empty) returns (stream SecurityHelperMsg) {} rpc EnforceSecurityPolicy(SecurityPolicyMessage) returns (google.protobuf.Empty) {} rpc FetchEnforceSecurityPolicyEvents(google.protobuf.Empty) returns (stream EnforceSecurityPolicyMsg) {} rpc FetchDisconnectEvents(google.protobuf.Empty) returns (stream DisconnectMsg) {} } message OobDataMessage { Loading Loading @@ -155,3 +156,7 @@ message SecurityPolicyMessage { message EnforceSecurityPolicyMsg { bool result = 1; } message DisconnectMsg { facade.BluetoothAddressWithType address = 1; }