Files
meshcentral-openclaw-bridge/openclaw-plugin/test/static-safety.test.mjs

25 lines
1010 B
JavaScript

import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import test from 'node:test';
const entry = await readFile(new URL('../src/index.ts', import.meta.url), 'utf8');
const transport = await readFile(new URL('../src/meshcentral-readonly.ts', import.meta.url), 'utf8');
test('declares exactly the four read-only tools', () => {
for (const name of [
'meshcentral_health',
'meshcentral_list_groups',
'meshcentral_list_devices',
'meshcentral_device_status',
]) assert.match(entry, new RegExp(`name: '${name}'`));
assert.doesNotMatch(entry, /runcommand|power|console|filetransfer|remotecontrol|diagnostic/i);
});
test('uses fixed configured targets and an environment variable for the password', () => {
assert.match(entry, /passwordEnv/);
assert.match(transport, /process\.env\[config\.passwordEnv\]/);
assert.match(transport, /groupName/);
assert.match(transport, /deviceName/);
assert.doesNotMatch(transport, /rejectUnauthorized:\s*false/);
});