Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cad54635a8 | ||
|
|
f45b0f6afc | ||
|
|
44afc7982c | ||
|
|
68be28af2f | ||
|
|
9ef38dc087 | ||
|
|
bef7f1ff72 |
No files matched your search
@@ -394,7 +394,7 @@ try {
|
||||
DATABASE_URL: `postgresql://mcp_test:${password}@127.0.0.1:${port}/${database}`,
|
||||
DATABASE_PATH: join(directory, 'no-legacy-database.sqlite'), SQLITE_IMPORT_FULL_HISTORY: 'false',
|
||||
MMAPP_OWN_SQL_DB: database, MCP_STATE_DIR: join(directory, 'regression-state'),
|
||||
REQUIRE_TEST_POSTGRES: '1',
|
||||
REQUIRE_TEST_POSTGRES: '1', MMAPP_OWN_REGRESSION: '1',
|
||||
LOGS_PERFORMANCE: process.argv.includes('--performance') ? '1' : '0',
|
||||
AUTH_REQUIRED: 'false', NODE_ENV: 'test' },
|
||||
})
|
||||
|
||||
@@ -3,10 +3,13 @@ import { spawnSync } from "node:child_process"
|
||||
const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"))
|
||||
const npmCli = process.env.npm_execpath
|
||||
if (!npmCli) throw new Error("Запускайте тесты через npm --prefix backend test")
|
||||
for (const command of pkg.scripts["test:all"].split(/\s*&&\s*/)) {
|
||||
const match = /^npm run (test:[\w-]+)$/.exec(command)
|
||||
if (!match) throw new Error("Неизвестный формат профиля backend tests")
|
||||
const result = spawnSync(process.execPath, [npmCli, "run", match[1]], {
|
||||
const profiles = pkg.scripts["test:all"].split(/\s*&&\s*/).map(command => {
|
||||
const match = /^npm run (test:[\w-]+(?::[\w-]+)*)$/.exec(command)
|
||||
if (!match || !Object.hasOwn(pkg.scripts, match[1])) throw new Error(`Неизвестный профиль тестов backend: ${command}`)
|
||||
return match[1]
|
||||
})
|
||||
for (const profile of profiles) {
|
||||
const result = spawnSync(process.execPath, [npmCli, "run", profile], {
|
||||
cwd: new URL("../", import.meta.url),
|
||||
env: { ...process.env, NODE_ENV: "test" },
|
||||
stdio: "inherit",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
import path from 'node:path'
|
||||
import {tmpdir} from 'node:os'
|
||||
import {mkdtemp,mkdir,writeFile,readFile,appendFile,rm,lstat,chmod,symlink} from 'node:fs/promises'
|
||||
import * as filesystem from 'node:fs/promises'
|
||||
import {fileURLToPath} from 'node:url'
|
||||
@@ -14,12 +15,12 @@ const target='postgresql://service:[email protected]:5432/managed?
|
||||
const record=(operationId:string,state:string)=>JSON.stringify({operationId,state,at:'2026-11-01T00:00:00.000Z'})+'\n'
|
||||
const source={systemIdentifier:'1234567890',databaseOid:'12345',databaseName:'managed',serverVersionNum:180004,inRecovery:false as const}
|
||||
const knownCurrent={transport:{mode:'tls' as const,endpointSha256:'f'.repeat(64)},source,schemaSha256:'a'.repeat(64),rawSchemaSha256:'b'.repeat(64),physicalSchemaSha256:'c'.repeat(64),manifestSha256:'d'.repeat(64),markersSha256:'e'.repeat(64)}
|
||||
async function own(work:(root:string,uncertain:string,applied:string)=>Promise<void>){await mkdir(temp,{recursive:true});const root=await mkdtemp(path.join(temp,'owned-maintenance-resolution-'));try{
|
||||
async function own(work:(root:string,uncertain:string,applied:string)=>Promise<void>,base=temp){await mkdir(base,{recursive:true});const root=await mkdtemp(path.join(base,'owned-maintenance-resolution-'));try{
|
||||
await mkdir(path.join(root,'restore-vault'));await writeFile(path.join(root,'access-generation'),Buffer.alloc(32,7));const uncertain=randomUUID(),applied=randomUUID()
|
||||
await writeFile(path.join(root,'database-maintenance.jsonl'),record(uncertain,'intent')+record(uncertain,'unconfirmed')+record(applied,'intent')+record(applied,'applied'))
|
||||
for(const [id,state]of [[uncertain,'unknown'],[applied,'applied']]){const archiveRef=randomUUID(),at='2026-11-01T00:00:00.000Z';await writeFile(path.join(root,'restore-vault',archiveRef+'.used'),JSON.stringify({operationId:id,at}));await writeFile(path.join(root,'restore-vault',id+'.receipt.json'),JSON.stringify({operationId:id,archiveRef,state,startedAt:at,automaticRetry:false,...(state==='applied'?{finishedAt:at,accessRevoked:true,warnings:[]}:{errorCode:'RESTORE_UNCONFIRMED',finishedAt:at})}))}
|
||||
await work(root,uncertain,applied)
|
||||
}finally{assert(path.dirname(root)===temp&&path.basename(root).startsWith('owned-maintenance-resolution-'));await rm(root,{recursive:true,force:true})}}
|
||||
}finally{assert(path.dirname(root)===base&&path.basename(root).startsWith('owned-maintenance-resolution-'));await rm(root,{recursive:true,force:true})}}
|
||||
export async function modeledStartup(){
|
||||
// This is deliberately a MODELED POSIX ownership adapter over actual owned
|
||||
// files on Windows, not evidence that Windows/Linux protection was accepted.
|
||||
@@ -139,12 +140,14 @@ test('new unresolved vault marker blocks even without a new core journal record'
|
||||
|
||||
test('native POSIX immutable fsynced acceptance is consumed by actual startup; mode and symlink drift refuse',async context=>{
|
||||
if(process.platform==='win32'){context.skip('Native POSIX filesystem acceptance must run directly on Linux; Windows model is not proof');return}
|
||||
await own(async root=>{
|
||||
// protectedDirectory requires every parent to be non-writable by others; a CI checkout may not be, the system temp root is.
|
||||
const base=await mkdtemp(path.join(tmpdir(),'mm-posix-maintenance-'))
|
||||
try{await own(async root=>{
|
||||
const {writeFile:writeProtected}=await import('../../scripts/writer-profile/operator-files.mjs'),value=await acceptance(root),directory=path.join(root,'maintenance-acceptances'),filename=path.join(directory,value.resolutionId+'.json')
|
||||
await mkdir(directory,{mode:0o700});await writeProtected(filename,Buffer.from(JSON.stringify(value)),{flag:'wx',mode:0o600})
|
||||
assert.equal((await inspectDatabaseMaintenanceStartup(root,target)).classification,'accepted-current-state')
|
||||
await chmod(filename,0o644);assert.equal((await inspectDatabaseMaintenanceStartup(root,target)).classification,'inspection-required');await chmod(filename,0o600)
|
||||
const alias=path.join(directory,randomUUID()+'.json');await symlink(filename,alias);assert.equal((await inspectDatabaseMaintenanceStartup(root,target)).classification,'inspection-required');await rm(alias)
|
||||
const later=randomUUID();await appendFile(path.join(root,'database-maintenance.jsonl'),record(later,'intent')+record(later,'applied'));assert.equal((await inspectDatabaseMaintenanceStartup(root,target)).classification,'accepted-current-state')
|
||||
})
|
||||
},base)}finally{await rm(base,{recursive:true,force:true})}
|
||||
})
|
||||
@@ -90,7 +90,8 @@ try {
|
||||
finally { if (ownedIds.length) await pool.query("DELETE FROM servers WHERE id=ANY($1::bigint[])", [ownedIds]) }
|
||||
}
|
||||
} else {
|
||||
assert.notEqual(process.env.REQUIRE_TEST_POSTGRES, "1", "Owned SQL/disabled API checks are mandatory in PostgreSQL regression")
|
||||
// Only the owned regression (test-mcp-postgres.mjs) must run them; CI has PostgreSQL but no owned database.
|
||||
assert.notEqual(process.env.MMAPP_OWN_REGRESSION, "1", "Owned SQL/disabled API checks are mandatory in the owned PostgreSQL regression")
|
||||
console.log("network-disabled-server.test.ts: invalid IDs passed; optional SQL checks need an explicit owned database")
|
||||
}
|
||||
} finally { await closePool() }
|
||||
@@ -798,5 +798,5 @@ function McpWorkspaceContent({ backendUrl, live }: { backendUrl: string; live: b
|
||||
const [operations, setOperations] = useState<McpOperationDescriptor[]>([]), [error, setError] = useState("")
|
||||
useEffect(() => { if (!live) return; const controller = new AbortController(); void api.catalog(controller.signal).then(catalog => setOperations(catalog.operations), failure => { if (!controller.signal.aborted) setError(errorText(failure)) }); return () => controller.abort() }, [api, live])
|
||||
const changeTab = (value: unknown) => { const next = String(value); const url = new URL(window.location.href); url.searchParams.set("tab", next); window.history.replaceState(null, "", url.pathname + url.search) }
|
||||
return <><PageHeader crumbs={[{ label: "MCP" }]} /><main className="flex min-w-0 flex-1 flex-col gap-5 p-4 md:p-6"><div className="flex items-center gap-3"><BotIcon className="size-7 text-muted-foreground" /><div><h1 className="text-xl font-semibold">MCP</h1><p className="text-sm text-muted-foreground">Доступ нейросетей, разрешения и контроль изменений</p></div></div>{!live ? <Panel title="Подключите backend"><p>Для выдачи реального AI-доступа выберите режим «Живые» и настройте авторизацию портала.</p></Panel> : <><ErrorMessage message={error} />{oauthRequestId && <Consent key={oauthRequestId} api={api} id={oauthRequestId} />}<Tabs value={tab} onValueChange={changeTab}><div className="overflow-x-auto pb-1"><TabsList variant="line">{Object.entries(tabs).filter(([key]) => key !== "settings" || can("mm:mcp:admin")).map(([key, title]) => <TabsTrigger key={key} value={key}>{title}</TabsTrigger>)}</TabsList></div><TabsContent value="overview"><Overview api={api} /></TabsContent><TabsContent value="connections"><div className="flex flex-col gap-4"><Connections api={api} operations={operations} />{can("mm:mcp:admin") && <AccessTools api={api} />}</div></TabsContent><TabsContent value="permissions"><Permissions api={api} operations={operations} /></TabsContent><TabsContent value="devices"><DeviceManagement api={api} /></TabsContent><TabsContent value="routing"><div className="flex flex-col gap-4"><RoutingProfiles api={api} /><RoutePathVerification api={api} /></div></TabsContent><TabsContent value="requests"><Records api={api} kind="requests" /></TabsContent><TabsContent value="plans"><div className="flex flex-col gap-4"><Records api={api} kind="plans" /><Records api={api} kind="operations" />{admin && <OperationRecovery key={recoveryId} api={api} operationId={recoveryId} />}<Records api={api} kind="drift" /></div></TabsContent>{can("mm:mcp:admin") && <TabsContent value="settings"><div className="flex flex-col gap-4"><Settings api={api} /><RestCoverage api={api} /><ManagementChannels api={api} />{can("mm:settings:admin") && <DatabaseRestore api={api} />}</div></TabsContent>}</Tabs></>}</main></>
|
||||
return <><PageHeader crumbs={[{ label: "MCP" }]} /><div className="flex min-h-0 min-w-0 flex-1 flex-col gap-5 overflow-y-auto p-4 md:p-6"><div className="flex items-center gap-3"><BotIcon className="size-7 text-muted-foreground" /><div><h1 className="text-xl font-semibold">MCP</h1><p className="text-sm text-muted-foreground">Доступ нейросетей, разрешения и контроль изменений</p></div></div>{!live ? <Panel title="Подключите backend"><p>Для выдачи реального AI-доступа выберите режим «Живые» и настройте авторизацию портала.</p></Panel> : <><ErrorMessage message={error} />{oauthRequestId && <Consent key={oauthRequestId} api={api} id={oauthRequestId} />}<Tabs value={tab} onValueChange={changeTab}><div className="overflow-x-auto pb-1"><TabsList variant="line">{Object.entries(tabs).filter(([key]) => key !== "settings" || can("mm:mcp:admin")).map(([key, title]) => <TabsTrigger key={key} value={key}>{title}</TabsTrigger>)}</TabsList></div><TabsContent value="overview"><Overview api={api} /></TabsContent><TabsContent value="connections"><div className="flex flex-col gap-4"><Connections api={api} operations={operations} />{can("mm:mcp:admin") && <AccessTools api={api} />}</div></TabsContent><TabsContent value="permissions"><Permissions api={api} operations={operations} /></TabsContent><TabsContent value="devices"><DeviceManagement api={api} /></TabsContent><TabsContent value="routing"><div className="flex flex-col gap-4"><RoutingProfiles api={api} /><RoutePathVerification api={api} /></div></TabsContent><TabsContent value="requests"><Records api={api} kind="requests" /></TabsContent><TabsContent value="plans"><div className="flex flex-col gap-4"><Records api={api} kind="plans" /><Records api={api} kind="operations" />{admin && <OperationRecovery key={recoveryId} api={api} operationId={recoveryId} />}<Records api={api} kind="drift" /></div></TabsContent>{can("mm:mcp:admin") && <TabsContent value="settings"><div className="flex flex-col gap-4"><Settings api={api} /><RestCoverage api={api} /><ManagementChannels api={api} />{can("mm:settings:admin") && <DatabaseRestore api={api} />}</div></TabsContent>}</Tabs></>}</div></>
|
||||
}
|
||||
@@ -40,6 +40,20 @@ async function setup(page: Page, fail = false) {
|
||||
return calls
|
||||
}
|
||||
|
||||
test("MCP: настройки прокручиваются до восстановления базы", async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1100, height: 640 })
|
||||
await setup(page)
|
||||
await page.goto("/mcp?tab=settings")
|
||||
|
||||
const restoreHeading = page.getByRole("heading", { name: "Восстановление БД через MCP" })
|
||||
await expect(restoreHeading).toBeAttached()
|
||||
await expect(restoreHeading).not.toBeInViewport()
|
||||
await page.mouse.move(700, 400)
|
||||
await page.mouse.wheel(0, 3000)
|
||||
await expect(restoreHeading).toBeInViewport()
|
||||
await expect(page.getByRole("navigation", { name: "Путь страницы" })).toBeInViewport()
|
||||
})
|
||||
|
||||
test("MCP приостанавливает опрос по сигналу скрытия документа и возобновляет при показе", async ({ page }) => {
|
||||
const calls = await setup(page)
|
||||
const overviewCalls = () => calls.filter(call => call === "GET /api/mcp/overview").length
|
||||
|
||||
Reference in new issue
Block a user