From 2b63dd854878d2f24850b7ba4fe1c817e5ae735e Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 23 Sep 2026 20:39:56 +0300 Subject: [PATCH] =?UTF-8?q?test(golden):=20=D0=B7=D0=B0=D0=BA=D1=80=D1=8B?= =?UTF-8?q?=D1=82=D1=8C=20Linux=20capture=20=D0=B1=D0=B5=D0=B7=20=D0=B0?= =?UTF-8?q?=D1=82=D1=82=D0=B5=D1=81=D1=82=D0=B0=D1=86=D0=B8=D0=B8=20(#641)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Интеграционный тест запускает настоящий accept.mjs в канонической Linux-среде и подтверждает fail-closed отказ до записи эталонов. Issue: #641 User-Visible: no --- test/golden-capture-provenance.test.mjs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/test/golden-capture-provenance.test.mjs b/test/golden-capture-provenance.test.mjs index 7f19c5de..140f03cd 100644 --- a/test/golden-capture-provenance.test.mjs +++ b/test/golden-capture-provenance.test.mjs @@ -27,7 +27,9 @@ const ROOT = resolve(fileURLToPath(new URL('../', import.meta.url))); const BASELINES = resolve(ROOT, 'demo/golden/baselines'); /** Артефакт съёмки: кадры равны принятым эталонам, отчёт — с нужным провенансом. */ -function fixture({ platform = 'linux', schema = CAPTURE_PROVENANCE_SCHEMA, capture = undefined } = {}) { +function fixture({ + platform = 'linux', schema = CAPTURE_PROVENANCE_SCHEMA, capture = undefined, captureEnv = undefined, +} = {}) { const dir = mkdtempSync(resolve(tmpdir(), 'hp-golden-571-')); mkdirSync(resolve(dir, 'actual'), { recursive: true }); const index = JSON.parse(readFileSync(resolve(BASELINES, 'baselines-index.json'), 'utf8')); @@ -68,7 +70,7 @@ function fixture({ platform = 'linux', schema = CAPTURE_PROVENANCE_SCHEMA, captu ? { ...captureProvenance({ chromium: index.chromium, buildFingerprint: report.buildFingerprint, - env: { + env: captureEnv ?? { GITHUB_RUN_ID: '1', GITHUB_RUN_ATTEMPT: '1', GITHUB_REPOSITORY: 'Matysh/houseplan-card', GITHUB_SHA: 'a'.repeat(40), }, @@ -125,6 +127,19 @@ test('#571 AC1: артефакт Linux принимается, обе сторо rmSync(from, { recursive: true, force: true }); }); +test('#641: локальная Linux-съёмка без CI и WSL-аттестации отвергается до записи', { + skip: process.platform !== 'linux' && 'целевой guard исполняется в канонической Linux-среде приёмки', +}, () => { + const from = fixture({ platform: 'linux', captureEnv: {} }); + assert.equal(existsSync(resolve(from, 'wsl-attestation.json')), false, + 'обычный golden:capture не должен неявно получать WSL-аттестацию'); + const before = JSON.parse(readFileSync(resolve(BASELINES, 'baselines-index.json'), 'utf8')); + const { error, index } = accept(from, { reason: '', expectFailure: true }); + assert.match(error, /локальная Linux-съёмка не аттестована/); + assert.deepEqual(index, before, 'отказ обязан произойти до изменения эталонов и индекса'); + rmSync(from, { recursive: true, force: true }); +}); + test('#571 AC2: чужая среда съёмки без причины — отказ до записи', () => { const from = fixture({ platform: 'win32' }); const before = readFileSync(resolve(BASELINES, 'baselines-index.json'), 'utf8');