fmt(js): npm run fix on merge (#104210)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
06402ecb7c
commit
089bb32886
@@ -1849,55 +1849,66 @@ test('cleanupStale keeps the lockfile when even SIGKILL cannot confirm the pid d
|
||||
// The record must survive so the next connect's reap pass retries.
|
||||
assert.ok(!ssh.calls.some(c => /rm -f .*backend\.lock\.json/.test(c)))
|
||||
})
|
||||
test.skipIf(process.platform === 'win32')('buildSpawnCommand quotes expandRemotePath fragments exactly once (real sh parse)', async () => {
|
||||
// expandRemotePath() output is pre-quoted; a second shq() ships literal quote
|
||||
// characters to the remote python. Parse the composed command with a real sh,
|
||||
// as the remote login shell does, and require every path to come out clean.
|
||||
const cmd = buildSpawnCommand('/x/hermes', 'work', {
|
||||
hermesHome: '~/.hermes',
|
||||
logPath: spawnLogPath(OWNERSHIP_ID, SPAWN_NONCE),
|
||||
ownershipId: OWNERSHIP_ID,
|
||||
reservationNonce: SPAWN_NONCE,
|
||||
spawnNonce: SPAWN_NONCE,
|
||||
tokenFilePath: spawnTokenPath(OWNERSHIP_ID, SPAWN_NONCE),
|
||||
lockMetadata: { ownershipId: OWNERSHIP_ID, spawnNonce: SPAWN_NONCE }
|
||||
})
|
||||
|
||||
// Capture the argv a remote shell would hand to python3, via a shim on PATH.
|
||||
const root = await mkdtemp(path.join(os.tmpdir(), 'hermes-argv-shim-'))
|
||||
try {
|
||||
const shimDir = path.join(root, 'shim')
|
||||
const fakeHome = path.join(root, 'home')
|
||||
await mkdir(shimDir)
|
||||
await mkdir(fakeHome)
|
||||
const argvFile = path.join(shimDir, 'argv')
|
||||
await writeFile(path.join(shimDir, 'python3'), `#!/bin/sh\nprintf '%s\\0' "$@" > '${argvFile}'\n`, { mode: 0o755 })
|
||||
await exec(cmd, {
|
||||
env: { ...process.env, PATH: `${shimDir}:${process.env.PATH}`, HOME: fakeHome }
|
||||
test.skipIf(process.platform === 'win32')(
|
||||
'buildSpawnCommand quotes expandRemotePath fragments exactly once (real sh parse)',
|
||||
async () => {
|
||||
// expandRemotePath() output is pre-quoted; a second shq() ships literal quote
|
||||
// characters to the remote python. Parse the composed command with a real sh,
|
||||
// as the remote login shell does, and require every path to come out clean.
|
||||
const cmd = buildSpawnCommand('/x/hermes', 'work', {
|
||||
hermesHome: '~/.hermes',
|
||||
logPath: spawnLogPath(OWNERSHIP_ID, SPAWN_NONCE),
|
||||
ownershipId: OWNERSHIP_ID,
|
||||
reservationNonce: SPAWN_NONCE,
|
||||
spawnNonce: SPAWN_NONCE,
|
||||
tokenFilePath: spawnTokenPath(OWNERSHIP_ID, SPAWN_NONCE),
|
||||
lockMetadata: { ownershipId: OWNERSHIP_ID, spawnNonce: SPAWN_NONCE }
|
||||
})
|
||||
const argv = (await readFile(argvFile, 'utf8')).split('\0')
|
||||
|
||||
// argv: ['-c', <mutex script>, <mutex path>, <payload>]
|
||||
assert.equal(
|
||||
argv[2],
|
||||
`${fakeHome}/.hermes/.hermes-update-in-progress.mutex`,
|
||||
'mutex path must reach python fully expanded, with no quote characters'
|
||||
)
|
||||
// Capture the argv a remote shell would hand to python3, via a shim on PATH.
|
||||
const root = await mkdtemp(path.join(os.tmpdir(), 'hermes-argv-shim-'))
|
||||
|
||||
// The payload assigns reservation/lock/owner_file before its mkdir loop.
|
||||
// Evaluate only that prefix the way the remote sh does; never the loop itself.
|
||||
const payload = argv[3]
|
||||
const loopStart = payload.indexOf('i=0;')
|
||||
assert.ok(loopStart > 0, 'payload prefix sentinel missing')
|
||||
const { stdout } = await exec(`${payload.slice(0, loopStart)} printf '%s\\n' "$reservation" "$lock" "$owner_file"`, {
|
||||
env: { ...process.env, HOME: fakeHome }
|
||||
})
|
||||
const [reservation, lock, ownerFile] = stdout.split('\n')
|
||||
const base = `${fakeHome}/.hermes/desktop-ssh/${OWNERSHIP_ID}`
|
||||
assert.equal(reservation, `${base}/.connect.lock`)
|
||||
assert.equal(lock, `${base}/backend.lock.json`)
|
||||
assert.equal(ownerFile, `${base}/.connect.lock/owner`)
|
||||
} finally {
|
||||
await rm(root, { recursive: true, force: true })
|
||||
try {
|
||||
const shimDir = path.join(root, 'shim')
|
||||
const fakeHome = path.join(root, 'home')
|
||||
await mkdir(shimDir)
|
||||
await mkdir(fakeHome)
|
||||
const argvFile = path.join(shimDir, 'argv')
|
||||
await writeFile(path.join(shimDir, 'python3'), `#!/bin/sh\nprintf '%s\\0' "$@" > '${argvFile}'\n`, {
|
||||
mode: 0o755
|
||||
})
|
||||
await exec(cmd, {
|
||||
env: { ...process.env, PATH: `${shimDir}:${process.env.PATH}`, HOME: fakeHome }
|
||||
})
|
||||
const argv = (await readFile(argvFile, 'utf8')).split('\0')
|
||||
|
||||
// argv: ['-c', <mutex script>, <mutex path>, <payload>]
|
||||
assert.equal(
|
||||
argv[2],
|
||||
`${fakeHome}/.hermes/.hermes-update-in-progress.mutex`,
|
||||
'mutex path must reach python fully expanded, with no quote characters'
|
||||
)
|
||||
|
||||
// The payload assigns reservation/lock/owner_file before its mkdir loop.
|
||||
// Evaluate only that prefix the way the remote sh does; never the loop itself.
|
||||
const payload = argv[3]
|
||||
const loopStart = payload.indexOf('i=0;')
|
||||
assert.ok(loopStart > 0, 'payload prefix sentinel missing')
|
||||
|
||||
const { stdout } = await exec(
|
||||
`${payload.slice(0, loopStart)} printf '%s\\n' "$reservation" "$lock" "$owner_file"`,
|
||||
{
|
||||
env: { ...process.env, HOME: fakeHome }
|
||||
}
|
||||
)
|
||||
|
||||
const [reservation, lock, ownerFile] = stdout.split('\n')
|
||||
const base = `${fakeHome}/.hermes/desktop-ssh/${OWNERSHIP_ID}`
|
||||
assert.equal(reservation, `${base}/.connect.lock`)
|
||||
assert.equal(lock, `${base}/backend.lock.json`)
|
||||
assert.equal(ownerFile, `${base}/.connect.lock/owner`)
|
||||
} finally {
|
||||
await rm(root, { recursive: true, force: true })
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
@@ -38,7 +38,10 @@ describe('statusbar hidden items', () => {
|
||||
})
|
||||
|
||||
it('surfaces the approval pill for installs that hid it under the v1 defaults, keeping their other choices', async () => {
|
||||
window.localStorage.setItem('hermes.desktop.statusbarHidden', JSON.stringify(['approval-mode', 'cron', 'gateway-health']))
|
||||
window.localStorage.setItem(
|
||||
'hermes.desktop.statusbarHidden',
|
||||
JSON.stringify(['approval-mode', 'cron', 'gateway-health'])
|
||||
)
|
||||
|
||||
const { $statusbarHiddenIds } = await loadStore()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user