device-oauth-performance.test.mjs
sha256:700fafdd1afa490919f9515d660ca6e75456bcd5bb67513abcd8757a634c01f6
docs: record AIP-b SD-21 land (KN #308)
Human
10 days ago
| 1 | /** |
| 2 | * Phase B — device OAuth: performance tier (light). |
| 3 | * |
| 4 | * Bulk device authorization creation completes within a reasonable wall-clock |
| 5 | * budget on a temp data directory. |
| 6 | */ |
| 7 | |
| 8 | import { describe, it, afterEach } from 'node:test'; |
| 9 | import assert from 'node:assert/strict'; |
| 10 | import { createDeviceAuthorization } from '../hub/gateway/device-oauth-store.mjs'; |
| 11 | import { createTempStrongStore } from './helpers/device-oauth-harness.mjs'; |
| 12 | |
| 13 | const cleanups = []; |
| 14 | afterEach(async () => { |
| 15 | while (cleanups.length) await cleanups.pop()(); |
| 16 | }); |
| 17 | |
| 18 | describe('Phase B performance — bulk authorization create', () => { |
| 19 | it('50 createDeviceAuthorization calls complete under 5 seconds', async () => { |
| 20 | const tmp = await createTempStrongStore(); |
| 21 | cleanups.push(tmp.cleanup); |
| 22 | |
| 23 | const start = Date.now(); |
| 24 | for (let i = 0; i < 50; i++) { |
| 25 | const created = await createDeviceAuthorization({ clientId: `perf-${i}` }); |
| 26 | assert.ok(created.deviceCode); |
| 27 | assert.ok(created.userCode); |
| 28 | } |
| 29 | const elapsed = Date.now() - start; |
| 30 | assert.ok(elapsed < 5000, `50 creates took ${elapsed}ms (budget 5000ms)`); |
| 31 | }); |
| 32 | }); |
File History
1 commit
sha256:700fafdd1afa490919f9515d660ca6e75456bcd5bb67513abcd8757a634c01f6
docs: record AIP-b SD-21 land (KN #308)
Human
10 days ago