mirror of
https://github.com/nexu-io/open-design.git
synced 2026-10-27 09:51:12 +01:00
* Split daemon run helper modules * refactor(daemon): split remaining server helpers * fix(daemon): restore routine run context import Generated-By: looper 0.9.11 (runner=fixer, agent=codex) * fix(daemon): preserve null analytics project kind Generated-By: looper 0.9.11 (runner=fixer, agent=codex) * fix(daemon): move run analytics helper under runtimes Generated-By: looper 0.9.11 (runner=fixer, agent=codex) * fix(web): handle diagnostic persisted events * test(daemon): gate media policy capture on run env Generated-By: looper 0.0.0-dev (runner=fixer, agent=codex)
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
import { tmpdir } from 'node:os';
|
|
import path from 'node:path';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { __forTestReadProjectPluginManifest } from '../src/plugins/share-helpers.js';
|
|
|
|
describe('readProjectPluginManifest', () => {
|
|
async function withManifest(name: string, fn: (folder: string) => Promise<void>) {
|
|
const folder = await mkdtemp(path.join(tmpdir(), 'od-plugin-manifest-'));
|
|
try {
|
|
await writeFile(path.join(folder, 'open-design.json'), JSON.stringify({ name }), 'utf8');
|
|
await fn(folder);
|
|
} finally {
|
|
await rm(folder, { recursive: true, force: true });
|
|
}
|
|
}
|
|
|
|
it.each(['../evil', '..\\\\evil', '.', '..'])('rejects unsafe manifest name %s', async (name) => {
|
|
await withManifest(name, async (folder) => {
|
|
await expect(__forTestReadProjectPluginManifest(folder)).rejects.toThrow(
|
|
/must not contain path separators or consist only of dots/,
|
|
);
|
|
});
|
|
});
|
|
|
|
it('allows ordinary plugin names with dots', async () => {
|
|
await withManifest('my-plugin.v2', async (folder) => {
|
|
await expect(__forTestReadProjectPluginManifest(folder)).resolves.toMatchObject({
|
|
name: 'my-plugin.v2',
|
|
});
|
|
});
|
|
});
|
|
});
|