Skip to content

Commit

Permalink
fix: use albators identifier in disable protection test
Browse files Browse the repository at this point in the history
  • Loading branch information
CahidArda committed Jun 13, 2024
1 parent afb7250 commit 9ce8768
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/deny-list/interation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("should reject in deny list", async () => {

beforeEach(async () => {
await redis.flushdb()
await redis.sadd(allDenyListsKey, "foo");
await redis.sadd(allDenyListsKey, "foo", "albatros");
});

test("should not check deny list when enableProtection: false", async () => {
Expand All @@ -35,7 +35,7 @@ describe("should reject in deny list", async () => {
denyListThreshold: 8
});

const result = await ratelimit.limit("foo")
const result = await ratelimit.limit("albatros")
expect(result.success).toBeTrue()

const [status, statusTTL, allSize, ipListsize] = await Promise.all([
Expand All @@ -48,7 +48,7 @@ describe("should reject in deny list", async () => {
// no status flag
expect(status).toBe(null)
expect(statusTTL).toBe(-2)
expect(allSize).toBe(1) // foo
expect(allSize).toBe(2) // foo + albatros
expect(ipListsize).toBe(0)
})

Expand All @@ -68,7 +68,7 @@ describe("should reject in deny list", async () => {
expect(status).toBe("valid")

Check failure on line 68 in src/deny-list/interation.test.ts

View workflow job for this annotation

GitHub Actions / Tests

error: expect(received).toBe(expected)

Expected: "valid" Received: null at /home/runner/work/ratelimit-js/ratelimit-js/src/deny-list/interation.test.ts:68:20
expect(statusTTL).toBeGreaterThan(1000)
expect(allSize).toBeGreaterThan(0)
expect(ipListsize).toBe(allSize-1) // foo
expect(ipListsize).toBe(allSize-2) // foo + albatros
})

test("should not create ip denylist when enableProtection: true but flag is disabled", async () => {
Expand All @@ -87,7 +87,7 @@ describe("should reject in deny list", async () => {
// no status flag
expect(status).toBe("disabled")
expect(statusTTL).toBe(-1)
expect(allSize).toBe(1) // foo
expect(allSize).toBe(2) // foo + albatros
expect(ipListsize).toBe(0)
})

Expand All @@ -107,7 +107,7 @@ describe("should reject in deny list", async () => {
expect(status).toBe("valid")
expect(statusTTL).toBeGreaterThan(1000)
expect(allSize).toBeGreaterThan(0)
expect(ipListsize).toBe(allSize-1) // foo
expect(ipListsize).toBe(allSize-2) // foo + albatros

// DISABLE: called from UI
await disableIpDenyList(redis, prefix);
Expand All @@ -126,7 +126,7 @@ describe("should reject in deny list", async () => {
// status flag exists and has ttl
expect(newStatus).toBe("disabled")
expect(newStatusTTL).toBe(-1)
expect(newAllSize).toBe(1) // foo
expect(newAllSize).toBe(2) // foo + albatros
expect(newIpListsize).toBe(0)
})

Expand Down

0 comments on commit 9ce8768

Please sign in to comment.