Skip to content

Commit 35a9c69

Browse files
fix(cloud-connection): keep the binding credential under OS_HOME so a container recreate does not unbind the node (#31708)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9Le5aumc4yG69U5cTLGJxTM)_ Fixes #31604 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:单节点的云绑定凭据文件 `cloud-connection.json` 改为跟随 `OS_HOME`(设置时放 `OS_HOME/cloud-connection.json`,未设置时路径不变);首次启动把旧的工作目录文件搬过去一次。 - 为什么改:容器里工作目录在镜像层,重建容器(compose recreate、升级换镜像)会丢掉绑定,在线授权的节点立刻掉回 Community,直到有人重新绑定。 - 风险与回滚:只动文件位置与一次性搬迁;两边都有时以 `OS_HOME` 的为准、旧文件原样保留;显式 `credentialPath` 优先级不变;多副本共享存储未改。回滚即 revert 本 PR(已搬走的文件需手动搬回工作目录)。 - 先看:`packages/cloud-connection/src/connection-credential-store.ts`(解析与 `moveLegacyFile`)、`cloud-connection-plugin.ts` 的 `moveLegacyCredentialFile`、`local-manifest-source.ts` 的 `readOsHome`。 - 两分钟验证:`pnpm --filter @objectstack/cloud-connection exec vitest run src/connection-credential-store.test.ts -t OS_HOME`,预期 6 个用例全绿。 - 需要你做的:无,席位落地。 ## What changes - **One `OS_HOME` reading.** `readOsHome()` in `local-manifest-source.ts` is the reading the install ledger already used (#30217), extracted so the ledger resolver and the new credential resolver share it; the ledger's answers are unchanged (its suites are green on this head). - **Credential path.** `resolveConnectionCredentialPath()` answers `OS_HOME/cloud-connection.json` when `OS_HOME` is set, and `CWD/.objectstack/cloud-connection.json` (unchanged) when it is not. `os start` in project mode sets `OS_HOME` to `CWD/.objectstack`, so its file does not move. An explicit `credentialPath` keeps its precedence and moves nothing. - **Migration on boot.** `CloudConnectionPlugin.init()` calls `ConnectionCredentialStore.moveLegacyFile()` before choosing the ledger: when the old working-directory file exists and the `OS_HOME` file does not, the bytes are written 0600 to a sibling staging file, renamed into place (works across the image layer and the data volume, where a plain rename cannot), and only then is the old file removed. One `info` line names both paths and never the credential. Both present: the `OS_HOME` file is the binding and the old file is left untouched. A failed move is reported once at `error` with the consequence and the fix. - **`os dev --fresh`.** Under the ephemeral home the run announces, the credential stays inside that home and the project's file is neither moved nor read. - **Not touched:** the multi-replica shared store (`connection-credential-ledger.ts`, `connection-credential-preboot.ts`, `sys-cloud-binding-credential.object.ts`). Its scale-out adoption reads the same store object, so it now adopts from the `OS_HOME` file, after the move has run. - Docs: `content/docs/deployment/cloud-connection.mdx` states the new location and the upgrade behaviour. Changeset: patch for `@objectstack/cloud-connection`. ## Why The shipped image runs with `OS_HOME=/data` on a volume, but the credential resolved to the working directory inside the container layer. A restart kept it; a recreate lost it, and the exchange then answered "not bound". ## Tests New top-level `describe` in `connection-credential-store.test.ts` (six cases): default store under `OS_HOME` and a bind writes there 0600; old file moved once (0600, one log line, nothing left behind, second boot silent); both present, new wins and old untouched; control with `OS_HOME` unset; `os dev --fresh` keeps it in the ephemeral home; explicit `credentialPath` precedence. No existing test was edited. ## Acceptance notes - Seat review amended ruling 3 for prose only: the header comments of `connection-credential-ledger.ts` and `sys-cloud-binding-credential.object.ts` now say the single-node file follows `OS_HOME` and point at `resolveConnectionCredentialPath` (comment lines only, no code line in either file). - `local-manifest-source.ts` is outside the claim's declared file surface; the seat accepted the `readOsHome` extraction as the one parser ruling 1 asked for. ## Verification Head `de5b1aa9`: the review round's comment-only commit on top of `d6663391` (merge of `origin/main` `cd43416f` into fix `dd1ef0a6`), measured in a card container. On `de5b1aa9`: package typecheck + Tests 1114 passed (1114); 99 derived gates all run, all exit 0, `--ran` 0 NOT-MEASURED 0 UNRUN; lint exit 0. The readings below are from `d6663391` unless they say otherwise. <details><summary>Red on main: 4 of 6 new pins fail on 5d1382a source</summary> The three source files restored from `5d1382a5`, the new tests kept: `Tests 4 failed | 17 passed (21)`. The four OS_HOME cases fail (e.g. `expected '/tmp/ccs-…/project/.objectstack/…' to be '/tmp/ccs-…/home/cloud-connection…'`; both-present: `expected 'oscc_legacy' to be 'oscc_home'`). The control (OS_HOME unset) and the explicit-path case pass on main, as they should. </details> <details><summary>Ablation: six legs, each red, each restored (scripts/ablation-replace.mjs)</summary> Tests import the source directly (no dist leg). Each leg: mutation landed (anchor count 1 to 0, blob changed), run red, restore proved by blob == HEAD and an empty `git diff HEAD`. - A1 drop the "new file exists" guard in `moveLegacyFile`: red `keeps the OS_HOME file when both exist…` - A2 drop the ephemeral-home exclusion in the resolver: red `os dev --fresh…` - A3 drop the removal of the old file: red `moves the working-directory file…` (`expected true to be false`) - A4 stage the moved file 0644: red `moves the working-directory file…` - A5 give an explicit path a legacy path: red `an explicit credentialPath keeps its precedence…` - A6 drop the plugin's boot move: red `moves the working-directory file…` A3 and A6 were first sent as empty replacements, which the tool refused before mutating (replacement count did not rise); re-run with `--delete`. </details> <details><summary>Package and gates on d666339</summary> - `pnpm --filter @objectstack/cloud-connection typecheck` then `vitest run --maxWorkers=2`: Test Files 80 passed (80), Tests 1114 passed (1114); lock VERDICT command-exit 0. - Full `pnpm build` after the merge: 119/119 tasks; VERDICT command-exit 0. - `node scripts/pm/dispatch-gates.mjs --commands`: 99 derived; all 99 run on this head, all exit 0. `--ran`: 99 derived, 99 run, 0 NOT-MEASURED, 0 UNRUN. - `eslint --no-inline-config packages/cloud-connection/src`: exit 0. `check-nul-bytes`: exit 0. - `test:repo` and the dogfood battery are left to CI (no narrowing arm, no `!`). </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmS9T6n1TQU1WRxmFdb)_ <!-- signed: domain:server#2 · os-steve · session_01ADHkmQKZzp4DLtqiCkZZRM --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9feb925 commit 35a9c69

8 files changed

Lines changed: 376 additions & 38 deletions
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@objectstack/cloud-connection': patch
3+
---
4+
5+
fix(cloud-connection): keep a single node's cloud binding credential under `OS_HOME`, so recreating the container does not disconnect it
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
A self-hosted server kept its cloud binding credential in `.objectstack/cloud-connection.json` under its working directory, even with `OS_HOME` set. In a container the working directory is the image's own layer, so a restart kept the connection but a recreate (a compose recreate, an image upgrade) lost it: the server read as not connected and an online licence fell back to Community until someone connected it again.
11+
12+
- **Where it lives now.** With `OS_HOME` set, the file is `OS_HOME/cloud-connection.json`, beside the rest of the instance's state. With `OS_HOME` unset it stays at `.objectstack/cloud-connection.json` under the working directory, as before. The `credentialPath` option still wins over both.
13+
- **Upgrading.** The first start with `OS_HOME` set moves the old working-directory file into `OS_HOME`, keeps mode `0600`, and logs both paths once. When a file is already in `OS_HOME`, that one is the connection and the old file is left untouched. Nothing to do by hand.
14+
- **`os dev --fresh`.** The connection stays inside the run's temporary home, and the project's file is neither moved nor read.
15+
- Several replicas declared over the Redis cluster driver still keep the credential in the shared database row; the file the first scaled-out start moves into that row is now the `OS_HOME` one.

‎content/docs/deployment/cloud-connection.mdx‎

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,13 @@ server, not by your browser: the code request, the polling, the connection
6969
itself and the disconnect. The server needs outbound HTTPS to the control-plane
7070
URL. Your browser only opens the approval link.
7171

72-
**The server's working directory is persistent.** The connection is stored in
73-
a file under the server's working directory,
74-
`.objectstack/cloud-connection.json` (see
75-
[What the server stores](#what-the-server-stores)). In the official runtime
76-
image the working directory is `/srv/app`. If that directory lives on the
77-
container's own filesystem, replacing the container loses the connection, and
72+
**The server's home is persistent.** The connection is stored in one file,
73+
`cloud-connection.json` in the server's home directory (`OS_HOME`), or
74+
`.objectstack/cloud-connection.json` under the working directory when
75+
`OS_HOME` is not set (see [What the server stores](#what-the-server-stores)).
76+
Point `OS_HOME` at a persistent volume, as the rest of the server's state
77+
already requires: if the file lives on the container's own filesystem,
78+
replacing the container (not just restarting it) loses the connection, and
7879
the server reads as not connected until you connect it again.
7980

8081
**The right people on each side.**
@@ -157,8 +158,17 @@ simply expires.
157158

158159
## What the server stores [#what-the-server-stores]
159160

160-
The connection lives in one file, `.objectstack/cloud-connection.json` under
161-
the server's working directory, written with mode `0600`:
161+
The connection lives in one file, written with mode `0600`:
162+
`OS_HOME/cloud-connection.json` when `OS_HOME` is set, otherwise
163+
`.objectstack/cloud-connection.json` under the server's working directory.
164+
165+
**Upgrading from a release that kept it under the working directory.** On the
166+
first start with `OS_HOME` set, the server moves
167+
`.objectstack/cloud-connection.json` from its working directory into
168+
`OS_HOME`, keeps mode `0600`, and logs both paths once. If a file is already in
169+
`OS_HOME`, that one is the connection and the old file is left untouched. A
170+
server started with `os dev --fresh` keeps its connection inside that run's
171+
temporary home and never moves the project's file.
162172

163173
| Field | What it is |
164174
|:---|:---|
@@ -207,8 +217,8 @@ every replica reads:
207217
If the read fails, the replica starts as an unconnected one would.
208218

209219
**Scaling out a server that is already connected.** The first start with
210-
several replicas declared moves the credential from
211-
`.objectstack/cloud-connection.json` into the row, when the row is still
220+
several replicas declared moves the credential from the server's
221+
connection file into the row, when the row is still
212222
empty, and logs where it moved it from. The file stays where it was but is
213223
not read again while replicas are declared. Scaling back to a single replica
214224
reads the file again, and the file does not follow connects or disconnects
@@ -263,8 +273,8 @@ What disconnecting **keeps**:
263273

264274
- **The runtime id.** Connecting again sends it along, so the cloud can attach
265275
the new connection to the same registration rather than a new one. To start
266-
over as a brand-new server, delete `.objectstack/cloud-connection.json`
267-
after disconnecting.
276+
over as a brand-new server, delete the connection file
277+
([What the server stores](#what-the-server-stores)) after disconnecting.
268278
- **Everything installed.** Disconnecting touches only the connection file.
269279
Packages already installed into this server stay installed and keep working.
270280

‎packages/cloud-connection/src/cloud-connection-plugin.ts‎

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,11 @@ export interface CloudConnectionPluginConfig {
346346
singleEnvironment?: boolean;
347347
/**
348348
* Override the on-disk credential store location. Defaults to
349-
* `<cwd>/.objectstack/cloud-connection.json` — where the bind flow
350-
* persists the `oscc_…` runtime bearer for self-hosted runtimes.
349+
* `<OS_HOME>/cloud-connection.json`, or `<cwd>/.objectstack/cloud-connection.json`
350+
* when `OS_HOME` is unset — where the bind flow persists the `oscc_…`
351+
* runtime bearer for self-hosted runtimes. The default moves a file an
352+
* earlier release left under the working directory once, at boot; an
353+
* explicit path moves nothing.
351354
*
352355
* A single node only: with several replicas declared over the Redis cluster
353356
* driver the credential lives in the shared database row instead
@@ -428,9 +431,44 @@ export class CloudConnectionPlugin implements Plugin {
428431
init = async (ctx: PluginContext): Promise<void> => {
429432
ctx.registerService?.(CLOUD_BINDING_SERVICE, this.binding);
430433
ctx.registerService?.(CLOUD_BINDING_CREDENTIAL_SERVICE, this.credentialReader);
434+
this.moveLegacyCredentialFile(ctx);
431435
this.ledger = this.chooseLedger(ctx);
432436
};
433437

438+
/**
439+
* A single node's credential file follows `OS_HOME`
440+
* (`resolveConnectionCredentialPath`); a release before that wrote it under
441+
* the working directory. Move that file once, before anything reads the
442+
* binding — the shared row's adoption at `kernel:ready` included — so the
443+
* node stays bound across the upgrade. An explicit `credentialPath` moves
444+
* nothing.
445+
*
446+
* A failed move is a consistency failure, not a choice: the binding is on
447+
* disk where this node no longer reads it, so the node reports itself
448+
* unbound and an online licence falls back to Community while everything
449+
* else looks healthy. It is reported once, at `error`, with the fix.
450+
*/
451+
private moveLegacyCredentialFile(ctx: PluginContext): void {
452+
const from = this.store.legacyPath;
453+
try {
454+
const moved = this.store.moveLegacyFile();
455+
if (moved) {
456+
ctx.logger?.info?.(
457+
`[CloudConnectionPlugin] moved the cloud binding credential from ${moved.from} to ${moved.to}: `
458+
+ 'the file now follows OS_HOME, so it survives a container recreate',
459+
);
460+
}
461+
} catch (err) {
462+
this.reportError(
463+
ctx,
464+
`[CloudConnectionPlugin] the cloud binding credential in ${from} could not be moved to ${this.store.path}, `
465+
+ 'where this node now reads it, so the node reports itself unbound and an online licence falls back to '
466+
+ 'Community. Move the file there by hand (mode 0600) and restart, or connect again (Setup, Cloud Connection): '
467+
+ `${err instanceof Error ? err.message : String(err)}`,
468+
);
469+
}
470+
}
471+
434472
/** Stops the shared row's re-read. */
435473
destroy = async (): Promise<void> => {
436474
this.stopSharedRefresh();

‎packages/cloud-connection/src/connection-credential-ledger.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
*
77
* Two homes, chosen once per boot by `CloudConnectionPlugin.init()`:
88
*
9-
* - **A single node** keeps the credential in its local file,
10-
* `<cwd>/.objectstack/cloud-connection.json`, through
9+
* - **A single node** keeps the credential in its local file, which
10+
* follows `OS_HOME`: `<OS_HOME>/cloud-connection.json`, or
11+
* `<cwd>/.objectstack/cloud-connection.json` when `OS_HOME` is unset
12+
* (`resolveConnectionCredentialPath`), through
1113
* {@link ConnectionCredentialStore}, exactly as before this module existed:
1214
* {@link fileCredentialLedger} is a pass-through, so the path, the bytes
13-
* and the 0600 mode do not move.
15+
* and the 0600 mode are the store's own.
1416
* - **Several replicas** — declared (`OS_CLUSTER_REPLICAS` > 1 or
1517
* `OS_EXPECT_MULTI_NODE=true`) AND served by the Redis cluster driver — keep
1618
* it in the one `sys_cloud_binding_credential` row of the database every

‎packages/cloud-connection/src/connection-credential-store.test.ts‎

Lines changed: 141 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
14-
import { existsSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
14+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
1515
import { join } from 'node:path';
1616
import { tmpdir } from 'node:os';
1717
import { ConnectionCredentialStore } from './connection-credential-store.js';
@@ -398,3 +398,143 @@ describe('[#31554] a single node keeps the binding credential in its file', () =
398398
expect(existsSync(credPath)).toBe(true);
399399
});
400400
});
401+
402+
/**
403+
* A single node's credential file follows `OS_HOME`, the home the rest of the
404+
* instance's state follows (the default database, the uploads root, the
405+
* install ledger). Under the working directory it sat in the container's own
406+
* layer, so recreating the container — not restarting it — lost the binding
407+
* and an online-licensed node fell back to Community until someone bound it
408+
* again. With `OS_HOME` on the data volume the file now outlives the container.
409+
*/
410+
describe('a single node keeps the binding credential under OS_HOME', () => {
411+
let home: string;
412+
let project: string;
413+
let legacyPath: string;
414+
let homePath: string;
415+
beforeEach(() => {
416+
home = join(dir, 'home');
417+
project = join(dir, 'project');
418+
mkdirSync(project, { recursive: true });
419+
legacyPath = join(project, '.objectstack', 'cloud-connection.json');
420+
homePath = join(home, 'cloud-connection.json');
421+
vi.spyOn(process, 'cwd').mockReturnValue(project);
422+
vi.stubEnv('OS_HOME', home);
423+
vi.stubEnv('OS_INTERNAL_FRESH_HOME', undefined);
424+
});
425+
afterEach(() => { vi.unstubAllEnvs(); vi.restoreAllMocks(); });
426+
427+
/** A plugin on the default credential path, booted the way the kernel boots it. */
428+
async function boot(config: Record<string, unknown> = {}) {
429+
const rawApp = makeRawApp();
430+
const registered = new Map<string, unknown>();
431+
const { ctx, fire } = makeCtx(rawApp, { auth: sessionAuth('admin'), manifest: { register: vi.fn() } });
432+
(ctx as any).registerService = (name: string, svc: unknown) => registered.set(name, svc);
433+
const plugin = new CloudConnectionPlugin({ singleEnvironment: true, environmentId: 'env_1', controlPlaneUrl: 'http://cloud.test', ...config });
434+
await plugin.init(ctx as any);
435+
await plugin.start(ctx as any);
436+
await fire();
437+
const reader = registered.get(CLOUD_BINDING_CREDENTIAL_SERVICE) as CloudBindingCredentialReader;
438+
return { rawApp, info: ctx.logger.info, error: ctx.logger.error, reader };
439+
}
440+
441+
async function bind(rawApp: ReturnType<typeof makeRawApp>) {
442+
vi.stubGlobal('fetch', vi.fn(async (url: any) => {
443+
const u = String(url);
444+
if (u.includes('/auth/device/token')) return new Response(JSON.stringify({ access_token: 'op-token' }), { status: 200 });
445+
if (u.includes('/cloud-connection/bind')) {
446+
return new Response(JSON.stringify({ success: true, data: { bound: true, runtime_id: 'rt-1', runtime_token: 'oscc_minted', connection: { organization_id: 'org_x' } } }), { status: 200 });
447+
}
448+
throw new Error(`unexpected fetch ${u}`);
449+
}));
450+
const res = await rawApp.routes.get('POST /api/v1/cloud-connection/bind/poll')!(makeC('http://localhost:3000/x', { device_code: 'dc' }));
451+
expect(res.payload.success).toBe(true);
452+
}
453+
454+
function writeLegacy(token: string) {
455+
new ConnectionCredentialStore(legacyPath).write({ runtimeToken: token, runtimeId: 'rt-old', environmentId: 'env_1' });
456+
return readFileSync(legacyPath, 'utf8');
457+
}
458+
459+
function movedLines(info: ReturnType<typeof vi.fn>) {
460+
return info.mock.calls.map(([m]) => String(m)).filter((m) => m.includes(legacyPath));
461+
}
462+
463+
it('resolves the default store under OS_HOME, and a bind writes the credential there, 0600', async () => {
464+
expect(new ConnectionCredentialStore().path).toBe(homePath);
465+
const { rawApp, reader } = await boot();
466+
await bind(rawApp);
467+
expect(new ConnectionCredentialStore(homePath).read()?.runtimeToken).toBe('oscc_minted');
468+
expect(statSync(homePath).mode & 0o777).toBe(0o600);
469+
expect(existsSync(legacyPath)).toBe(false);
470+
expect(reader.read()?.runtimeToken).toBe('oscc_minted');
471+
});
472+
473+
it('moves the working-directory file an earlier release wrote, once: 0600, one log line, nothing left behind', async () => {
474+
const bytes = writeLegacy('oscc_legacy');
475+
const first = await boot();
476+
expect(readFileSync(homePath, 'utf8')).toBe(bytes);
477+
expect(statSync(homePath).mode & 0o777).toBe(0o600);
478+
expect(existsSync(legacyPath)).toBe(false);
479+
expect(first.reader.read()?.runtimeToken).toBe('oscc_legacy');
480+
const lines = movedLines(first.info);
481+
expect(lines).toHaveLength(1);
482+
expect(lines[0]).toContain(homePath);
483+
expect(lines[0]).not.toContain('oscc_legacy');
484+
expect(first.error).not.toHaveBeenCalled();
485+
486+
// The next boot has nothing to move and says nothing about it.
487+
const second = await boot();
488+
expect(movedLines(second.info)).toHaveLength(0);
489+
expect(readFileSync(homePath, 'utf8')).toBe(bytes);
490+
expect(second.reader.read()?.runtimeToken).toBe('oscc_legacy');
491+
});
492+
493+
it('keeps the OS_HOME file when both exist, and leaves the working-directory file untouched', async () => {
494+
const legacyBytes = writeLegacy('oscc_legacy');
495+
new ConnectionCredentialStore(homePath).write({ runtimeToken: 'oscc_home', runtimeId: 'rt-home' });
496+
const homeBytes = readFileSync(homePath, 'utf8');
497+
const { info, reader } = await boot();
498+
expect(reader.read()?.runtimeToken).toBe('oscc_home');
499+
expect(readFileSync(homePath, 'utf8')).toBe(homeBytes);
500+
expect(readFileSync(legacyPath, 'utf8')).toBe(legacyBytes);
501+
expect(statSync(legacyPath).mode & 0o777).toBe(0o600);
502+
expect(movedLines(info)).toHaveLength(0);
503+
});
504+
505+
it('control: with OS_HOME unset the file stays where it always was, and nothing moves', async () => {
506+
vi.stubEnv('OS_HOME', undefined);
507+
expect(new ConnectionCredentialStore().path).toBe(legacyPath);
508+
const bytes = writeLegacy('oscc_legacy');
509+
const { info, reader } = await boot();
510+
expect(readFileSync(legacyPath, 'utf8')).toBe(bytes);
511+
expect(existsSync(homePath)).toBe(false);
512+
expect(reader.read()?.runtimeToken).toBe('oscc_legacy');
513+
expect(movedLines(info)).toHaveLength(0);
514+
});
515+
516+
it('`os dev --fresh`: the credential stays inside the ephemeral home, and the project file is neither moved nor read', async () => {
517+
vi.stubEnv('OS_INTERNAL_FRESH_HOME', home);
518+
const bytes = writeLegacy('oscc_legacy');
519+
expect(new ConnectionCredentialStore().path).toBe(homePath);
520+
const { rawApp, info, reader } = await boot();
521+
expect(reader.read()).toBeNull();
522+
expect(existsSync(homePath)).toBe(false);
523+
expect(movedLines(info)).toHaveLength(0);
524+
await bind(rawApp);
525+
expect(new ConnectionCredentialStore(homePath).read()?.runtimeToken).toBe('oscc_minted');
526+
expect(readFileSync(legacyPath, 'utf8')).toBe(bytes);
527+
});
528+
529+
it('an explicit `credentialPath` keeps its precedence over OS_HOME, and moves nothing into it', async () => {
530+
const explicit = join(dir, 'srv', 'cloud-connection.json');
531+
const bytes = writeLegacy('oscc_legacy');
532+
const { rawApp, info } = await boot({ credentialPath: explicit });
533+
expect(existsSync(explicit)).toBe(false);
534+
expect(movedLines(info)).toHaveLength(0);
535+
await bind(rawApp);
536+
expect(new ConnectionCredentialStore(explicit).read()?.runtimeToken).toBe('oscc_minted');
537+
expect(existsSync(homePath)).toBe(false);
538+
expect(readFileSync(legacyPath, 'utf8')).toBe(bytes);
539+
});
540+
});

0 commit comments

Comments
 (0)