返回 DeepSeek-Reasonix
types_security_test.go
根目录 / internal / installsource / types_security_test.go
1 package installsource
2
3 import (
4 "strings"
5 "testing"
6
7 "reasonix/internal/config"
8 )
9
10 func TestPublicActionsOmitCredentialBearingState(t *testing.T) {
11 public := publicActions([]action{{
12 Kind: "mcp", Action: "install_mcp_server", Status: "planned",
13 Env: map[string]string{"TOKEN": "env-secret"}, Headers: map[string]string{"Authorization": "header-secret"},
14 entry: config.PluginEntry{
15 Env: map[string]string{"PRIVATE": "entry-env-secret"},
16 Headers: map[string]string{"Authorization": "entry-header-secret"},
17 },
18 }})
19 raw := marshalJSON(response{OK: true, Actions: public})
20 for _, secret := range []string{
21 "env-secret", "header-secret", "entry-env-secret", "entry-header-secret", "\"env\"", "\"headers\"",
22 } {
23 if strings.Contains(raw, secret) {
24 t.Fatalf("public action contains credential-bearing data %q: %s", secret, raw)
25 }
26 }
27 }
28
28 lines GO