continuous-integration/drone Build is failing
Migrate the workspace to React and Ant Design, improve account forms and responsive layouts, support outbound diagnostics and SSH fingerprint confirmation, and persist the management startup port. Preserve database migrations, remove S3 settings storage, and improve gateway audit handling.
44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
package store
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
|
|
"linkport/internal/model"
|
|
)
|
|
|
|
func TestRedactBundleClearsSingBoxOutboundJSON(t *testing.T) {
|
|
bundle := RedactBundle(Bundle{Version: 2, Outbounds: []model.OutboundProfile{{
|
|
ID: "sing-box", Name: "route", Outbound: model.Outbound{
|
|
Mode: "sing-box", SingBoxType: "vless", SingBoxOutbound: `{"type":"vless","password":"private"}`,
|
|
},
|
|
}}})
|
|
if got := bundle.Outbounds[0].Outbound.SingBoxOutbound; got != "" {
|
|
t.Fatalf("sing-box JSON was not redacted: %q", got)
|
|
}
|
|
}
|
|
|
|
func TestConfigDiffTreatsSingBoxOutboundAsSecret(t *testing.T) {
|
|
before := map[string]any{"outbound": map[string]any{
|
|
"mode": "sing-box",
|
|
"singBoxOutbound": `{"type":"vless","password":"old-private-value"}`,
|
|
}}
|
|
after := map[string]any{"outbound": map[string]any{
|
|
"mode": "sing-box",
|
|
"singBoxOutbound": `{"type":"vless","password":"new-private-value"}`,
|
|
}}
|
|
|
|
changes := compareConfig(before, after)
|
|
if len(changes) != 1 || !changes[0].SecretChanged || changes[0].Before != nil || changes[0].After != nil {
|
|
t.Fatalf("sing-box diff was not redacted: %+v", changes)
|
|
}
|
|
raw, err := json.Marshal(changes)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if strings.Contains(string(raw), "private-value") {
|
|
t.Fatalf("sing-box diff leaked outbound JSON: %s", raw)
|
|
}
|
|
}
|