def RestartFleetspeakGrrService(grr_id: Text) -> None: """Restarts the GRR service on the given client.""" restart_req = fs_system_pb2.RestartServiceRequest(name="GRR") fs_msg = fs_common_pb2.Message() fs_msg.message_type = "RestartService" fs_msg.destination.client_id = GRRIDToFleetspeakID(grr_id) fs_msg.destination.service_name = "system" fs_msg.data.Pack(restart_req) fleetspeak_connector.CONN.outgoing.InsertMessage(fs_msg)
def testRestartFleetspeakGrrService(self, mock_conn): fleetspeak_utils.RestartFleetspeakGrrService("C.2000000000000000") mock_conn.outgoing.InsertMessage.assert_called_once() insert_args, _ = mock_conn.outgoing.InsertMessage.call_args fs_message = insert_args[0] self.assertEqual(fs_message.message_type, "RestartService") self.assertEqual(fs_message.destination.client_id, b"\x20\x00\x00\x00\x00\x00\x00\x00") self.assertEqual(fs_message.destination.service_name, "system") restart_req = fs_system_pb2.RestartServiceRequest() fs_message.data.Unpack(restart_req) self.assertEqual(restart_req.name, "GRR")