quality / commitlint (push) Skipped
quality / changes (push) Failing after 8s
quality / openapi (push) Skipped
quality / web (push) Skipped
quality / api (push) Skipped
CD / quality (push) Failing after 9s
quality / docker-check (push) Skipped
CD / publish (push) Skipped
- genReqId (uuid) + x-request-id в каждом ответе и request_id в error envelope — корреляция ошибок между клиентом и логами - RBAC: /agents/:id/(stats|blocked-ips|blocked-ports) классифицируются как fw:stats:read (reset остаётся под fw:agents:write) - web: test-скрипт + 10 unit-тестов (filter-utils, fleet-kpis, parseClaims, nav) - typecheck-скрипты для api/shared/db; CI: тесты shared и web, typecheck всех пакетов - гигиена: .node-version (22), актуальный .dockerignore, drizzle out → ./migrations, удалены 12 лишних .gitkeep и пустой apps/api/test
87 lines
2.3 KiB
TypeScript
87 lines
2.3 KiB
TypeScript
import { describe, it, expect, afterAll } from 'vitest'
|
|
import { buildApp } from '../app.js'
|
|
import type { AppConfig } from '../config.js'
|
|
import { repos } from '@evofw/db'
|
|
|
|
const testConfig: AppConfig = {
|
|
databaseUrl: 'sqlite::memory:',
|
|
jwtSecret: 'test',
|
|
jwtTtlHours: 24,
|
|
serverPort: 8080,
|
|
staticDir: null,
|
|
logLevel: 'error',
|
|
authRequired: false,
|
|
authIssuer: 'https://auth.test',
|
|
authPortalUrl: 'http://localhost:5175',
|
|
publicBaseUrl: 'https://fw.example.com',
|
|
enrollSeed: 'test-seed',
|
|
corsOrigins: [],
|
|
authAuditIngestSecret: null,
|
|
secretKey: null,
|
|
statsRetentionDays: 30,
|
|
}
|
|
|
|
describe('settings + bumpAgentsForList', () => {
|
|
const appPromise = buildApp({ memory: true, config: testConfig })
|
|
|
|
afterAll(async () => {
|
|
const app = await appPromise
|
|
await app.close()
|
|
})
|
|
|
|
it('rejects unknown settings keys', async () => {
|
|
const app = await appPromise
|
|
await app.ready()
|
|
const res = await app.inject({
|
|
method: 'PUT',
|
|
url: '/api/v1/settings',
|
|
payload: { unknown_key: 'x' },
|
|
})
|
|
expect(res.statusCode).toBeGreaterThanOrEqual(400)
|
|
})
|
|
|
|
it('accepts show_quick_actions', async () => {
|
|
const app = await appPromise
|
|
await app.ready()
|
|
const res = await app.inject({
|
|
method: 'PUT',
|
|
url: '/api/v1/settings',
|
|
payload: { show_quick_actions: 'false' },
|
|
})
|
|
expect(res.statusCode).toBe(200)
|
|
const get = await app.inject({ method: 'GET', url: '/api/v1/settings' })
|
|
expect(get.json().show_quick_actions).toBe('false')
|
|
})
|
|
|
|
it('bumpAgentsForList no-ops when list has no rules', async () => {
|
|
const app = await appPromise
|
|
await app.ready()
|
|
const db = app.db
|
|
|
|
const agent = repos.insertAgent(db, {
|
|
id: 'ag-bump-1',
|
|
name: 'bump-test',
|
|
platform: 'linux',
|
|
tokenPrefix: 'tok',
|
|
tokenHash: 'hash-bump-1',
|
|
status: 'approved',
|
|
defaultAction: 'accept',
|
|
policyGeneration: 1,
|
|
settingsJson: '{}',
|
|
})
|
|
expect(agent?.policyGeneration).toBe(1)
|
|
|
|
const list = repos.insertIpList(db, {
|
|
id: 'list-unused',
|
|
name: 'unused',
|
|
type: 'static',
|
|
configJson: '{}',
|
|
})
|
|
expect(list).toBeTruthy()
|
|
|
|
repos.bumpAgentsForList(db, 'list-unused')
|
|
const after = repos.getAgent(db, 'ag-bump-1')
|
|
expect(after?.policyGeneration).toBe(1)
|
|
})
|
|
})
|