+ whitelist not listed test
+
diff --git a/test/rateLimiter.test.ts b/test/rateLimiter.test.ts
index fbe17974..0dda16f5 100644
--- a/test/rateLimiter.test.ts
+++ b/test/rateLimiter.test.ts
@@ -63,4 +63,43 @@ describe('[nuxt-security] Rate Limiter', async () => {
expect(res6.status).toBe(200)
expect(res6.statusText).toBe('OK')
})
+
+ it ('should return 200 OK after multiple requests for a route with localhost ip whitelisted', async () => {
+ const res1 = await fetch('/whitelistBase')
+ await fetch('/whitelistBase')
+ await fetch('/whitelistBase')
+ await fetch('/whitelistBase')
+ const res5 = await fetch('/whitelistBase')
+
+ expect(res1).toBeDefined()
+ expect(res1).toBeTruthy()
+ expect(res5.status).toBe(200)
+ expect(res5.statusText).toBe('OK')
+ })
+
+ it ('should return 429 when limit reached with an empty whitelist array', async () => {
+ const res1 = await fetch('/whitelistEmpty')
+ await fetch('/whitelistEmpty')
+ await fetch('/whitelistEmpty')
+ await fetch('/whitelistEmpty')
+ const res5 = await fetch('/whitelistEmpty')
+
+ expect(res1).toBeDefined()
+ expect(res1).toBeTruthy()
+ expect(res5.status).toBe(429)
+ expect(res5.statusText).toBe('Too Many Requests')
+ })
+
+ it ('should return 429 when limit reached as localhost ip is not whitelisted', async () => {
+ const res1 = await fetch('/whitelistNotListed')
+ await fetch('/whitelistNotListed')
+ await fetch('/whitelistNotListed')
+ await fetch('/whitelistNotListed')
+ const res5 = await fetch('/whitelistNotListed')
+
+ expect(res1).toBeDefined()
+ expect(res1).toBeTruthy()
+ expect(res5.status).toBe(429)
+ expect(res5.statusText).toBe('Too Many Requests')
+ })
})