Skip to content

Commit a1ec41f

Browse files
test: add rate limiting E2E test for booking attendees endpoint
Co-Authored-By: rajiv@cal.com <sahalrajiv6900@gmail.com>
1 parent 5cd3934 commit a1ec41f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/get-attendees.e2e-spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,28 @@ describe("Bookings Endpoints 2024-08-13 get attendees", () => {
250250
});
251251
});
252252

253+
describe("Rate limiting", () => {
254+
it("should return 429 after exceeding the rate limit", async () => {
255+
const responses = [];
256+
for (let i = 0; i < 10; i++) {
257+
const response = await request(app.getHttpServer())
258+
.get(`/v2/bookings/${testSetup.bookingUid}/attendees`)
259+
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
260+
.set("Authorization", `Bearer ${testSetup.organizer.accessToken}`);
261+
responses.push(response.status);
262+
}
263+
264+
expect(responses).toContain(429);
265+
266+
const firstThrottledIndex = responses.indexOf(429);
267+
expect(firstThrottledIndex).toBeLessThanOrEqual(5);
268+
269+
for (let i = firstThrottledIndex; i < responses.length; i++) {
270+
expect(responses[i]).toBe(429);
271+
}
272+
});
273+
});
274+
253275
describe("Response format", () => {
254276
it("should return attendees with correct structure", async () => {
255277
const getAttendeesResponse = await request(app.getHttpServer())

0 commit comments

Comments
 (0)