26 lines
1.1 KiB
JavaScript
26 lines
1.1 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import { mkdtempSync, writeFileSync } from 'node:fs'
|
|
import { tmpdir } from 'node:os'
|
|
import { join } from 'node:path'
|
|
import test from 'node:test'
|
|
import { assertWithinSize, missingSigningVariables, readPeMachine, REQUIRED_SIGNING_ENV } from './release-tools.mjs'
|
|
|
|
test('signing preflight reports every missing secret', () => {
|
|
assert.deepEqual(missingSigningVariables('windows', {}), REQUIRED_SIGNING_ENV.windows)
|
|
const env = Object.fromEntries(REQUIRED_SIGNING_ENV.macos.map(key => [key, 'configured']))
|
|
assert.deepEqual(missingSigningVariables('macos', env), [])
|
|
})
|
|
|
|
test('PE reader accepts x86_64 and rejects malformed files', () => {
|
|
const dir = mkdtempSync(join(tmpdir(), 'opsxshell-release-'))
|
|
const pe = Buffer.alloc(128)
|
|
pe.writeUInt16LE(0x5a4d, 0)
|
|
pe.writeUInt32LE(64, 0x3c)
|
|
pe.write('PE\0\0', 64, 'ascii')
|
|
pe.writeUInt16LE(0x8664, 68)
|
|
const path = join(dir, 'app.exe')
|
|
writeFileSync(path, pe)
|
|
assert.equal(readPeMachine(path), 0x8664)
|
|
assert.throws(() => assertWithinSize(path, 64), /limit is/)
|
|
})
|