From 97de81525627e9c97df0aab90d30661dbbf31da2 Mon Sep 17 00:00:00 2001 From: Andre Kurait Date: Sun, 25 Oct 2026 12:53:56 -0500 Subject: [PATCH] test(iot): verify oversized packet rejection before body writes (#6527) Send only the oversized advertised packet length, then verify socket closure and the existing disconnect event assertions. Signed-off-by: Andre Kurait --- .../floci/services/iot/IotMqttBrokerServiceTest.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/test/java/io/github/hectorvent/floci/services/iot/IotMqttBrokerServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/iot/IotMqttBrokerServiceTest.java index b5b96dc15a..1175b3c3d9 100644 --- a/src/test/java/io/github/hectorvent/floci/services/iot/IotMqttBrokerServiceTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/iot/IotMqttBrokerServiceTest.java @@ -907,14 +907,17 @@ class IotMqttBrokerServiceTest { assertEquals("CLIENT_ERROR", disconnected.get(0).get("disconnectReason").asText()); } - /** A PUBLISH beyond the decoder's packet limit never reaches the publish handler, yet AWS reports the same client error. */ + /** The decoder rejects an oversized advertised length before reading the body or invoking the publish handler. */ @Test void aPacketAboveTheDecoderLimitEndsTheSessionWithAClientError() throws Exception { startBrokerRecordingPublishes(); try (Socket socket = rawConnect("undecodable")) { - rawPublish(socket, 0, "devices/d1/huge", new byte[150 * 1024]); + byte[] body = new byte[150 * 1024]; + byte[] frame = packet(0x30, body); + socket.getOutputStream().write(frame, 0, frame.length - body.length); awaitPresence("disconnected", "undecodable", 1); + assertEquals(-1, socket.getInputStream().read(), "the decoder closes without waiting for the body"); } barrier();