38 lines
2.7 KiB
TypeScript
38 lines
2.7 KiB
TypeScript
import assert from "node:assert/strict"
|
|
process.env.AUTH_REQUIRED="true"
|
|
process.env.AUTH_JWT_SECRET="mcp-owned-application-acceptance-secret"
|
|
process.env.AUTH_ISSUER="https://auth.test.local"
|
|
const {pool,closePool}=await import("../../db/index.js")
|
|
const {applySqlMigrations}=await import("../../db/migrate.js")
|
|
const {updateMcpSettings}=await import("./store.js")
|
|
const {buildApp}=await import("../../index.js")
|
|
const actor={id:"application-acceptance-owner",apps:["mm"],permissions:["mm:settings:admin","mm:network:admin"],expiresAt:Date.now()+3600000}
|
|
let app:Awaited<ReturnType<typeof buildApp>>|undefined
|
|
try{
|
|
await applySqlMigrations(pool)
|
|
assert.equal((await pool.query("SELECT count(*)::int AS n FROM servers")).rows[0].n,0,"Disposable empty database required")
|
|
await pool.query("INSERT INTO servers(id,name,host,port,use_ssl,enabled) VALUES(1,'owned-fixture','127.0.0.1',9,false,false)")
|
|
await pool.query("INSERT INTO geoip_settings(id,enabled) VALUES(1,false) ON CONFLICT(id) DO UPDATE SET enabled=false")
|
|
await pool.query("INSERT INTO traffic_flow_settings(id) VALUES(1) ON CONFLICT(id) DO NOTHING")
|
|
await pool.query("INSERT INTO backup_storage_settings(id) VALUES(1) ON CONFLICT(id) DO NOTHING")
|
|
await updateMcpSettings({enabled:true},actor)
|
|
app=await buildApp({startScheduler:false});await app.ready()
|
|
await (await import("../../test/mcp-users-bindings.js")).verifyMcpUserBindings(actor)
|
|
await (await import("./routing-community-context-acceptance.js")).acceptRouteCommunityContextMcp(actor)
|
|
await (await import("../../test/mcp-acme-test.js")).verifyMcpAcmeTest(actor)
|
|
await (await import("../../test/mcp-acme-settings.js")).verifyMcpAcmeSettings(actor)
|
|
await (await import("../../test/mcp-geoip-update.js")).verifyMcpGeoipUpdate(actor)
|
|
await (await import("../../test/mcp-flow-overlay.js")).verifyMcpFlowOverlay(actor)
|
|
await (await import("../../test/mcp-backup-download.js")).verifyMcpBackupDownload(actor,app)
|
|
await (await import("./wireguard-interface-create-acceptance.js")).acceptWireguardInterfaceCreation(actor)
|
|
await (await import("./wireguard-peer-create-acceptance.js")).acceptWireguardPeerCreation(actor)
|
|
await (await import("../../test/mcp-database-backup.js")).verifyMcpDatabaseBackup(actor,app)
|
|
}finally{
|
|
await pool.query("UPDATE servers SET enabled=false").catch(()=>{})
|
|
// Database export resumes shared background work even for this scheduler-free
|
|
// app fixture. Drain it before closing the pool, as the full integration does.
|
|
await (await import("../../services/scheduler.js")).stopSchedulerForDatabaseOperation()
|
|
await (await import("../../services/traffic-flow-ingest.js")).stopTrafficFlowListenerForDatabaseOperation()
|
|
await app?.close();await closePool()
|
|
}
|