@exagone313/dsh-podman 1.0.2 → 1.0.4

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.
Files changed (91) hide show
  1. package/dist/generated/version.d.ts +2 -2
  2. package/dist/generated/version.js +2 -2
  3. package/docs/architecture.md +13 -4
  4. package/docs/architecture.zh.md +7 -2
  5. package/docs/development.md +8 -4
  6. package/docs/development.zh.md +7 -4
  7. package/package.json +3 -1
  8. package/dist/approval-reasons.test.d.ts +0 -1
  9. package/dist/approval-reasons.test.js +0 -143
  10. package/dist/approval.test.d.ts +0 -1
  11. package/dist/approval.test.js +0 -593
  12. package/dist/card-route.test.d.ts +0 -1
  13. package/dist/card-route.test.js +0 -223
  14. package/dist/card-test-support.d.ts +0 -15
  15. package/dist/card-test-support.js +0 -133
  16. package/dist/container-env.test.d.ts +0 -1
  17. package/dist/container-env.test.js +0 -93
  18. package/dist/containers.test.d.ts +0 -1
  19. package/dist/containers.test.js +0 -621
  20. package/dist/daemons.test.d.ts +0 -1
  21. package/dist/daemons.test.js +0 -167
  22. package/dist/dsh-version.test.d.ts +0 -1
  23. package/dist/dsh-version.test.js +0 -25
  24. package/dist/env-rows.test.d.ts +0 -1
  25. package/dist/env-rows.test.js +0 -43
  26. package/dist/fs-provider.test.d.ts +0 -1
  27. package/dist/fs-provider.test.js +0 -301
  28. package/dist/guest-rpc.test.d.ts +0 -1
  29. package/dist/guest-rpc.test.js +0 -241
  30. package/dist/images.test.d.ts +0 -1
  31. package/dist/images.test.js +0 -86
  32. package/dist/locales.test.d.ts +0 -1
  33. package/dist/locales.test.js +0 -34
  34. package/dist/misc.test.d.ts +0 -1
  35. package/dist/misc.test.js +0 -169
  36. package/dist/mounts.test.d.ts +0 -1
  37. package/dist/mounts.test.js +0 -478
  38. package/dist/naming.test.d.ts +0 -1
  39. package/dist/naming.test.js +0 -28
  40. package/dist/package-deps.test.d.ts +0 -1
  41. package/dist/package-deps.test.js +0 -49
  42. package/dist/paths.test.d.ts +0 -1
  43. package/dist/paths.test.js +0 -76
  44. package/dist/plugin-meta.test.d.ts +0 -1
  45. package/dist/plugin-meta.test.js +0 -29
  46. package/dist/project-path.test.d.ts +0 -1
  47. package/dist/project-path.test.js +0 -66
  48. package/dist/read-only-shell.test.d.ts +0 -1
  49. package/dist/read-only-shell.test.js +0 -182
  50. package/dist/runtime-client.test.d.ts +0 -1
  51. package/dist/runtime-client.test.js +0 -53
  52. package/dist/secrets.test.d.ts +0 -1
  53. package/dist/secrets.test.js +0 -196
  54. package/dist/settings-commands.test.d.ts +0 -1
  55. package/dist/settings-commands.test.js +0 -596
  56. package/dist/settings-create.test.d.ts +0 -1
  57. package/dist/settings-create.test.js +0 -416
  58. package/dist/settings-default-env.test.d.ts +0 -1
  59. package/dist/settings-default-env.test.js +0 -175
  60. package/dist/settings-mounts.test.d.ts +0 -1
  61. package/dist/settings-mounts.test.js +0 -506
  62. package/dist/settings-paths.test.d.ts +0 -1
  63. package/dist/settings-paths.test.js +0 -65
  64. package/dist/settings-schema.test.d.ts +0 -1
  65. package/dist/settings-schema.test.js +0 -35
  66. package/dist/settings-workspaces.test.d.ts +0 -1
  67. package/dist/settings-workspaces.test.js +0 -240
  68. package/dist/spill-store.test.d.ts +0 -1
  69. package/dist/spill-store.test.js +0 -82
  70. package/dist/subprocess.test.d.ts +0 -1
  71. package/dist/subprocess.test.js +0 -344
  72. package/dist/terminal-preference.test.d.ts +0 -1
  73. package/dist/terminal-preference.test.js +0 -62
  74. package/dist/terminal-route.test.d.ts +0 -1
  75. package/dist/terminal-route.test.js +0 -265
  76. package/dist/terminal-tab.test.d.ts +0 -1
  77. package/dist/terminal-tab.test.js +0 -58
  78. package/dist/terminal-targets.test.d.ts +0 -1
  79. package/dist/terminal-targets.test.js +0 -43
  80. package/dist/terminal-titles.test.d.ts +0 -1
  81. package/dist/terminal-titles.test.js +0 -36
  82. package/dist/test-support.d.ts +0 -358
  83. package/dist/test-support.js +0 -499
  84. package/dist/version-compat.test.d.ts +0 -1
  85. package/dist/version-compat.test.js +0 -27
  86. package/dist/views.test.d.ts +0 -1
  87. package/dist/views.test.js +0 -23
  88. package/dist/volumes.test.d.ts +0 -1
  89. package/dist/volumes.test.js +0 -40
  90. package/dist/workspace-binding.test.d.ts +0 -1
  91. package/dist/workspace-binding.test.js +0 -523
@@ -1,29 +0,0 @@
1
- // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
2
- //
3
- // SPDX-License-Identifier: MIT
4
- import test from "node:test";
5
- import assert from "node:assert/strict";
6
- import { readFileSync } from "node:fs";
7
- // The display name the Plugins page shows comes from the package's exported
8
- // locale metadata. Without the `exports` entry the Host cannot resolve the
9
- // file, and without the `files` entry a packed install has no file to resolve:
10
- // both fall back silently to the scoped package name, so both are asserted.
11
- function localeMeta(language) {
12
- return JSON.parse(readFileSync(new URL(`../locale/${language}.json`, import.meta.url), "utf8"));
13
- }
14
- function manifest() {
15
- return JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
16
- }
17
- test("the locale metadata declares the plugin's display name", () => {
18
- for (const language of ["en", "zh"]) {
19
- const meta = localeMeta(language).meta;
20
- assert.equal(meta.title, "dsh-podman", `${language}: meta.title`);
21
- assert.equal(typeof meta.description, "string", `${language}: meta.description must be a string`);
22
- assert.notEqual(meta.description.trim(), "", `${language}: meta.description must not be empty`);
23
- }
24
- });
25
- test("the locale metadata is exported and shipped", () => {
26
- const pkg = manifest();
27
- assert.equal(pkg.exports["./locale/*.json"], "./locale/*.json", "package.json must export the locale metadata");
28
- assert.ok(pkg.files.includes("locale/*.json"), "package.json files must ship locale/*.json");
29
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,66 +0,0 @@
1
- // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
2
- //
3
- // SPDX-License-Identifier: MIT
4
- import test from "node:test";
5
- import assert from "node:assert/strict";
6
- import { confineToRoot, crumbLabel, hostPathForProjectName, parentDirectory, projectNameFromHostPath, rootCrumbs, } from "./project-path.js";
7
- test("projectNameFromHostPath maps a host directory to a project path", () => {
8
- assert.equal(projectNameFromHostPath("/projects", "/projects/web"), "web");
9
- assert.equal(projectNameFromHostPath("/projects", "/projects/group/web"), "group/web");
10
- assert.equal(projectNameFromHostPath("/projects/", "/projects/web/"), "web", "trailing slashes are ignored");
11
- });
12
- test("projectNameFromHostPath refuses anything outside the projects root", () => {
13
- assert.equal(projectNameFromHostPath("/projects", "/projects"), undefined);
14
- assert.equal(projectNameFromHostPath("/projects", "/projects/"), undefined);
15
- assert.equal(projectNameFromHostPath("/projects", "/projects2/web"), undefined);
16
- assert.equal(projectNameFromHostPath("/projects", "/etc/hosts"), undefined);
17
- assert.equal(projectNameFromHostPath("/projects", "web"), undefined);
18
- assert.equal(projectNameFromHostPath("/projects", ""), undefined);
19
- assert.equal(projectNameFromHostPath("", "/projects/web"), undefined);
20
- });
21
- test("hostPathForProjectName is the inverse", () => {
22
- assert.equal(hostPathForProjectName("/projects", "web"), "/projects/web");
23
- assert.equal(hostPathForProjectName("/projects", "group/web"), "/projects/group/web");
24
- assert.equal(hostPathForProjectName("/projects", ""), "/projects");
25
- assert.equal(hostPathForProjectName("/projects", "/web"), "/projects/web");
26
- });
27
- test("confineToRoot clamps a directory to the projects root", () => {
28
- assert.equal(confineToRoot("/projects", "/projects/web"), "/projects/web");
29
- assert.equal(confineToRoot("/projects", "/projects"), "/projects");
30
- assert.equal(confineToRoot("/projects", "/etc"), "/projects");
31
- assert.equal(confineToRoot("/projects", ""), "/projects");
32
- assert.equal(confineToRoot("/projects", "/projects/web/"), "/projects/web", "trailing slashes are ignored");
33
- });
34
- test("project paths resolve their dots and never escape the root", () => {
35
- // A ".." that stays inside the root is resolved.
36
- assert.equal(confineToRoot("/projects", "/projects/a/../b"), "/projects/b");
37
- assert.equal(hostPathForProjectName("/projects", "a/../b"), "/projects/b");
38
- // A ".." that would climb above the root clamps to the root, on both the
39
- // path-building and the path-clamping helper.
40
- assert.equal(confineToRoot("/projects", "/projects/../etc"), "/projects");
41
- assert.equal(confineToRoot("/projects", "/projects/a/../../etc"), "/projects");
42
- assert.equal(hostPathForProjectName("/projects", "../etc"), "/projects");
43
- assert.equal(hostPathForProjectName("/projects", "a/../../etc"), "/projects");
44
- assert.equal(hostPathForProjectName("/projects", "/../etc"), "/projects");
45
- // A "." segment is dropped, not kept as a directory name.
46
- assert.equal(hostPathForProjectName("/projects", "./web"), "/projects/web");
47
- });
48
- test("parentDirectory never climbs above the projects root", () => {
49
- assert.equal(parentDirectory("/projects", "/projects/web/sub"), "/projects/web");
50
- assert.equal(parentDirectory("/projects", "/projects/web"), "/projects");
51
- assert.equal(parentDirectory("/projects", "/projects"), "/projects");
52
- assert.equal(parentDirectory("/projects", "/elsewhere"), "/projects");
53
- });
54
- test("rootCrumbs lists the root-relative ancestry", () => {
55
- assert.deepEqual(rootCrumbs("/projects", "/projects/group/web"), [
56
- "/projects/group",
57
- "/projects/group/web",
58
- ]);
59
- assert.deepEqual(rootCrumbs("/projects", "/projects"), []);
60
- assert.deepEqual(rootCrumbs("/projects", "/etc"), [], "a path outside the root has no crumbs");
61
- });
62
- test("crumbLabel is the last segment", () => {
63
- assert.equal(crumbLabel("/projects/group/web"), "web");
64
- assert.equal(crumbLabel("/projects/group/web/"), "web");
65
- assert.equal(crumbLabel("/projects"), "projects");
66
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,182 +0,0 @@
1
- // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
2
- //
3
- // SPDX-License-Identifier: MIT
4
- import test from "node:test";
5
- import assert from "node:assert/strict";
6
- import { createReadOnlyShellGate, READ_ONLY_GATED_TOOLS, REMOUNT_TOOL_NAME, } from "./index.js";
7
- import { WORKSPACE_ID } from "./test-support.js";
8
- const EXEC = {
9
- name: "bash",
10
- arguments: {},
11
- agent: { session: { header: { cwd: "/proj" } } },
12
- };
13
- // A resolver whose control plane reports one container with the given mounts,
14
- // recording every control call; the gate's approval is recorded by reason.
15
- function gateFixture(mounts, options = {}) {
16
- const controlCalls = [];
17
- const approvals = [];
18
- const containerName = options.containerName ?? "default";
19
- const resolver = {
20
- registry: { resolveByPath: async () => ({ id: WORKSPACE_ID }) },
21
- getConfig: () => ({ projectsRoot: "/projects" }),
22
- async control(method, request) {
23
- controlCalls.push([method, request]);
24
- if (method === "listContainers") {
25
- return mounts === undefined ? { containers: [] } : {
26
- containers: [
27
- {
28
- workspaceSlug: WORKSPACE_ID,
29
- containerName,
30
- mounts,
31
- },
32
- ],
33
- };
34
- }
35
- return {};
36
- },
37
- };
38
- const gate = createReadOnlyShellGate({
39
- resolver,
40
- approve: async (_exec, reason) => {
41
- approvals.push(reason);
42
- return options.approve ?? true;
43
- },
44
- });
45
- return { gate, controlCalls, approvals };
46
- }
47
- test("the gate ignores tools outside its set", async () => {
48
- const { gate, controlCalls } = gateFixture([]);
49
- assert.equal(await gate({ ...EXEC, name: "image_list" }, "en"), undefined);
50
- assert.equal(await gate({ ...EXEC, name: "container_read" }, "en"), undefined);
51
- assert.deepEqual(controlCalls, []);
52
- });
53
- test("the gate covers the shell, file, and daemon tools", () => {
54
- assert.deepEqual([...READ_ONLY_GATED_TOOLS].sort(), [
55
- "bash",
56
- "container_bash",
57
- "container_edit",
58
- "container_exec",
59
- "container_write",
60
- "daemon_start",
61
- "edit",
62
- "pwsh",
63
- "write",
64
- ]);
65
- assert.equal(REMOUNT_TOOL_NAME, "dsh_podman_builtin_remount_read_only");
66
- });
67
- test("all mounts read-only allows the tool without a prompt", async () => {
68
- const { gate, controlCalls, approvals } = gateFixture([
69
- {
70
- projectName: "team",
71
- kind: "MOUNT_KIND_PROJECT",
72
- mode: "MOUNT_MODE_READ_ONLY",
73
- },
74
- {
75
- kind: "MOUNT_KIND_TMPFS",
76
- destination: "/scratch",
77
- mode: "MOUNT_MODE_READ_WRITE",
78
- },
79
- {
80
- kind: "MOUNT_KIND_SECRET",
81
- secret: "tls",
82
- destination: "/run/secrets/tls",
83
- },
84
- ]);
85
- assert.deepEqual(await gate(EXEC, "en"), { kind: "allow" });
86
- assert.deepEqual(approvals, []);
87
- assert.equal(controlCalls.filter(([method]) => method === "recreateContainer").length, 0);
88
- });
89
- test("a read-write mount prompts and then remounts read-only", async () => {
90
- const { gate, controlCalls, approvals } = gateFixture([
91
- {
92
- projectName: "team",
93
- kind: "MOUNT_KIND_PROJECT",
94
- mode: "MOUNT_MODE_READ_WRITE",
95
- },
96
- {
97
- kind: "MOUNT_KIND_VOLUME",
98
- volume: "data",
99
- destination: "/data",
100
- mode: "MOUNT_MODE_READ_WRITE",
101
- },
102
- {
103
- kind: "MOUNT_KIND_TMPFS",
104
- destination: "/scratch",
105
- mode: "MOUNT_MODE_READ_WRITE",
106
- },
107
- {
108
- kind: "MOUNT_KIND_SECRET",
109
- secret: "tls",
110
- destination: "/run/secrets/tls",
111
- },
112
- ]);
113
- assert.deepEqual(await gate(EXEC, "en"), { kind: "allow" });
114
- assert.equal(approvals.length, 1);
115
- assert.match(approvals[0], /Read-only mode blocks "bash"/);
116
- assert.match(approvals[0], /- project "team" \(read-write\)/);
117
- assert.match(approvals[0], /- volume "data" at "\/data" \(read-write\)/);
118
- assert.match(approvals[0], /Kept as-is: tmpfs at "\/scratch"/);
119
- const recreate = controlCalls.filter(([method]) => method === "recreateContainer");
120
- assert.equal(recreate.length, 1);
121
- assert.deepEqual(recreate[0][1], {
122
- workspaceSlug: WORKSPACE_ID,
123
- container: "default",
124
- mounts: [
125
- {
126
- projectName: "team",
127
- kind: "MOUNT_KIND_PROJECT",
128
- mode: "MOUNT_MODE_READ_ONLY",
129
- },
130
- {
131
- projectName: "",
132
- kind: "MOUNT_KIND_VOLUME",
133
- mode: "MOUNT_MODE_READ_ONLY",
134
- destination: "/data",
135
- volume: "data",
136
- },
137
- {
138
- projectName: "",
139
- kind: "MOUNT_KIND_TMPFS",
140
- mode: "MOUNT_MODE_READ_WRITE",
141
- destination: "/scratch",
142
- },
143
- {
144
- projectName: "",
145
- kind: "MOUNT_KIND_SECRET",
146
- destination: "/run/secrets/tls",
147
- secret: "tls",
148
- },
149
- ],
150
- });
151
- });
152
- test("a declined prompt denies without remounting", async () => {
153
- const { gate, controlCalls, approvals } = gateFixture([{
154
- projectName: "team",
155
- kind: "MOUNT_KIND_PROJECT",
156
- mode: "MOUNT_MODE_READ_WRITE",
157
- }], { approve: false });
158
- const decision = (await gate(EXEC, "en"));
159
- assert.equal(decision.kind, "deny");
160
- assert.match(decision.reason, /mounts were not remounted/);
161
- assert.equal(approvals.length, 1);
162
- assert.equal(controlCalls.filter(([method]) => method === "recreateContainer").length, 0);
163
- });
164
- test("an unreadable container falls through to the plain denial", async () => {
165
- const { gate, approvals } = gateFixture(undefined);
166
- assert.equal(await gate(EXEC, "en"), undefined);
167
- assert.deepEqual(approvals, []);
168
- });
169
- test("a plugin tool targets its own container", async () => {
170
- const { gate, controlCalls } = gateFixture([{
171
- projectName: "team",
172
- kind: "MOUNT_KIND_PROJECT",
173
- mode: "MOUNT_MODE_READ_ONLY",
174
- }], { containerName: "web" });
175
- const exec = {
176
- name: "container_bash",
177
- arguments: { container: "web" },
178
- agent: { session: { header: { cwd: "/proj" } } },
179
- };
180
- assert.deepEqual(await gate(exec, "en"), { kind: "allow" });
181
- assert.equal(controlCalls[0][0], "listContainers");
182
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,53 +0,0 @@
1
- // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
2
- //
3
- // SPDX-License-Identifier: MIT
4
- import test from "node:test";
5
- import assert from "node:assert/strict";
6
- import { abortError, closeClients, controlClient, guestClient, unary, } from "./grpc/runtime-client.js";
7
- test("clients are reused per socket and a close drops the cache", () => {
8
- const first = controlClient("/run/dsh-podman/orchestrator.sock");
9
- const second = controlClient("/run/dsh-podman/orchestrator.sock");
10
- assert.equal(second, first, "the same socket must reuse one channel");
11
- assert.notEqual(controlClient("/tmp/other.sock"), first, "a different socket gets its own channel");
12
- const guest = guestClient("/run/dsh-podman/w/guest.sock");
13
- closeClients();
14
- assert.notEqual(controlClient("/run/dsh-podman/orchestrator.sock"), first, "a disposed client is not served from the cache");
15
- assert.notEqual(guestClient("/run/dsh-podman/w/guest.sock"), guest);
16
- closeClients();
17
- });
18
- test("unary rejects a pre-aborted call without invoking the client", async () => {
19
- const controller = new AbortController();
20
- controller.abort();
21
- let called = false;
22
- const client = {
23
- method: () => {
24
- called = true;
25
- },
26
- };
27
- await assert.rejects(() => unary(client, "method", {}, undefined, controller.signal), (error) => error.code === "ABORTED");
28
- assert.equal(called, false);
29
- });
30
- test("unary cancels a pending call when the signal aborts", async () => {
31
- const controller = new AbortController();
32
- let cancelled = false;
33
- let settle;
34
- const client = {
35
- method: (_request, _metadata, callback) => {
36
- settle = callback;
37
- return {
38
- cancel: () => {
39
- cancelled = true;
40
- // grpc-js settles a cancelled call with a CANCELLED status.
41
- settle?.(Object.assign(new Error("cancelled"), { code: 1 }));
42
- },
43
- };
44
- },
45
- };
46
- const pending = unary(client, "method", {}, undefined, controller.signal);
47
- controller.abort();
48
- await assert.rejects(pending, (error) => error.code === "ABORTED");
49
- assert.equal(cancelled, true);
50
- });
51
- test("abortError carries a stable code", () => {
52
- assert.equal(abortError("exec").code, "ABORTED");
53
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,196 +0,0 @@
1
- // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
2
- //
3
- // SPDX-License-Identifier: MIT
4
- import test from "node:test";
5
- import assert from "node:assert/strict";
6
- import { MOUNT_EXEC, mountRequestRecorder, SECRET_TOOLS, WORKSPACE_ID, } from "./test-support.js";
7
- import { READ_ONLY_TOOLS, toolHandlers, TOOLS } from "./index.js";
8
- test("secret tools are registered with the expected schemas", () => {
9
- assert.ok(READ_ONLY_TOOLS.has("secret_list"), "secret_list must be read-only");
10
- const listTool = TOOLS.find((entry) => entry.name === "secret_list");
11
- assert.ok(listTool, "secret_list registered");
12
- assert.notEqual(listTool.approval, true, "secret_list must not require approval");
13
- assert.deepEqual(listTool.parameters.required, []);
14
- const createTool = TOOLS.find((entry) => entry.name === "secret_create");
15
- assert.ok(createTool, "secret_create registered");
16
- assert.notEqual(createTool.approval, true, "secret_create must not require approval");
17
- assert.deepEqual(createTool.parameters.required, ["name"]);
18
- assert.equal(createTool.parameters.properties.length.type, "integer");
19
- assert.equal(createTool.parameters.properties.length.minimum, 1);
20
- assert.deepEqual(createTool.parameters.properties.charset.enum, [
21
- "alphanumeric",
22
- "hex",
23
- "base64url",
24
- ]);
25
- const removeTool = TOOLS.find((entry) => entry.name === "secret_remove");
26
- assert.ok(removeTool, "secret_remove registered");
27
- assert.equal(removeTool.approval, true, "secret_remove must require approval");
28
- assert.deepEqual(removeTool.parameters.required, ["name"]);
29
- const addTool = TOOLS.find((entry) => entry.name === "container_secret_add");
30
- assert.ok(addTool, "container_secret_add registered");
31
- assert.equal(addTool.approval, true, "container_secret_add must require approval");
32
- assert.deepEqual(addTool.parameters.required, [
33
- "container",
34
- "env",
35
- "secret",
36
- ]);
37
- assert.equal(addTool.parameters.properties.secret.type, "string");
38
- assert.equal(addTool.parameters.properties.env.type, "string");
39
- const removeEnvTool = TOOLS.find((entry) => entry.name === "container_secret_remove");
40
- assert.ok(removeEnvTool, "container_secret_remove registered");
41
- assert.equal(removeEnvTool.approval, true, "container_secret_remove must require approval");
42
- assert.deepEqual(removeEnvTool.parameters.required, ["container", "env"]);
43
- for (const name of SECRET_TOOLS) {
44
- const tool = TOOLS.find((entry) => entry.name === name);
45
- assert.ok(tool, `${name} registered`);
46
- assert.equal(tool.parameters.type, "object", `${name} type`);
47
- assert.equal(typeof tool.parameters.properties, "object");
48
- assert.ok(Array.isArray(tool.parameters.required));
49
- }
50
- });
51
- test("secret mount kinds forward the secret to the orchestrator", async () => {
52
- const requests = [];
53
- const resolver = {
54
- registry: {
55
- resolveByPath: async () => ({ id: WORKSPACE_ID }),
56
- },
57
- getConfig: () => ({ projectsRoot: "/projects" }),
58
- async control(method, request) {
59
- if (method === "addContainerMount" || method === "removeContainerMount") {
60
- requests.push(request);
61
- }
62
- return {};
63
- },
64
- };
65
- const exec = { agent: { session: { header: { cwd: "/proj" } } } };
66
- await toolHandlers.container_mount_add(resolver, {
67
- container: "valkey-ctr",
68
- kind: "secret",
69
- secret: "valkey-tls",
70
- destination: "/run/secrets/tls",
71
- }, exec);
72
- await toolHandlers.container_mount_remove(resolver, {
73
- container: "valkey-ctr",
74
- kind: "secret",
75
- secret: "valkey-tls",
76
- }, exec);
77
- assert.deepEqual(requests[0], {
78
- workspaceSlug: WORKSPACE_ID,
79
- container: "valkey-ctr",
80
- kind: "MOUNT_KIND_SECRET",
81
- secret: "valkey-tls",
82
- destination: "/run/secrets/tls",
83
- });
84
- assert.deepEqual(requests[1], {
85
- workspaceSlug: WORKSPACE_ID,
86
- container: "valkey-ctr",
87
- kind: "MOUNT_KIND_SECRET",
88
- secret: "valkey-tls",
89
- });
90
- });
91
- test("mount tools reject a read-write secret mount", async () => {
92
- const { requests, resolver } = mountRequestRecorder();
93
- await assert.rejects(() => toolHandlers.container_mount_add(resolver, {
94
- container: "web",
95
- kind: "secret",
96
- secret: "tls",
97
- destination: "/run/secrets/tls",
98
- mode: "read_write",
99
- }, MOUNT_EXEC), /secret mounts are read-only/);
100
- await assert.rejects(() => toolHandlers.container_start(resolver, {
101
- container: "web",
102
- image: "img1",
103
- mounts: [{
104
- kind: "secret",
105
- secret: "tls",
106
- destination: "/run/secrets/tls",
107
- mode: "read_write",
108
- }],
109
- }, MOUNT_EXEC), /secret mounts are read-only/);
110
- assert.deepEqual(requests, [], "a rejected mount must not reach the orchestrator");
111
- });
112
- test("container_list returns secretEnv maps on container rows", async () => {
113
- const resolver = {
114
- registry: {
115
- resolveByPath: async () => ({ id: WORKSPACE_ID }),
116
- },
117
- control: async (method) => {
118
- if (method === "listContainers") {
119
- return {
120
- containers: [
121
- {
122
- workspaceSlug: WORKSPACE_ID,
123
- containerName: "default",
124
- status: "running",
125
- imageId: "img-1",
126
- secretEnv: { REDIS_PASSWORD: "db-pass" },
127
- },
128
- {
129
- workspaceSlug: WORKSPACE_ID,
130
- containerName: "db",
131
- status: "running",
132
- secretEnv: {
133
- A: "a",
134
- B: "b",
135
- C: "c",
136
- D: "d",
137
- E: "e",
138
- F: "f",
139
- G: "g",
140
- H: "h",
141
- I: "i",
142
- J: "j",
143
- },
144
- },
145
- {
146
- workspaceSlug: WORKSPACE_ID,
147
- containerName: "worker",
148
- status: "stopped",
149
- },
150
- ],
151
- };
152
- }
153
- return {};
154
- },
155
- };
156
- const exec = { agent: { session: { header: { cwd: "/proj" } } } };
157
- const out = (await toolHandlers.container_list(resolver, {}, exec));
158
- assert.deepEqual(out, [
159
- {
160
- containerName: "default",
161
- status: "running",
162
- imageId: "img-1",
163
- mounts: [],
164
- paths: [],
165
- env: {},
166
- secretEnv: { REDIS_PASSWORD: "db-pass" },
167
- },
168
- {
169
- containerName: "db",
170
- status: "running",
171
- mounts: [],
172
- paths: [],
173
- env: {},
174
- secretEnv: {
175
- A: "a",
176
- B: "b",
177
- C: "c",
178
- D: "d",
179
- E: "e",
180
- F: "f",
181
- G: "g",
182
- H: "h",
183
- I: "i",
184
- J: "j",
185
- },
186
- },
187
- {
188
- containerName: "worker",
189
- status: "stopped",
190
- mounts: [],
191
- paths: [],
192
- env: {},
193
- secretEnv: {},
194
- },
195
- ]);
196
- });
@@ -1 +0,0 @@
1
- export {};