ci(temp): verify P01 test and lockfile corrections
This commit is contained in:
1 parent
d8ac96e39d
commit
90fce0629a
16 files changed
+1094
-2804
No files matched your search
@@ -5,6 +5,12 @@ on:
|
||||
paths:
|
||||
- '.gitea/workflows/datastack-ci.yml'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
p01_only:
|
||||
description: Run P01 tests, typecheck, build and Windows clean-install only
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
jobs:
|
||||
node-regression:
|
||||
@@ -38,6 +44,7 @@ jobs:
|
||||
test "$failed" -eq 0
|
||||
|
||||
python-regression:
|
||||
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.p01_only != 'true' }}
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
@@ -87,6 +94,7 @@ jobs:
|
||||
test -f .next/standalone/server.js
|
||||
|
||||
docker-image-build:
|
||||
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.p01_only != 'true' }}
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 35
|
||||
steps:
|
||||
@@ -127,12 +135,9 @@ jobs:
|
||||
shell: powershell
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
# Diagnostic only: regenerate the lock in the disposable runner checkout.
|
||||
# The tracked repository lock remains unchanged for the later bug-fix phase.
|
||||
npm install --package-lock-only --no-audit --no-fund
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Temporary lock regeneration failed' }
|
||||
# Verify the committed cross-platform lock without disposable regeneration.
|
||||
npm ci --no-audit --no-fund
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Diagnostic npm install failed' }
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Committed-lock npm ci failed' }
|
||||
npm --prefix sdk/node/datastack install --no-audit --no-fund
|
||||
if ($LASTEXITCODE -ne 0) { throw 'SDK install failed' }
|
||||
npm --prefix sdk/node/datastack run build
|
||||
|
||||
Generated
+1007
File diff suppressed because it is too large.
Load diff
@@ -85,7 +85,7 @@ describe("Phase-01 Auth, Secrets, Revocation & Proxy Hardening", () => {
|
||||
});
|
||||
|
||||
it("BUG-01 & BUG-02: fails closed in production when secrets or DB/setup are missing", async () => {
|
||||
process.env.NODE_ENV = "production";
|
||||
(process.env as Record<string, string | undefined>).NODE_ENV = "production";
|
||||
delete process.env.DATABASE_URL;
|
||||
delete process.env.DATASTACK_ADMIN_SESSION_SECRET;
|
||||
delete process.env.DATASTACK_ADMIN_SETUP_KEY;
|
||||
@@ -557,7 +557,7 @@ describe("Phase-01 Auth, Secrets, Revocation & Proxy Hardening", () => {
|
||||
});
|
||||
|
||||
it("FORENSIC BUG-01: blocks volatile RAM admin setup in production without DATABASE_URL and returns 409 SETUP_REQUIRED on pre-setup login", async () => {
|
||||
process.env.NODE_ENV = "production";
|
||||
(process.env as Record<string, string | undefined>).NODE_ENV = "production";
|
||||
delete process.env.DATABASE_URL;
|
||||
delete process.env.DATASTACK_ADMIN_PASSWORD;
|
||||
process.env.DATASTACK_ADMIN_SESSION_SECRET =
|
||||
@@ -770,7 +770,7 @@ describe("Phase-01 Auth, Secrets, Revocation & Proxy Hardening", () => {
|
||||
|
||||
try {
|
||||
// 1. Production with empty jwtSecret must not persist empty jwt_secret row into PG
|
||||
process.env.NODE_ENV = "production";
|
||||
(process.env as Record<string, string | undefined>).NODE_ENV = "production";
|
||||
delete process.env.DATASTACK_JWT_SECRET;
|
||||
settingsGlobals.__dataStackAdminSettings = undefined;
|
||||
settingsGlobals.__dataStackSettingsHydrated = false;
|
||||
@@ -791,7 +791,7 @@ describe("Phase-01 Auth, Secrets, Revocation & Proxy Hardening", () => {
|
||||
);
|
||||
|
||||
// 2. Failing PG write must reject (not silently return 200) and must not mutate RAM
|
||||
process.env.NODE_ENV = "test";
|
||||
(process.env as Record<string, string | undefined>).NODE_ENV = "test";
|
||||
process.env.DATASTACK_JWT_SECRET =
|
||||
"valid-jwt-secret-at-least-32-characters-long";
|
||||
AuthService.setSecret(process.env.DATASTACK_JWT_SECRET);
|
||||
|
||||
@@ -1085,10 +1085,10 @@ test("FORENSIC BUG-19: Deleting a client purges RAM, Redis, and Port 4000 buffer
|
||||
|
||||
test("FORENSIC BUG-20: Socket.IO sync_data and batch_sync ACKs wait until async Redis RPUSH completes", async () => {
|
||||
const fakeRedis = new FakeRedisClient();
|
||||
let rpushGateResolve: (() => void) | null = null;
|
||||
const rpushGateControl: { resolve?: () => void } = {};
|
||||
let rpushEnteredResolve: (() => void) | null = null;
|
||||
let rpushGate = new Promise<void>((resolve) => {
|
||||
rpushGateResolve = resolve;
|
||||
rpushGateControl.resolve = resolve;
|
||||
});
|
||||
let rpushEntered = new Promise<void>((resolve) => {
|
||||
rpushEnteredResolve = resolve;
|
||||
@@ -1155,14 +1155,14 @@ test("FORENSIC BUG-20: Socket.IO sync_data and batch_sync ACKs wait until async
|
||||
"sync_data ACK must NOT fire before Redis RPUSH finishes",
|
||||
);
|
||||
|
||||
rpushGateResolve?.();
|
||||
rpushGateControl.resolve?.();
|
||||
const syncAck = await syncAckPromise;
|
||||
assert.equal(syncAck.success, true);
|
||||
assert.equal(await fakeRedis.llen(REDIS_BUFFER_KEY), 1);
|
||||
|
||||
// 2. batch_sync must also wait for Redis RPUSH before ACK
|
||||
rpushGate = new Promise<void>((resolve) => {
|
||||
rpushGateResolve = resolve;
|
||||
rpushGateControl.resolve = resolve;
|
||||
});
|
||||
rpushEntered = new Promise<void>((resolve) => {
|
||||
rpushEnteredResolve = resolve;
|
||||
@@ -1199,7 +1199,7 @@ test("FORENSIC BUG-20: Socket.IO sync_data and batch_sync ACKs wait until async
|
||||
"batch_sync ACK must NOT fire before Redis RPUSH finishes",
|
||||
);
|
||||
|
||||
rpushGateResolve?.();
|
||||
rpushGateControl.resolve?.();
|
||||
const batchAck = await batchAckPromise;
|
||||
assert.equal(batchAck.success, true);
|
||||
assert.equal(batchAck.processed, 2);
|
||||
|
||||
@@ -172,7 +172,7 @@ test("R3-Phase-01 [BUG-03]: Client SDK JWTs omit hardcoded 30d exp so Never-Expi
|
||||
test("R3-Phase-01 [BUG-04 & BUG-15]: Viewer blocked (403) on POST /api/events and Operator blocked (403) on POST /api/storage/s3-test", async () => {
|
||||
resetAdminStateForTests();
|
||||
await createInitialAdmin("r3-owner@datastack.dev", "OwnerPassword123!");
|
||||
const sessionSecret = getAdminSessionSecret();
|
||||
const sessionSecret = getAdminSessionSecret()!;
|
||||
const suffix = Date.now();
|
||||
const viewerEmail = `r3viewer_${suffix}@datastack.dev`;
|
||||
const operatorEmail = `r3operator_${suffix}@datastack.dev`;
|
||||
@@ -182,13 +182,11 @@ test("R3-Phase-01 [BUG-04 & BUG-15]: Viewer blocked (403) on POST /api/events an
|
||||
email: viewerEmail,
|
||||
password: "ViewerPassword123!",
|
||||
role: "viewer",
|
||||
displayName: "R3 Viewer",
|
||||
});
|
||||
const operator = await createAdminTeamMemberAsync({
|
||||
email: operatorEmail,
|
||||
password: "OperatorPassword123!",
|
||||
role: "operator",
|
||||
displayName: "R3 Operator",
|
||||
});
|
||||
await SDKManager.registerClientAsync({
|
||||
clientId,
|
||||
@@ -292,7 +290,7 @@ test("R3-Phase-01 [BUG-06]: Locked webhook secret does not break unrelated setti
|
||||
|
||||
const ownerToken = await createAdminSessionToken(
|
||||
owner.email,
|
||||
getAdminSessionSecret(),
|
||||
getAdminSessionSecret()!,
|
||||
Date.now() + 3600_000,
|
||||
owner.tokenVersion,
|
||||
owner.role,
|
||||
@@ -427,7 +425,7 @@ test("R3-Phase-01 [BUG-10]: Brute-force 429 admin login lockout dispatches ADMIN
|
||||
assert.equal(dispatchedBodies[0].instance, "DataStack");
|
||||
} finally {
|
||||
global.fetch = origFetch;
|
||||
await clearAdminLoginAttempts(email, getAdminSessionSecret(), testIp);
|
||||
await clearAdminLoginAttempts(email, getAdminSessionSecret()!, testIp);
|
||||
await SettingsManager.updateSettingsAsync({
|
||||
enableWebhookAlerts: false,
|
||||
webhookUrl: "",
|
||||
|
||||
@@ -40,7 +40,7 @@ function writeGzipCsv(filePath: string, content: string): void {
|
||||
|
||||
async function createOwnerCookie(): Promise<string> {
|
||||
delete process.env.DATABASE_URL;
|
||||
const sessionSecret = getAdminSessionSecret();
|
||||
const sessionSecret = getAdminSessionSecret()!;
|
||||
resetAdminStateForTests();
|
||||
const ownerEmail = "owner-r3p2@datastack.local";
|
||||
await createInitialAdmin(ownerEmail, "StrongPassword123!");
|
||||
|
||||
@@ -5,6 +5,7 @@ import test from "node:test";
|
||||
import { NextRequest } from "next/server";
|
||||
import { GET as prometheusGet } from "../app/api/prometheus/route";
|
||||
import { SettingsManager } from "../core/adminSettings/settingsManager";
|
||||
import { DataBufferEngine } from "../core/data/buffer";
|
||||
import { ApiEngine } from "../core/apiEngine/apiService";
|
||||
import {
|
||||
createAdminSessionToken,
|
||||
@@ -24,6 +25,11 @@ import {
|
||||
summarizeUiClientCounts,
|
||||
} from "../lib/vconUiHelpers";
|
||||
|
||||
test.after(async () => {
|
||||
SDKManager.stopActivityFlushTimerForTests();
|
||||
await DataBufferEngine.shutdown();
|
||||
});
|
||||
|
||||
async function makeOwnerCookie(): Promise<string> {
|
||||
resetAdminStateForTests();
|
||||
await createInitialAdmin("r3-p4-owner@datastack.dev", "R3Phase04Pass!");
|
||||
|
||||
@@ -96,7 +96,7 @@ function restoreEnv(): void {
|
||||
async function createOwnerCookie(email = "r4p1-owner@datastack.dev"): Promise<string> {
|
||||
resetAdminStateForTests();
|
||||
await createInitialAdmin(email, "OwnerPassword123!");
|
||||
const secret = getAdminSessionSecret();
|
||||
const secret = getAdminSessionSecret()!;
|
||||
const token = await createAdminSessionToken(
|
||||
email,
|
||||
secret,
|
||||
@@ -531,7 +531,7 @@ test("R4-Phase-01 [AUDIT-09 / ERR-R4-04 & ERR-R4-05]: Fail-loud audit DB degrade
|
||||
assert.equal(unauthSync.status, 401);
|
||||
|
||||
// Owner session v1 works before logout/revocation
|
||||
const secret = getAdminSessionSecret();
|
||||
const secret = getAdminSessionSecret()!;
|
||||
const ownerTokenV1 = await createAdminSessionToken(
|
||||
"r4-audit-owner@datastack.dev",
|
||||
secret,
|
||||
|
||||
@@ -5,6 +5,7 @@ import fsp from "node:fs/promises";
|
||||
import http from "node:http";
|
||||
import { createRequire } from "node:module";
|
||||
import type { AddressInfo } from "node:net";
|
||||
import type { Request, Response } from "express";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
@@ -81,7 +82,7 @@ async function createOwnerCookie(
|
||||
): Promise<string> {
|
||||
resetAdminStateForTests();
|
||||
await createInitialAdmin(email, "OwnerPassword123!");
|
||||
const secret = getAdminSessionSecret();
|
||||
const secret = getAdminSessionSecret()!;
|
||||
const token = await createAdminSessionToken(
|
||||
email,
|
||||
secret,
|
||||
@@ -329,13 +330,13 @@ test("R4-Phase-02 AUDIT-06: Governance audit logging for /api/export, Files Mana
|
||||
getDbPool: () => null,
|
||||
}),
|
||||
);
|
||||
ramApp.put("/vcon/files-engine/api/v1/fs/sample.csv", (_req: express.Request, res: express.Response) => {
|
||||
ramApp.put("/vcon/files-engine/api/v1/fs/sample.csv", (_req: Request, res: Response) => {
|
||||
res.status(200).json({ ok: true });
|
||||
});
|
||||
ramApp.put("/vcon/files-engine/api/v1/rename", (_req: express.Request, res: express.Response) => {
|
||||
ramApp.put("/vcon/files-engine/api/v1/rename", (_req: Request, res: Response) => {
|
||||
res.status(200).json({ ok: true });
|
||||
});
|
||||
ramApp.delete("/vcon/files-engine/api/v1/fs/sample.csv", (_req: express.Request, res: express.Response) => {
|
||||
ramApp.delete("/vcon/files-engine/api/v1/fs/sample.csv", (_req: Request, res: Response) => {
|
||||
res.status(403).json({ ok: false }); // non-2xx should NOT emit mutation audit
|
||||
});
|
||||
|
||||
@@ -404,7 +405,7 @@ test("R4-Phase-02 AUDIT-06: Governance audit logging for /api/export, Files Mana
|
||||
getDbPool: () => mockDbPool,
|
||||
}),
|
||||
);
|
||||
pgApp.delete("/vcon/files-engine/api/v1/fs/obsolete.csv", (_req: express.Request, res: express.Response) => {
|
||||
pgApp.delete("/vcon/files-engine/api/v1/fs/obsolete.csv", (_req: Request, res: Response) => {
|
||||
res.status(200).json({ ok: true });
|
||||
});
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import fs from 'node:fs';
|
||||
import { createRequire } from 'node:module';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { afterEach, beforeEach, describe, it } from 'node:test';
|
||||
import { after, afterEach, beforeEach, describe, it } from 'node:test';
|
||||
import { NextRequest } from 'next/server';
|
||||
import { POST as setupPost } from '../app/api/auth/setup/route';
|
||||
import { GET as filesStatusGet } from '../app/api/files/status/route';
|
||||
@@ -13,9 +13,14 @@ import {
|
||||
getAdminSessionSecret,
|
||||
} from '../core/auth/adminSession';
|
||||
import { resetAdminStateForTests } from '../core/auth/adminUsers';
|
||||
import { DataBufferEngine } from '../core/data/buffer';
|
||||
import { middleware } from '../middleware';
|
||||
import { DataStack, DiskSpooler } from '../sdk/node/datastack';
|
||||
|
||||
after(async () => {
|
||||
await DataBufferEngine.shutdown();
|
||||
});
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const ORIGINAL_ENV = { ...process.env };
|
||||
const ORIGINAL_FETCH = globalThis.fetch;
|
||||
|
||||
@@ -35,6 +35,7 @@ import { SDKManager } from "../core/sdk/sdkManager";
|
||||
import { getInternalIngestionHeaders } from "../core/Security/security";
|
||||
import { SSRFBlockedError } from "../core/Security/ssrfGuard";
|
||||
import { CSVStorageManager } from "../core/Storage/csvStorage";
|
||||
import { DataBufferEngine } from "../core/data/buffer";
|
||||
import { middleware } from "../middleware";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
@@ -80,6 +81,12 @@ const ingestionServer = require("../server/index.js") as {
|
||||
syncSettingsFromDatabase: () => Promise<boolean>;
|
||||
};
|
||||
|
||||
test.after(async () => {
|
||||
ingestionServer.stopTimers();
|
||||
SDKManager.stopActivityFlushTimerForTests();
|
||||
await DataBufferEngine.shutdown();
|
||||
});
|
||||
|
||||
test("R5-Phase-01 [MCP-AUDIT-02 / ERR-R5-02]: Runtime log capture scrubs secrets, rotates at 2MB, filters/tails safely, and handles missing dirs gracefully", async () => {
|
||||
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "datastack-r5-logs-"));
|
||||
const logsDir = path.join(tmpDir, ".runtime-logs");
|
||||
|
||||
@@ -507,7 +507,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
|
||||
});
|
||||
assert.equal(deniedClientCreate.isError, true);
|
||||
const deniedPayload = JSON.parse(
|
||||
(deniedClientCreate.content[0] as { text: string }).text,
|
||||
((deniedClientCreate.content as Array<{ text: string }>)[0]).text,
|
||||
) as { code: string; permission: string };
|
||||
assert.equal(deniedPayload.code, "MCP_PERMISSION_DENIED");
|
||||
assert.equal(deniedPayload.permission, "clients_create");
|
||||
@@ -521,7 +521,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
|
||||
});
|
||||
assert.notEqual(createdToolRes.isError, true);
|
||||
const createdPayload = JSON.parse(
|
||||
(createdToolRes.content[0] as { text: string }).text,
|
||||
((createdToolRes.content as Array<{ text: string }>)[0]).text,
|
||||
) as { success: boolean; client: { clientId: string; rateLimit: number; token?: string } };
|
||||
assert.equal(createdPayload.success, true);
|
||||
assert.equal(createdPayload.client.clientId, testClientId);
|
||||
@@ -535,7 +535,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
|
||||
});
|
||||
assert.equal(traversalRes.isError, true);
|
||||
assert.equal(
|
||||
(JSON.parse((traversalRes.content[0] as { text: string }).text) as { code: string }).code,
|
||||
(JSON.parse(((traversalRes.content as Array<{ text: string }>)[0]).text) as { code: string }).code,
|
||||
"PATH_OUTSIDE_ROOT",
|
||||
);
|
||||
|
||||
@@ -546,7 +546,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
|
||||
});
|
||||
assert.equal(symlinkRes.isError, true);
|
||||
assert.equal(
|
||||
(JSON.parse((symlinkRes.content[0] as { text: string }).text) as { code: string }).code,
|
||||
(JSON.parse(((symlinkRes.content as Array<{ text: string }>)[0]).text) as { code: string }).code,
|
||||
"SYMLINK_FORBIDDEN",
|
||||
);
|
||||
}
|
||||
@@ -557,7 +557,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
|
||||
});
|
||||
assert.equal(lockReadRes.isError, true);
|
||||
assert.equal(
|
||||
(JSON.parse((lockReadRes.content[0] as { text: string }).text) as { code: string }).code,
|
||||
(JSON.parse(((lockReadRes.content as Array<{ text: string }>)[0]).text) as { code: string }).code,
|
||||
"LOCKFILE_PROTECTED",
|
||||
);
|
||||
|
||||
@@ -567,7 +567,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
|
||||
});
|
||||
assert.equal(lockedFileUploadRes.isError, true);
|
||||
assert.equal(
|
||||
(JSON.parse((lockedFileUploadRes.content[0] as { text: string }).text) as { code: string })
|
||||
(JSON.parse(((lockedFileUploadRes.content as Array<{ text: string }>)[0]).text) as { code: string })
|
||||
.code,
|
||||
"LOCKFILE_PROTECTED",
|
||||
);
|
||||
@@ -578,7 +578,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
|
||||
});
|
||||
assert.equal(logWriteRes.isError, true);
|
||||
assert.equal(
|
||||
(JSON.parse((logWriteRes.content[0] as { text: string }).text) as { code: string }).code,
|
||||
(JSON.parse(((logWriteRes.content as Array<{ text: string }>)[0]).text) as { code: string }).code,
|
||||
"PROTECTED_LOG_DIR",
|
||||
);
|
||||
|
||||
@@ -601,7 +601,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
|
||||
});
|
||||
assert.notEqual(dlRes.isError, true);
|
||||
assert.equal(
|
||||
(JSON.parse((dlRes.content[0] as { text: string }).text) as { content: string }).content,
|
||||
(JSON.parse(((dlRes.content as Array<{ text: string }>)[0]).text) as { content: string }).content,
|
||||
"alpha gamma",
|
||||
);
|
||||
|
||||
@@ -610,7 +610,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
|
||||
arguments: { path: "data" },
|
||||
});
|
||||
assert.notEqual(listRes.isError, true);
|
||||
const listParsed = JSON.parse((listRes.content[0] as { text: string }).text) as {
|
||||
const listParsed = JSON.parse(((listRes.content as Array<{ text: string }>)[0]).text) as {
|
||||
entries: Array<{ name: string }>;
|
||||
};
|
||||
assert.ok(listParsed.entries.some((e) => e.name === "active.csv"));
|
||||
@@ -632,7 +632,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
|
||||
});
|
||||
assert.notEqual(metricsRes.isError, true);
|
||||
assert.equal(
|
||||
(JSON.parse((metricsRes.content[0] as { text: string }).text) as { success: boolean }).success,
|
||||
(JSON.parse(((metricsRes.content as Array<{ text: string }>)[0]).text) as { success: boolean }).success,
|
||||
true,
|
||||
);
|
||||
|
||||
@@ -641,7 +641,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
|
||||
arguments: { action: "flush" },
|
||||
});
|
||||
assert.notEqual(flushRes.isError, true);
|
||||
const flushPayload = JSON.parse((flushRes.content[0] as { text: string }).text) as {
|
||||
const flushPayload = JSON.parse(((flushRes.content as Array<{ text: string }>)[0]).text) as {
|
||||
success: boolean;
|
||||
ingestionFlushed: number;
|
||||
};
|
||||
@@ -654,7 +654,7 @@ test("R5-Phase-02 [MCP-AUDIT-01/06/07 & ERR-R5-03/04/05/06]: Port 4000 MCP serve
|
||||
});
|
||||
assert.equal(coolifySsrfRes.isError, true);
|
||||
assert.equal(
|
||||
(JSON.parse((coolifySsrfRes.content[0] as { text: string }).text) as { code: string }).code,
|
||||
(JSON.parse(((coolifySsrfRes.content as Array<{ text: string }>)[0]).text) as { code: string }).code,
|
||||
"SSRF_BLOCKED_HOST",
|
||||
);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import path from "node:path";
|
||||
import test from "node:test";
|
||||
|
||||
import { MCP_PERMISSION_DEFINITIONS } from "../core/mcp/mcpSettings";
|
||||
import { DataBufferEngine } from "../core/data/buffer";
|
||||
import {
|
||||
applyCategoryPermissionToggle,
|
||||
applyMcpPermissionPreset,
|
||||
@@ -23,6 +24,10 @@ import {
|
||||
|
||||
const DEFINITIONS = MCP_PERMISSION_DEFINITIONS as readonly McpPermissionDefinitionView[];
|
||||
|
||||
test.after(async () => {
|
||||
await DataBufferEngine.shutdown();
|
||||
});
|
||||
|
||||
test("R5-Phase-03 [lib/mcpUiHelpers.ts]: URL builder, AI client JSON snippets, permission grouping/presets, bridge status, and diff payload", () => {
|
||||
// 1. Endpoint URL builder
|
||||
assert.equal(
|
||||
|
||||
@@ -43,6 +43,8 @@ import {
|
||||
uploadFileToS3,
|
||||
} from "../core/Storage/s3Archive";
|
||||
import {
|
||||
classifyUiClientStatus,
|
||||
summarizeUiClientCounts,
|
||||
DEFAULT_EDITABLE_SETTINGS,
|
||||
settingsToNumericDrafts,
|
||||
validateEditableSettingsDraft,
|
||||
@@ -759,7 +761,7 @@ test("V2-Audit-Phase-03 [BUG-V2-AUDIT-01, BUG-V2-AUDIT-07, BUG-V2-AUDIT-10]: Dis
|
||||
bsize: 4096,
|
||||
}));
|
||||
|
||||
const snapshot = await CSVStorageManager.getDiskUsageAsync(true);
|
||||
const snapshot = await CSVStorageManager.getDiskUsageAsync();
|
||||
assert.equal(snapshot.available, true);
|
||||
assert.equal(snapshot.usedPct, 25);
|
||||
assert.equal(snapshot.totalBytes, 2000 * 4096);
|
||||
@@ -780,29 +782,30 @@ test("V2-Audit-Phase-03 [BUG-V2-AUDIT-01, BUG-V2-AUDIT-07, BUG-V2-AUDIT-10]: Dis
|
||||
CSVStorageManager.setStatfsOverrideForTests(async () => {
|
||||
throw new Error("Simulated statfs failure");
|
||||
});
|
||||
const fallbackSnapshot = await CSVStorageManager.getDiskUsageAsync(true);
|
||||
const fallbackSnapshot = await CSVStorageManager.getDiskUsageAsync();
|
||||
assert.equal(fallbackSnapshot.available, false);
|
||||
assert.equal(fallbackSnapshot.freeBytes, 0);
|
||||
assert.equal(fallbackSnapshot.availableBytes, 0);
|
||||
|
||||
// 2. BUG-V2-AUDIT-07: app/vcon/clients/page.tsx defines isClientExpired and excludes expired tokens from onlineCount, pendingCount, and online/pending filter tabs
|
||||
// 2. BUG-V2-AUDIT-07: shared status classifier excludes expired clients from active counters.
|
||||
const clientsPageSrc = await fs.readFile(
|
||||
path.join(process.cwd(), "app/vcon/clients/page.tsx"),
|
||||
"utf8",
|
||||
);
|
||||
assert.match(clientsPageSrc, /function isClientExpired\(/);
|
||||
assert.match(
|
||||
clientsPageSrc,
|
||||
/const expired = !revoked && isClientExpired\(client\.expiresAt,\s*now\)/,
|
||||
);
|
||||
assert.match(
|
||||
clientsPageSrc,
|
||||
/!isClientExpired\(client\.expiresAt,\s*now\)/,
|
||||
);
|
||||
assert.match(
|
||||
clientsPageSrc,
|
||||
/const pending =\s*client\.status === 'active' && !expired && !client\.lastActive/,
|
||||
);
|
||||
assert.match(clientsPageSrc, /summarizeUiClientCounts\(clients, now\)/);
|
||||
assert.match(clientsPageSrc, /classifyUiClientStatus\(client, now\)/);
|
||||
const now = Date.parse("2026-11-21T10:00:00.000Z");
|
||||
const expiredClient = { status: "active" as const, expiresAt: "2020-01-01T00:00:00.000Z", lastActive: "2026-11-21T09:59:50.000Z" };
|
||||
const pendingClient = { status: "active" as const, expiresAt: null, lastActive: undefined };
|
||||
const onlineClient = { status: "active" as const, expiresAt: null, lastActive: "2026-11-21T09:59:50.000Z" };
|
||||
assert.equal(classifyUiClientStatus(expiredClient, now), "expired");
|
||||
assert.equal(classifyUiClientStatus(pendingClient, now), "pending");
|
||||
assert.equal(classifyUiClientStatus(onlineClient, now), "online");
|
||||
const summary = summarizeUiClientCounts([expiredClient, pendingClient, onlineClient], now);
|
||||
assert.equal(summary.expired, 1);
|
||||
assert.equal(summary.online, 1);
|
||||
assert.equal(summary.pending, 1);
|
||||
assert.equal(summary.active, 2);
|
||||
|
||||
// 3. BUG-V2-AUDIT-10: ExportWorkspace.tsx and app/vcon/storage/page.tsx render CSV.GZ badge for compressed .csv.gz partitions
|
||||
const exportWorkspaceSrc = await fs.readFile(
|
||||
|
||||
@@ -331,7 +331,7 @@ test("V2-Phase-02 [HTTP & Socket Ingestion Security]: Per-client IP allowlist (4
|
||||
token: string,
|
||||
bypassCache?: boolean,
|
||||
clientIp?: string,
|
||||
) => Promise<{ ok: boolean; reason?: string }>;
|
||||
) => Promise<{ allowed: boolean; code?: string; reason?: string }>;
|
||||
setDbPoolForTests: (pool: unknown) => void;
|
||||
stopTimers: () => void;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user