跳到主要内容

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

浏览文件

storage_default_test.go

45 行 · 1.7 KB历史下载
1package cage
2
3import (
4 "os"
5 "path/filepath"
6 "testing"
7)
8
9func TestWindowsInitialDataDirectoryAndApplicationBoundary(t *testing.T) {
10 profile, root := newStorageFixture(t)
11 app := filepath.Join(root, "Cage")
12 backend := filepath.Join(app, "resources", "cage.exe")
13 writeStorageFixture(t, backend, []byte("backend"))
14 writeStorageFixture(t, filepath.Join(app, "Cage.exe"), []byte("launcher"))
15 if got := initialStorageDirectory(backend, "windows"); got != "" {
16 t.Fatalf("unmarked build default=%s", got)
17 }
18 writeStorageFixture(t, filepath.Join(app, "Cage.install-id"), []byte("io.github.lee-xeo.claude-cage"))
19 data := filepath.Join(app, "CageData")
20 if got := initialStorageDirectory(backend, "windows"); got != data {
21 t.Fatalf("default=%s want=%s", got, data)
22 }
23 for _, platform := range []string{"darwin", "linux"} {
24 if got := initialStorageDirectory(backend, platform); got != "" {
25 t.Fatalf("%s default changed to %s", platform, got)
26 }
27 }
28 if err := validateStorageTarget(profile, data, app, "windows"); err != nil {
29 t.Fatalf("reserved Windows data folder rejected: %v", err)
30 }
31 for _, target := range []string{app, filepath.Join(app, "resources", "data"), filepath.Join(app, "OtherData")} {
32 if err := validateStorageTarget(profile, target, app, "windows"); err == nil {
33 t.Fatalf("program boundary opened for %s", target)
34 }
35 }
36 if err := validateStorageTarget(profile, data, app, "darwin"); err == nil {
37 t.Fatal("Mac application directory allowed")
38 }
39 if err := os.Remove(filepath.Join(app, "Cage.install-id")); err != nil {
40 t.Fatal(err)
41 }
42 if err := validateStorageTarget(profile, data, app, "windows"); err == nil {
43 t.Fatal("unmarked installation allowed data inside app")
44 }
45}