跳到主要内容

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

浏览文件

exit_samples_test.go

39 行 · 1.6 KB历史下载
1package workbench
2
3import (
4 "context"
5 "errors"
6 "strings"
7 "testing"
8)
9
10func TestIncompleteExitSamplesIdentifyRoutesAndRedactPrivateErrors(t *testing.T) {
11 good := networkObservation{Status: 200, IP: "8.8.8.8"}
12 message := incompleteExitSamples("", context.DeadlineExceeded, good, nil, networkObservation{}, errors.New("浏览器请求失败 https://user:[email protected]/secret token=private-token /Users/alice/project"))
13 for _, want := range []string{"宿主", "超时", "浏览器", "出口采样不完整"} {
14 if !strings.Contains(message, want) {
15 t.Fatalf("missing diagnostic %q: %s", want, message)
16 }
17 }
18 for _, unwanted := range []string{"虚拟机终端", "private.example", "private-token", "alice", "password"} {
19 if strings.Contains(message, unwanted) {
20 t.Fatalf("successful route or private data included: %s", message)
21 }
22 }
23 if message := incompleteExitSamples("8.8.8.8", nil, good, nil, good, nil); message != "" {
24 t.Fatal("complete samples reported missing", message)
25 }
26 for _, tc := range []struct {
27 observation networkObservation
28 want string
29 }{
30 {networkObservation{}, "没有收到检测通道的响应"},
31 {networkObservation{Status: 503}, "HTTP 503"},
32 {networkObservation{Status: 200}, "没有返回出口地址"},
33 } {
34 message := incompleteExitSamples("8.8.8.8", nil, tc.observation, nil, good, nil)
35 if !strings.Contains(message, "虚拟机终端:") || !strings.Contains(message, tc.want) || strings.Contains(message, "宿主:") || strings.Contains(message, "浏览器:") {
36 t.Fatalf("wrong route or failure category: %s", message)
37 }
38 }
39}