fix issues with failing tests (I'm just gonna fucking assume directx isn't installed on the github actions machines). Added MUCH better RBAC support and control Fixed an issue when you have over a million clients RBAC would be slow asf Add settings page with some basic settings and configs you can change.
30 lines
1022 B
TypeScript
30 lines
1022 B
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { getConfig } from "./config";
|
|
import { isRateLimited, recordFailedAttempt, recordSuccessfulAttempt } from "./rateLimit";
|
|
|
|
describe("rateLimit", () => {
|
|
test("locks out after repeated failures", () => {
|
|
const maxAttempts = Math.max(1, Number(getConfig().security.loginMaxAttempts) || 5);
|
|
const ip = `10.0.0.${Date.now()}`;
|
|
for (let i = 0; i < maxAttempts; i += 1) {
|
|
recordFailedAttempt(ip);
|
|
}
|
|
|
|
const result = isRateLimited(ip);
|
|
expect(result.limited).toBe(true);
|
|
expect(result.retryAfter).toBeGreaterThan(0);
|
|
});
|
|
|
|
test("successful attempt clears lock state", () => {
|
|
const maxAttempts = Math.max(1, Number(getConfig().security.loginMaxAttempts) || 5);
|
|
const ip = `10.0.1.${Date.now()}`;
|
|
for (let i = 0; i < maxAttempts; i += 1) {
|
|
recordFailedAttempt(ip);
|
|
}
|
|
expect(isRateLimited(ip).limited).toBe(true);
|
|
|
|
recordSuccessfulAttempt(ip);
|
|
expect(isRateLimited(ip).limited).toBe(false);
|
|
});
|
|
});
|