feat(db,schemas): add migration 004, runtime throttle profile, and v1.1 Zod schemas
This commit is contained in:
parent
d7c3e11d7e
commit
afc2d6358a
30 changed files with 792 additions and 118 deletions
|
|
@ -2,7 +2,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 { createGCoordinatorServer, type GCoordinatorInstance } from '../src/server/app.js';
|
||||
import { MockSshServer } from './helpers/mock-ssh-server.js';
|
||||
|
||||
|
|
@ -104,6 +104,8 @@ describe('Always-on background collectors & write-only Vault lock', () => {
|
|||
}
|
||||
});
|
||||
|
||||
vi.useFakeTimers({ toFake: ['Date'] });
|
||||
vi.setSystemTime(Date.now() - 65_000);
|
||||
let api = createApiClient(activeServer);
|
||||
const bootInfo = await api.call('/api/auth/bootstrap');
|
||||
const secretBase32 = String(bootInfo.data.secretBase32);
|
||||
|
|
@ -130,6 +132,12 @@ describe('Always-on background collectors & write-only Vault lock', () => {
|
|||
const recoveryCodes = bootRes.data.recoveryCodes as string[];
|
||||
expect(recoveryCodes.length).toBeGreaterThan(0);
|
||||
|
||||
vi.setSystemTime(Date.now() + 31_000);
|
||||
expect(
|
||||
(await api.call('/api/auth/step-up', { method: 'POST', body: { code: totp.generate() } })).status,
|
||||
).toBe(200);
|
||||
vi.useRealTimers();
|
||||
|
||||
// Explicitly initialize & add SSH key, register server, then lock Vault
|
||||
expect((await api.call('/api/vault/init', { method: 'POST', body: {} })).status).toBe(201);
|
||||
const keyRes = await api.call('/api/vault/generate-ed25519', {
|
||||
|
|
@ -230,6 +238,11 @@ describe('Always-on background collectors & write-only Vault lock', () => {
|
|||
expect((await api.call('/api/servers/srv-1/inspect')).status).toBe(200);
|
||||
expect((await api.call('/api/servers/srv-1/sftp/list?path=/')).status).toBe(200);
|
||||
|
||||
// Step up so the Vault write-lock guard (423 VAULT_LOCKED) is reached
|
||||
expect(
|
||||
(await api.call('/api/auth/step-up', { method: 'POST', body: { code: totp.generate() } })).status,
|
||||
).toBe(200);
|
||||
|
||||
// Modifications and secret reveals must still be blocked with 423 VAULT_LOCKED while locked
|
||||
const addBlocked = await api.call('/api/vault/credentials', {
|
||||
method: 'POST',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue