Skip to content

Commit 753bec1

Browse files
committed
test(cli): the one-shot family pin declares its own OS_SECRET_KEY
Test Core (4/6) failed the file in beforeAll: the served boot composes SettingsServicePlugin, whose LocalCryptoProvider refuses to start in production without a key, and a CI runner has no persisted $HOME/.objectstack/dev-crypto-key. The file now sets a fresh key for its whole run and restores the variable afterwards, the convention orphans.driver-contract.test.ts already follows. Claude-Session: https://claude.ai/code/session_01VvcEokUG1tvVxkceYfR5XB Co-authored-by: Claude <noreply@anthropic.com>
1 parent 11d48f0 commit 753bec1

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎packages/cli/src/utils/schema-migrate.one-shot-family.integration.test.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
import { describe, it, expect, beforeAll, afterAll, beforeEach, afterEach, vi } from 'vitest';
4040
import { copyFileSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
41+
import { randomBytes } from 'node:crypto';
4142
import { tmpdir } from 'node:os';
4243
import { dirname, join, relative, resolve } from 'node:path';
4344
import { fileURLToPath } from 'node:url';
@@ -389,12 +390,21 @@ function prepareCase(argv: string[], opts: { absent?: boolean } = {}): { dbFile:
389390
}
390391

391392
beforeAll(async () => {
392-
for (const key of [...OVERRIDING_ENV, 'OS_ARTIFACT_PATH', 'NODE_ENV', 'OS_LIFECYCLE_DISABLED'] as const) {
393+
for (const key of [...OVERRIDING_ENV, 'OS_ARTIFACT_PATH', 'NODE_ENV', 'OS_LIFECYCLE_DISABLED', 'OS_SECRET_KEY'] as const) {
393394
savedEnv[key] = process.env[key];
394395
}
395396
for (const key of OVERRIDING_ENV) delete process.env[key];
396397
delete process.env.OS_LIFECYCLE_DISABLED;
397398
process.env.NODE_ENV = 'production';
399+
// The key this production-posture file needs — the served boot and every
400+
// command that composes `SettingsServicePlugin` (`secret orphans`, and the
401+
// storage arm of `files-to-references` / `storage orphans`) construct a
402+
// `LocalCryptoProvider`, which refuses to start in production without one.
403+
// Declared here rather than inherited from a persisted
404+
// `$HOME/.objectstack/dev-crypto-key` (#16491): one fresh value for the
405+
// whole file, so every boot in it decrypts what the others wrote, and never
406+
// written to disk.
407+
process.env.OS_SECRET_KEY = randomBytes(32).toString('hex');
398408

399409
dir = mkdtempSync(join(tmpdir(), 'os-21391-'));
400410
mkdirSync(join(dir, 'dist'), { recursive: true });

0 commit comments

Comments
 (0)