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 <AndreKurait@gmail.com>
This commit is contained in:
Andre Kurait authored and GitHub committed 2026-10-25 13:53:56 -04:00
1 parent 74b626870f
commit 97de815256
1 file changed
+5 -2
@@ -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();