Skip to content

Commit

Permalink
added extra checks in SectionAcknowledgmentTest
Browse files Browse the repository at this point in the history
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
  • Loading branch information
lachlan-roberts committed May 13, 2022
1 parent b9901bc commit 2e98a26
Showing 1 changed file with 6 additions and 2 deletions.
Expand Up @@ -15,6 +15,7 @@

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;
Expand All @@ -25,6 +26,8 @@
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;

Expand Down Expand Up @@ -68,12 +71,13 @@ public void testSectionAcknowledgmentForZeroRequiredInsertCountOnEncoder() throw
{
// 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"));
}
}

0 comments on commit 2e98a26

Please sign in to comment.