跳到主要内容

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

浏览文件

proxy_gate_test.go

45 行 · 1.4 KB历史下载
1package main
2
3import (
4 "os"
5 "path/filepath"
6 "testing"
7
8 "github.com/google/uuid"
9 "github.com/sylvinus/agent-vm/internal/cage"
10 "github.com/sylvinus/agent-vm/internal/guestos"
11)
12
13func TestProxyChangeClosesBoundWindowsGate(t *testing.T) {
14 profile := t.TempDir()
15 instance := t.TempDir()
16 binding := guestos.WindowsProfile{Version: 1, VMID: uuid.New(), GUIUserSID: "S-1-5-21-1-2-3-1001", InstanceDirectory: instance, RelayExecutable: filepath.Join(profile, "relay.exe"), PairingFile: filepath.Join(profile, "pairing.bin")}
17 if err := guestos.BindWindowsProfile(profile, binding); err != nil {
18 t.Fatal(err)
19 }
20 gate, err := cage.NewEgressGate(cage.DefaultConfig())
21 if err != nil {
22 t.Fatal(err)
23 }
24 stop, err := cage.StartGateControl(filepath.Join(profile, "config.json"), instance, gate)
25 if err != nil {
26 t.Fatal(err)
27 }
28 defer stop()
29 if err := closeManagedGates(profile); err != nil {
30 t.Fatal(err)
31 }
32 if gate.Status().Mode != cage.GateClosed || gate.Status().Reason != "代理核心停止或重启,等待重新检测" {
33 t.Fatal("CLI proxy lifecycle missed the bound Windows gate")
34 }
35}
36
37func TestProxyChangeRejectsMalformedWindowsBinding(t *testing.T) {
38 profile := t.TempDir()
39 if err := os.WriteFile(guestos.WindowsProfilePath(profile), []byte(`{"version":1}`), 0600); err != nil {
40 t.Fatal(err)
41 }
42 if err := closeManagedGates(profile); err == nil {
43 t.Fatal("proxy mutation ignored an invalid native guest binding")
44 }
45}