feat(db,schemas): add migration 004, runtime throttle profile, and v1.1 Zod schemas

This commit is contained in:
tyuXX 2026-11-27 22:15:50 +00:00
parent d7c3e11d7e
commit afc2d6358a
30 changed files with 792 additions and 118 deletions

View file

@ -3,7 +3,7 @@ import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import * as OTPAuth from 'otpauth';
import { afterEach, describe, expect, it } from 'vitest';
import { afterEach, describe, expect, it, vi } from 'vitest';
import WebSocket from 'ws';
import { createGCoordinatorServer, type GCoordinatorInstance } from '../src/server/app.js';
import { MockSshServer } from './helpers/mock-ssh-server.js';
@ -82,6 +82,8 @@ async function setupServerWithSsh() {
return { status: res.status, data: data as Record<string, unknown> };
};
vi.useFakeTimers({ toFake: ['Date'] });
vi.setSystemTime(Date.now() - 35_000);
const bootInfo = await api('/api/auth/bootstrap');
const secretBase32 = String(bootInfo.data.secretBase32);
const totp = new OTPAuth.TOTP({
@ -102,7 +104,11 @@ async function setupServerWithSsh() {
initialSafeMode: false,
},
});
vi.useRealTimers();
csrfToken = String(boot.data.csrfToken);
expect(
(await api('/api/auth/step-up', { method: 'POST', body: { code: totp.generate() } })).status,
).toBe(200);
await api('/api/vault/init', { method: 'POST', body: {} });
const keyRes = await api('/api/vault/generate-ed25519', {