CI / go-test (push) Canceled after 0s
CI / postgres-durable-first (push) Canceled after 0s
CI / codegen (push) Canceled after 0s
CI / govulncheck (push) Canceled after 0s
CI / race (push) Canceled after 0s
CI / fuzz-smoke (push) Canceled after 0s
CI / golangci (push) Canceled after 0s
CI / frontend (push) Canceled after 0s
CodeQL Advanced / Analyze (go) (push) Canceled after 0s
CodeQL Advanced / Analyze (actions) (push) Canceled after 0s
CodeQL Advanced / Analyze (javascript-typescript) (push) Canceled after 0s
Docs CI / build (push) Canceled after 0s
Docs Deploy (GitHub Pages) / build (push) Canceled after 0s
Release 3X-UI / build (386) (push) Canceled after 0s
Release 3X-UI / build (amd64) (push) Canceled after 0s
Release 3X-UI / build (arm64) (push) Canceled after 0s
Release 3X-UI / build (armv5) (push) Canceled after 0s
Release 3X-UI / build (armv6) (push) Canceled after 0s
Release 3X-UI / build (armv7) (push) Canceled after 0s
Release 3X-UI / build (s390x) (push) Canceled after 0s
Release 3X-UI / Build for Windows (amd64) (push) Canceled after 0s
Deploy Smoke Tests / noninteractive-install (ubuntu-24.04-arm) (push) Canceled after 0s
Deploy Smoke Tests / noninteractive-install (ubuntu-latest) (push) Canceled after 0s
Deploy Smoke Tests / release-tag-install (ubuntu-24.04-arm) (push) Canceled after 0s
Deploy Smoke Tests / release-tag-install (ubuntu-latest) (push) Canceled after 0s
Docs Deploy (GitHub Pages) / deploy (push) Canceled after 0s
Release 3X-UI / Publish rolling dev release (push) Canceled after 0s
44 lines
1.8 KiB
Go
44 lines
1.8 KiB
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
// TestHealShadowsocksClientMethods_RewritesRemovedCipher covers the last-gate
|
|
// build-time heal for xray-core v26.7.11's removed "none"/"plain" ciphers: a
|
|
// row that survives to config generation (restored backup, direct DB edit)
|
|
// must be rewritten to a supported cipher on both the inbound method and its
|
|
// clients so one such inbound cannot keep xray from starting.
|
|
func TestHealShadowsocksClientMethods_RewritesRemovedCipher(t *testing.T) {
|
|
settings := `{"method": "plain", "clients": [{"email": "a@x", "password": "p", "method": "plain"}]}`
|
|
healed, ok := HealShadowsocksClientMethods(settings)
|
|
if !ok {
|
|
t.Fatal("expected heal to report a change for a removed cipher")
|
|
}
|
|
var parsed struct {
|
|
Method string `json:"method"`
|
|
Clients []map[string]any `json:"clients"`
|
|
}
|
|
if err := json.Unmarshal([]byte(healed), &parsed); err != nil {
|
|
t.Fatalf("parse healed settings: %v", err)
|
|
}
|
|
if parsed.Method != "chacha20-ietf-poly1305" {
|
|
t.Fatalf("expected inbound method rewritten to a supported cipher, got %q", parsed.Method)
|
|
}
|
|
if parsed.Clients[0]["method"] != "chacha20-ietf-poly1305" {
|
|
t.Fatalf("expected client method to match the healed cipher, got %v", parsed.Clients[0]["method"])
|
|
}
|
|
}
|
|
|
|
func TestReplaceRemovedShadowsocksCipher(t *testing.T) {
|
|
for _, method := range []string{"none", "plain"} {
|
|
if got, removed := ReplaceRemovedShadowsocksCipher(method); !removed || got != "chacha20-ietf-poly1305" {
|
|
t.Fatalf("ReplaceRemovedShadowsocksCipher(%q) = (%q, %v), want a supported replacement", method, got, removed)
|
|
}
|
|
}
|
|
if got, removed := ReplaceRemovedShadowsocksCipher("aes-256-gcm"); removed || got != "aes-256-gcm" {
|
|
t.Fatalf("ReplaceRemovedShadowsocksCipher(aes-256-gcm) = (%q, %v), want it left untouched", got, removed)
|
|
}
|
|
}
|