Skip to content

Commit

Permalink
Add a test for server RST flood protection
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Oct 12, 2023
1 parent d04371e commit 28da3ef
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/test/java/io/vertx/core/http/Http2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -1047,4 +1047,29 @@ public void testConnectionCloseEvictsConnectionFromThePoolBeforeStreamsAreClosed
}));
await();
}

@Test
public void testRstFloodProtection() throws Exception {
server.requestHandler(req -> {
});
startServer(testAddress);
int num = HttpServerOptions.DEFAULT_HTTP2_RST_FLOOD_MAX_RST_FRAME_PER_WINDOW + 1;
for (int i = 0;i < num;i++) {
int val = i;
client.request(requestOptions, onSuccess(req -> {
if (val == 0) {
req
.connection()
.goAwayHandler(ga -> {
assertEquals(11, ga.getErrorCode()); // Enhance your calm
testComplete();
});
}
req.end().onComplete(onSuccess(v -> {
req.reset();
}));
}));
}
await();
}
}

0 comments on commit 28da3ef

Please sign in to comment.