use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class HpackDecoderTest method responsePseudoHeaderInRequest.
@Test
public void responsePseudoHeaderInRequest() throws Exception {
final ByteBuf in = Unpooled.buffer(200);
try {
HpackEncoder hpackEncoder = new HpackEncoder(true);
Http2Headers toEncode = new DefaultHttp2Headers();
toEncode.add(":method", "GET");
toEncode.add(":status", "200");
hpackEncoder.encodeHeaders(1, in, toEncode, NEVER_SENSITIVE);
final Http2Headers decoded = new DefaultHttp2Headers();
assertThrows(Http2Exception.StreamException.class, new Executable() {
@Override
public void execute() throws Throwable {
hpackDecoder.decode(1, in, decoded, true);
}
});
} finally {
in.release();
}
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class HpackDecoderTest method testAccountForHeaderOverhead.
@Test
public void testAccountForHeaderOverhead() throws Exception {
final ByteBuf in = Unpooled.buffer(100);
try {
String headerName = "12345";
String headerValue = "56789";
long headerSize = headerName.length() + headerValue.length();
hpackDecoder.setMaxHeaderListSize(headerSize);
HpackEncoder hpackEncoder = new HpackEncoder(true);
Http2Headers toEncode = new DefaultHttp2Headers();
toEncode.add(headerName, headerValue);
hpackEncoder.encodeHeaders(1, in, toEncode, NEVER_SENSITIVE);
final Http2Headers decoded = new DefaultHttp2Headers();
// SETTINGS_MAX_HEADER_LIST_SIZE is big enough for the header to fit...
assertThat(hpackDecoder.getMaxHeaderListSize(), is(greaterThanOrEqualTo(headerSize)));
// ... but decode should fail because we add some overhead for each header entry
assertThrows(Http2Exception.HeaderListSizeException.class, new Executable() {
@Override
public void execute() throws Throwable {
hpackDecoder.decode(1, in, decoded, true);
}
});
} finally {
in.release();
}
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class HpackDecoderTest method testSetTableSizeOverLimitFails.
@Test
public void testSetTableSizeOverLimitFails() throws Http2Exception {
byte[] input = { (byte) 0x3F, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x0E };
final ByteBuf in = Unpooled.wrappedBuffer(input);
try {
// based on the input above ... 1 less than is above.
hpackDecoder.setMaxHeaderTableSize(4026531870L - 1);
assertThrows(Http2Exception.class, new Executable() {
@Override
public void execute() throws Throwable {
hpackDecoder.decode(0, in, mockHeaders, true);
}
});
} finally {
in.release();
}
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class HpackDecoderTest method pseudoHeaderAfterRegularHeader.
@Test
public void pseudoHeaderAfterRegularHeader() throws Exception {
final ByteBuf in = Unpooled.buffer(200);
try {
HpackEncoder hpackEncoder = new HpackEncoder(true);
Http2Headers toEncode = new InOrderHttp2Headers();
toEncode.add("test", "1");
toEncode.add(":method", "GET");
hpackEncoder.encodeHeaders(1, in, toEncode, NEVER_SENSITIVE);
final Http2Headers decoded = new DefaultHttp2Headers();
assertThrows(Http2Exception.StreamException.class, new Executable() {
@Override
public void execute() throws Throwable {
hpackDecoder.decode(1, in, decoded, true);
}
});
} finally {
in.release();
}
}
use of org.junit.jupiter.api.function.Executable in project netty by netty.
the class HpackDecoderTest method testIncompleteHeaderFieldRepresentation.
@Test
public void testIncompleteHeaderFieldRepresentation() throws Http2Exception {
// Incomplete Literal Header Field with Incremental Indexing
byte[] input = { (byte) 0x40 };
final ByteBuf in = Unpooled.wrappedBuffer(input);
try {
assertThrows(Http2Exception.class, new Executable() {
@Override
public void execute() throws Throwable {
hpackDecoder.decode(0, in, mockHeaders, true);
}
});
} finally {
in.release();
}
}
Aggregations