Issue #2722 - Improve configurability for SETTINGS frames.
Added one more test. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
1f785eed28
commit
467bbbe1f9
|
@ -184,7 +184,7 @@ public class SettingsGenerateParseTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGenerateParseTooManySettingsInOneFrame()
|
public void testGenerateParseTooManyDifferentSettingsInOneFrame()
|
||||||
{
|
{
|
||||||
SettingsGenerator generator = new SettingsGenerator(new HeaderGenerator());
|
SettingsGenerator generator = new SettingsGenerator(new HeaderGenerator());
|
||||||
|
|
||||||
|
@ -217,6 +217,47 @@ public class SettingsGenerateParseTest
|
||||||
Assert.assertEquals(ErrorCode.ENHANCE_YOUR_CALM_ERROR.code, errorRef.get());
|
Assert.assertEquals(ErrorCode.ENHANCE_YOUR_CALM_ERROR.code, errorRef.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGenerateParseTooManySameSettingsInOneFrame() throws Exception
|
||||||
|
{
|
||||||
|
int keyValueLength = 6;
|
||||||
|
int pairs = Frame.DEFAULT_MAX_LENGTH / keyValueLength;
|
||||||
|
int maxSettingsKeys = pairs / 2;
|
||||||
|
|
||||||
|
AtomicInteger errorRef = new AtomicInteger();
|
||||||
|
Parser parser = new Parser(byteBufferPool, new Parser.Listener.Adapter(), 4096, 8192);
|
||||||
|
parser.setMaxSettingsKeys(maxSettingsKeys);
|
||||||
|
parser.setMaxFrameLength(Frame.DEFAULT_MAX_LENGTH);
|
||||||
|
parser.init(listener -> new Parser.Listener.Wrapper(listener)
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onConnectionFailure(int error, String reason)
|
||||||
|
{
|
||||||
|
errorRef.set(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
int length = pairs * keyValueLength;
|
||||||
|
ByteBuffer buffer = ByteBuffer.allocate(1 + 9 + length);
|
||||||
|
buffer.putInt(length);
|
||||||
|
buffer.put((byte)FrameType.SETTINGS.getType());
|
||||||
|
buffer.put((byte)0); // Flags.
|
||||||
|
buffer.putInt(0); // Stream ID.
|
||||||
|
// Add the same setting over and over again.
|
||||||
|
for (int i = 0; i < pairs; ++i)
|
||||||
|
{
|
||||||
|
buffer.putShort((short)SettingsFrame.MAX_CONCURRENT_STREAMS);
|
||||||
|
buffer.putInt(i);
|
||||||
|
}
|
||||||
|
// Only 3 bytes for the length, skip the first.
|
||||||
|
buffer.flip().position(1);
|
||||||
|
|
||||||
|
while (buffer.hasRemaining())
|
||||||
|
parser.parse(buffer);
|
||||||
|
|
||||||
|
Assert.assertEquals(ErrorCode.ENHANCE_YOUR_CALM_ERROR.code, errorRef.get());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGenerateParseTooManySettingsInMultipleFrames()
|
public void testGenerateParseTooManySettingsInMultipleFrames()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue