Skip to content

chore: expect response code for positive cases #3990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 9, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class InMemoryRateLimiterFilterFactoryIntegrationTest {

private static WebTestClient client;

final int bucketCapacity = 60;
final int bucketCapacity = 20;

@BeforeAll
static void setUpTester() {
Expand Down Expand Up @@ -67,22 +67,23 @@ void testRateLimitingWhenAllowedWithCookie() {
void testRateLimitingWhenExceeded() {
IntStream.range(0, bucketCapacity).parallel().forEach(i -> client.get()
.cookie("apimlAuthenticationToken", "validTokenValue")
.exchange());
.exchange().expectStatus().isOk());


client.get()
.cookie("apimlAuthenticationToken", "validTokenValue")
.exchange()
.expectStatus().isEqualTo(HttpStatus.TOO_MANY_REQUESTS)
.expectBody()
.jsonPath("$.messages[0].messageReason").isEqualTo("Connections limit exceeded.");;
.jsonPath("$.messages[0].messageReason").isEqualTo("Connections limit exceeded.");
}

@Test
void testRateLimiterAllowsAccessToAnotherUser() {
// the first user requires access
IntStream.range(0, bucketCapacity).parallel().forEach(i -> client.get()
.cookie("apimlAuthenticationToken", "theFirstUser")
.exchange());
.exchange().expectStatus().isOk());
//access should be denied
client.get()
.cookie("apimlAuthenticationToken", "theFirstUser")
Expand Down
Loading