跳到主要内容

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

浏览文件

windows_install_activation_test.go

52 行 · 1.8 KB历史下载
1package workbench
2
3import (
4 "os"
5 "path/filepath"
6 "strings"
7 "testing"
8
9 "github.com/google/uuid"
10 "github.com/sylvinus/agent-vm/internal/cage"
11 "github.com/sylvinus/agent-vm/internal/guestos"
12)
13
14func TestWindowsInstallationActivationRejectsDifferentGuest(t *testing.T) {
15 s := testServer(t)
16 install := guestos.Installation{Version: 1, ID: uuid.New(), System: guestos.Windows11}
17 state := filepath.Join(s.profile, "state")
18 if err := os.MkdirAll(state, 0700); err != nil {
19 t.Fatal(err)
20 }
21 state, err := cage.StoragePhysicalPath(state)
22 if err != nil {
23 t.Fatal(err)
24 }
25 binding := guestos.WindowsProfile{Version: 1, VMID: uuid.New(), GUIUserSID: "S-1-5-21-1-2-3-1001",
26 InstanceDirectory: filepath.Join(state, "windows-"+strings.ReplaceAll(install.ID.String(), "-", "")),
27 RelayExecutable: filepath.Join(s.profile, "relay.exe"), PairingFile: filepath.Join(s.profile, "pairing.bin")}
28 if err := guestos.BindWindowsProfile(s.profile, binding); err != nil {
29 t.Fatal(err)
30 }
31 receipt := filepath.Join(s.profile, "windows-install-vm.txt")
32 if err := os.WriteFile(receipt, []byte(binding.VMID.String()), 0600); err != nil {
33 t.Fatal(err)
34 }
35 owner, err := s.installedWindowsVMOwner(install)
36 if err != nil || owner != "windows/"+binding.VMID.String()+"/Running" {
37 t.Fatalf("completed installation was not admitted: %q %v", owner, err)
38 }
39 if err := os.WriteFile(receipt, []byte(uuid.New().String()), 0600); err != nil {
40 t.Fatal(err)
41 }
42 if _, err := s.installedWindowsVMOwner(install); err == nil {
43 t.Fatal("another VM's receipt permitted controller activation")
44 }
45 if err := os.WriteFile(receipt, []byte(binding.VMID.String()), 0600); err != nil {
46 t.Fatal(err)
47 }
48 install.ID = uuid.New()
49 if _, err := s.installedWindowsVMOwner(install); err == nil {
50 t.Fatal("another installation's disk permitted controller activation")
51 }
52}