chore(runtime): upgrade DSH and bundled plugins for runtime-7.10
This commit is contained in:
@@ -3,6 +3,30 @@ import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { runInNewContext } from 'node:vm';
|
||||
|
||||
test('installer accepts the release host and rejects unverified hosts before writing', () => {
|
||||
const source = readFileSync(new URL('./install-preview-download.mjs', import.meta.url), 'utf8')
|
||||
.replace(/^import .*;$/gm, '').replaceAll('import.meta.url', JSON.stringify(import.meta.url));
|
||||
const release = JSON.parse(readFileSync(new URL('../release.json', import.meta.url)));
|
||||
for (const version of [release.version, '0.2.1-rc.2', '0.2.1-rc.4', 'next']) {
|
||||
const calls = [];
|
||||
const run = () => runInNewContext(source, {
|
||||
URL, readFileSync: () => JSON.stringify({ version }),
|
||||
mkdirSync: (...args) => calls.push(['mkdir', ...args]),
|
||||
cpSync: (...args) => calls.push(['copy', ...args]),
|
||||
execFileSync: (...args) => calls.push(['exec', ...args]),
|
||||
});
|
||||
if (version === release.version) {
|
||||
run();
|
||||
assert.deepEqual(calls.map(call => call[0]), ['mkdir', 'copy', 'exec']);
|
||||
assert.equal(calls[2][1], 'tar');
|
||||
assert.equal(calls[2][2][1], '/usr/local/lib/dsh-mgr/dsh-preview-download-1.0.1.tgz');
|
||||
} else {
|
||||
assert.throws(run, /Unverified preview download host/);
|
||||
assert.equal(calls.length, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function load() {
|
||||
let plugin;
|
||||
runInNewContext(readFileSync(new URL('./preview-download/client.js', import.meta.url), 'utf8'), {
|
||||
|
||||
Reference in New Issue
Block a user