@mycadet/assistant 0.13.0-dev.202610231952.fa65022 → 0.13.0-dev.202610241003.f9cbe80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
getCredentialMetadata,
|
|
34
34
|
} from "../tools/credentials/metadata-store.js";
|
|
35
35
|
import { storeCredentialValue } from "../tools/credentials/store.js";
|
|
36
|
+
import { useMemorySecureKeys } from "./helpers/secure-keys.js";
|
|
36
37
|
|
|
37
38
|
// Real metadata store backed by a temp file. A mock.module on metadata-store
|
|
38
39
|
// or secure-keys would replace the whole module namespace, so only the secure
|
|
@@ -69,6 +70,9 @@ beforeEach(() => {
|
|
|
69
70
|
}
|
|
70
71
|
mkdirSync(TEST_DIR, { recursive: true });
|
|
71
72
|
_setMetadataPath(META_PATH);
|
|
73
|
+
// Belt-and-suspenders vs the module spies: if a spy ever fails to
|
|
74
|
+
// intercept, seeded credentials land in a memory backend, not the vault.
|
|
75
|
+
useMemorySecureKeys();
|
|
72
76
|
|
|
73
77
|
secureStore = new Map();
|
|
74
78
|
writeSucceeds = true;
|
|
@@ -66,3 +66,21 @@ if (
|
|
|
66
66
|
`CADET_WORKSPACE_DIR resolves to ${resolvedWorkspace}, which is not under ${tmpRoot}`,
|
|
67
67
|
);
|
|
68
68
|
}
|
|
69
|
+
|
|
70
|
+
// The main preload also strands CES credential-RPC discovery: the socket dir
|
|
71
|
+
// must be set AND resolve under tmpdir (deleting the var is not enough —
|
|
72
|
+
// discovery falls back to the hardcoded /run/ces-bootstrap).
|
|
73
|
+
const cesSocketDir = process.env.CES_BOOTSTRAP_SOCKET_DIR?.trim();
|
|
74
|
+
if (!cesSocketDir) {
|
|
75
|
+
fail("CES_BOOTSTRAP_SOCKET_DIR is not set after main preload");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const resolvedCesSocket = canonicalize(cesSocketDir);
|
|
79
|
+
if (
|
|
80
|
+
resolvedCesSocket !== tmpRoot &&
|
|
81
|
+
!resolvedCesSocket.startsWith(tmpRoot + sep)
|
|
82
|
+
) {
|
|
83
|
+
fail(
|
|
84
|
+
`CES_BOOTSTRAP_SOCKET_DIR resolves to ${resolvedCesSocket}, which is not under ${tmpRoot}`,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
@@ -49,13 +49,17 @@ if (fixturesDir) {
|
|
|
49
49
|
cpSync(join(fixturesDir, "migrated"), testDir, { recursive: true });
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
// Prevent tests from routing credential
|
|
53
|
-
//
|
|
54
|
-
//
|
|
52
|
+
// Prevent tests from routing credential ops through the real CES. The HTTP
|
|
53
|
+
// failover arm dies with IS_CONTAINERIZED/CES_CREDENTIAL_URL; the RPC primary
|
|
54
|
+
// dies with a dead per-process socket dir — deleting the var is not enough,
|
|
55
|
+
// discovery falls back to the hardcoded /run/ces-bootstrap, which fronts the
|
|
56
|
+
// real vault on containerized dev machines.
|
|
55
57
|
const savedIsContainerized = process.env.IS_CONTAINERIZED;
|
|
56
58
|
const savedCesCredentialUrl = process.env.CES_CREDENTIAL_URL;
|
|
57
59
|
delete process.env.IS_CONTAINERIZED;
|
|
58
60
|
delete process.env.CES_CREDENTIAL_URL;
|
|
61
|
+
const savedCesBootstrapSocketDir = process.env.CES_BOOTSTRAP_SOCKET_DIR;
|
|
62
|
+
process.env.CES_BOOTSTRAP_SOCKET_DIR = join(tmpRoot, "ces-bootstrap-absent");
|
|
59
63
|
|
|
60
64
|
// A test runs daemon code in-process, so it acts as the main daemon for the
|
|
61
65
|
// event hub's publish routing (a non-daemon forwards publishes over IPC to a
|
|
@@ -91,6 +95,9 @@ afterAll(() => {
|
|
|
91
95
|
if (savedCesCredentialUrl !== undefined) {
|
|
92
96
|
process.env.CES_CREDENTIAL_URL = savedCesCredentialUrl;
|
|
93
97
|
}
|
|
98
|
+
if (savedCesBootstrapSocketDir !== undefined) {
|
|
99
|
+
process.env.CES_BOOTSTRAP_SOCKET_DIR = savedCesBootstrapSocketDir;
|
|
100
|
+
}
|
|
94
101
|
try {
|
|
95
102
|
rmSync(tmpRoot, { recursive: true, force: true });
|
|
96
103
|
} catch {
|
|
@@ -17,6 +17,8 @@ import { afterEach, beforeEach, describe, expect, mock, test } from "bun:test";
|
|
|
17
17
|
|
|
18
18
|
import { Command } from "commander";
|
|
19
19
|
|
|
20
|
+
import { useMemorySecureKeys } from "../../../__tests__/helpers/secure-keys.js";
|
|
21
|
+
|
|
20
22
|
// ---------------------------------------------------------------------------
|
|
21
23
|
// Mock state
|
|
22
24
|
// ---------------------------------------------------------------------------
|
|
@@ -68,6 +70,8 @@ let savedConversationId: string | undefined;
|
|
|
68
70
|
let savedSkillContextJson: string | undefined;
|
|
69
71
|
|
|
70
72
|
beforeEach(() => {
|
|
73
|
+
// Any stray direct secure-keys write lands in memory, not the vault.
|
|
74
|
+
useMemorySecureKeys();
|
|
71
75
|
mockSetSecureKeyViaDaemon = mock(() => Promise.resolve({ ok: true }));
|
|
72
76
|
mockDeleteSecureKeyViaDaemon = mock(
|
|
73
77
|
(): Promise<DeleteResultStub> => Promise.resolve({ result: "deleted" }),
|