Files
orca/config/scripts/desktop-distribution/runtime-verification/verify-packaged-plugin-resources.test.mjs
T
Neil 9bd6272fdf refactor(tooling): organize build, CI, and test owners (#38130)
* refactor(tooling): organize test runtime and maintenance owners

* test(tooling): preserve relocated runtime fixture dependency edges

* refactor(tooling): preserve xterm routing owner checks

* ci(tooling): include routing owner in sparse checkout

* test(tooling): preserve copied workflow dependency closures

* fix(tooling): normalize hashed JSON assets in release parity

* fix(tooling): distinguish asset aliases from literal references

* fix(tooling): frame normalized asset reference payloads

* fix(tooling): normalize decoded JSON asset references

* refactor(tooling): organize build, CI and release owners

* fix(tooling): align moved generator and workflow path contracts

* fix(tooling): update generated plugin bundle owner banners

* test(tooling): create relocated mobile verifier fixture directories

* test(tooling): copy headless detector dependency closure

* test(tooling): align native batch policy fixtures with owner path

* fix(tooling): link moved reliability command to historical evidence

* fix(tooling): preserve nested sandbox owners and canonical guide source

* fix(tooling): target release version owners in checkout fixture
2026-11-04 21:08:19 -08:00

72 lines
2.6 KiB
JavaScript

import { cp, mkdtemp, readFile, readdir, rm, stat, writeFile } from 'node:fs/promises'
import { createRequire } from 'node:module'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { describe, expect, it } from 'vitest'
const require = createRequire(import.meta.url)
const {
hashPackagedPluginTree,
verifyPackagedPluginResources
} = require('./verify-packaged-plugin-resources.cjs')
const FIXTURE_KEY = 'stablyai.orca-multipass-recipes'
/** Copies the launch tree and indexes one shipped pack so byte checks have something to verify. */
async function copyIndexedLaunchTree(resourcesDir) {
const launchRoot = join(resourcesDir, 'plugins', 'launch')
await cp(join(process.cwd(), 'resources', 'plugins', 'launch'), launchRoot, { recursive: true })
await writeFile(
join(launchRoot, 'bundled-plugins.json'),
JSON.stringify({
version: 1,
plugins: [
{
pluginKey: FIXTURE_KEY,
path: FIXTURE_KEY,
contentHash: hashPackagedPluginTree(join(launchRoot, FIXTURE_KEY))
}
]
})
)
return launchRoot
}
describe('verify packaged plugin resources', () => {
it('rejects mutated bytes in the packaged output', async () => {
const resourcesDir = await mkdtemp(join(tmpdir(), 'orca-packaged-plugins-'))
try {
const launchRoot = await copyIndexedLaunchTree(resourcesDir)
expect(() => verifyPackagedPluginResources(resourcesDir)).not.toThrow()
await writeFile(join(launchRoot, FIXTURE_KEY, 'extra.json'), '{"mutated":true}\n')
expect(() => verifyPackagedPluginResources(resourcesDir)).toThrow(
`packaged bytes do not match ${FIXTURE_KEY}`
)
} finally {
await rm(resourcesDir, { recursive: true, force: true })
}
})
it('rejects a CRLF checkout of the launch tree', async () => {
const resourcesDir = await mkdtemp(join(tmpdir(), 'orca-packaged-plugins-'))
try {
const launchRoot = await copyIndexedLaunchTree(resourcesDir)
for (const entry of await readdir(launchRoot, { recursive: true })) {
const path = join(launchRoot, entry)
if (!(await stat(path)).isFile()) {
continue
}
await writeFile(path, (await readFile(path, 'utf8')).replace(/\r?\n/g, '\r\n'))
}
// Every plugin is rewritten; assert first sorted mismatch without pinning reorderable plugin name.
expect(() => verifyPackagedPluginResources(resourcesDir)).toThrow(
/packaged bytes do not match stablyai\./
)
} finally {
await rm(resourcesDir, { recursive: true, force: true })
}
})
})