跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

platform_paths_test.go

57 行 · 2.3 KB历史下载
1package workbench
2
3import (
4 "encoding/json"
5 "github.com/sylvinus/agent-vm/internal/paths"
6 "testing"
7)
8
9func TestWindowsGuestPathsMatchVMSharePaths(t *testing.T) {
10 previous := paths.Windows
11 paths.Windows = func() bool { return true }
12 t.Cleanup(func() { paths.Windows = previous })
13 for _, path := range []string{`C:\Users\甲 用户\project`, "C:/Users/甲 用户/project"} {
14 if got := guestPath(path); got != "/c/Users/甲 用户/project" {
15 t.Fatalf("guestPath(%q) = %q", path, got)
16 }
17 }
18}
19
20func TestBoundaryProbeUsesGuestFilePaths(t *testing.T) {
21 previous := paths.Windows
22 t.Cleanup(func() { paths.Windows = previous })
23 for _, tc := range []struct {
24 name string
25 windows bool
26 private, shared, wantPrivate, wantShared string
27 }{
28 {"Windows backslashes and another drive", true, `C:\Users\甲 用户\Cage\private-probe`, `D:\项目 工作区\shared-probe`, "/c/Users/甲 用户/Cage/private-probe", "/d/项目 工作区/shared-probe"},
29 {"Windows forward slashes", true, "C:/Users/user/Cage/private-probe", "C:/Users/user/work/shared-probe", "/c/Users/user/Cage/private-probe", "/c/Users/user/work/shared-probe"},
30 {"POSIX", false, "/Users/user/Cage/private-probe", "/Users/user/work/shared-probe", "/Users/user/Cage/private-probe", "/Users/user/work/shared-probe"},
31 } {
32 t.Run(tc.name, func(t *testing.T) {
33 paths.Windows = func() bool { return tc.windows }
34 wire, err := json.Marshal(boundaryProbeInput(17777, "check-id", tc.private, tc.shared, "challenge"))
35 if err != nil {
36 t.Fatal(err)
37 }
38 var input struct {
39 Stage string `json:"stage"`
40 Port int `json:"control_port"`
41 Nonce string `json:"nonce"`
42 Private string `json:"private_file"`
43 Shared string `json:"shared_file"`
44 Challenge string `json:"challenge"`
45 }
46 if err := json.Unmarshal(wire, &input); err != nil {
47 t.Fatal(err)
48 }
49 if input.Private != tc.wantPrivate || input.Shared != tc.wantShared {
50 t.Fatalf("Linux file probe received host paths: private=%q shared=%q", input.Private, input.Shared)
51 }
52 if input.Stage != "boundary" || input.Port != 17777 || input.Nonce != "check-id" || input.Challenge != "challenge" {
53 t.Fatalf("path conversion changed the probe identity: %+v", input)
54 }
55 })
56 }
57}