added extra checks in SectionAcknowledgmentTest

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2022-05-13 13:49:10 +10:00
parent b9901bcd47
commit 2e98a26f03
1 changed files with 6 additions and 2 deletions

View File

@ -15,6 +15,7 @@ package org.eclipse.jetty.http3.qpack;
import java.nio.ByteBuffer;
import org.eclipse.jetty.http3.qpack.QpackException.SessionException;
import org.eclipse.jetty.http3.qpack.internal.instruction.SectionAcknowledgmentInstruction;
import org.eclipse.jetty.util.BufferUtil;
import org.junit.jupiter.api.BeforeEach;
@ -25,6 +26,8 @@ import static org.eclipse.jetty.http3.qpack.QpackTestUtil.toBuffer;
import static org.eclipse.jetty.http3.qpack.QpackTestUtil.toMetaData;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
@ -68,12 +71,13 @@ public class SectionAcknowledgmentTest
{
// Encode a header with only a value contained in the static table.
ByteBuffer buffer = encode(_encoder, 0, toMetaData("GET", "/", "http"));
System.err.println(BufferUtil.toDetailString(buffer));
assertThat(BufferUtil.remaining(buffer), greaterThan(0L));
// Parsing a section ack instruction on the encoder when we are not expecting it should result in QPACK_DECODER_STREAM_ERROR.
SectionAcknowledgmentInstruction instruction = new SectionAcknowledgmentInstruction(0);
ByteBuffer instructionBuffer = toBuffer(instruction);
QpackException error = assertThrows(QpackException.class, () -> _encoder.parseInstructions(instructionBuffer));
SessionException error = assertThrows(SessionException.class, () -> _encoder.parseInstructions(instructionBuffer));
assertThat(error.getErrorCode(), equalTo(QpackException.QPACK_ENCODER_STREAM_ERROR));
assertThat(error.getMessage(), containsString("No StreamInfo for 0"));
}
}