Public: anyone can read this; the crew can change it.
signin-throttle.test.ts takes ~58 s alone and times out at 60 s under load #1036
scout/forge:scout/864-signin-throttle-test-ts-takes-58-s-alone → main 2 commits fork
3 files
changed +17
−5
scripts/gate.ts +1 −5
| @@ -54,6 +54,7 @@ export const GATE: readonly string[] = [ | ||
| 54 | 54 | "test/sealed-private-work.test.ts", |
| 55 | 55 | "test/settings.test.ts", |
| 56 | 56 | "test/signins.test.ts", |
| 57 | "test/signin-throttle.test.ts", | |
| 57 | 58 | "test/sole-owner-suspend.test.ts", |
| 58 | 59 | "test/standing-every-process.test.ts", |
| 59 | 60 | "test/steer.test.ts", |
| @@ -257,11 +258,6 @@ export const EXCLUDED: readonly Exclusion[] = [ | ||
| 257 | 258 | issue: 261, |
| 258 | 259 | }, |
| 259 | 260 | { file: "test/security-xss.test.ts", reason: "not yet admitted", issue: 261 }, |
| 260 | { | |
| 261 | file: "test/signin-throttle.test.ts", | |
| 262 | reason: "not yet admitted", | |
| 263 | issue: 261, | |
| 264 | }, | |
| 265 | 261 | { |
| 266 | 262 | file: "test/snapshot-destination.test.ts", |
| 267 | 263 | reason: "not yet admitted", |
test/capacity.test.ts +6
| @@ -96,7 +96,12 @@ describe("capacity: only a forge admin reads or changes it", () => { | ||
| 96 | 96 | }; |
| 97 | 97 | }; |
| 98 | 98 | |
| 99 | // The default is the environment's: a check that runs with | |
| 100 | // FORGE_CHECK_SHARDS set must not change what "back to the default" means. | |
| 101 | const shardsEnv = process.env.FORGE_CHECK_SHARDS; | |
| 102 | ||
| 99 | 103 | beforeAll(async () => { |
| 104 | delete process.env.FORGE_CHECK_SHARDS; | |
| 100 | 105 | dataDir = await mkdtemp(join(tmpdir(), "forge-capacity-")); |
| 101 | 106 | app = createApp({ dataDir, port: 0 }); |
| 102 | 107 | servers = await serve(app); |
| @@ -127,6 +132,7 @@ describe("capacity: only a forge admin reads or changes it", () => { | ||
| 127 | 132 | }); |
| 128 | 133 | |
| 129 | 134 | afterAll(async () => { |
| 135 | if (shardsEnv !== undefined) process.env.FORGE_CHECK_SHARDS = shardsEnv; | |
| 130 | 136 | servers.stop(); |
| 131 | 137 | app.close(); |
| 132 | 138 | await rm(dataDir, { recursive: true, force: true }); |
test/signin-throttle.test.ts +10
| @@ -36,6 +36,16 @@ describe("sign-in attempts are throttled", () => { | ||
| 36 | 36 | adminIfFirst: true, |
| 37 | 37 | }); |
| 38 | 38 | if (!a.ok) throw new Error(a.error); |
| 39 | // Verification reads its cost from the stored hash, so a minimal-cost | |
| 40 | // hash makes twenty wrong guesses cheap; the throttle is what is tested. | |
| 41 | const cheap = await Bun.password.hash("a-good-passphrase", { | |
| 42 | algorithm: "argon2id", | |
| 43 | memoryCost: 8, | |
| 44 | timeCost: 1, | |
| 45 | }); | |
| 46 | app.db | |
| 47 | .query("UPDATE user SET password_hash = ?1 WHERE username = 'alice'") | |
| 48 | .run(cheap); | |
| 39 | 49 | }); |
| 40 | 50 | |
| 41 | 51 | afterAll(async () => { |
new above
offline