Fix some tests and format code (#830)

* Increase some tls test timeout

* Fix TestUserValidator

* Change all tests to VMessAEAD

Old VMess MD5 tests will be rejected and fail in 2022

* Chore: auto format code
This commit is contained in:
yuhan6665 2021-12-14 19:28:47 -05:00 committed by GitHub
parent d5a7901601
commit e93da4bd02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
77 changed files with 137 additions and 234 deletions

View file

@ -2,6 +2,7 @@ package conf
import (
"encoding/json"
"github.com/golang/protobuf/proto"
"github.com/xtls/xray-core/common/serial"

View file

@ -209,8 +209,7 @@ func TestUserParsing(t *testing.T) {
common.Must(json.Unmarshal([]byte(`{
"id": "96edb838-6d68-42ef-a933-25f7ac3a9d09",
"email": "love@example.com",
"level": 1,
"alterId": 100
"level": 1
}`), user))
nUser := user.Build()

View file

@ -68,10 +68,10 @@ func (FakeDNSPostProcessingStage) Process(config *Config) error {
}
switch strings.ToLower(config.DNSConfig.QueryStrategy) {
case "useip4", "useipv4", "use_ip4", "use_ipv4", "use_ip_v4", "use-ip4", "use-ipv4", "use-ip-v4":
isIPv4Enable, isIPv6Enable = true, false
case "useip6", "useipv6", "use_ip6", "use_ipv6", "use_ip_v6", "use-ip6", "use-ipv6", "use-ip-v6":
isIPv4Enable, isIPv6Enable = false, true
case "useip4", "useipv4", "use_ip4", "use_ipv4", "use_ip_v4", "use-ip4", "use-ipv4", "use-ip-v4":
isIPv4Enable, isIPv6Enable = true, false
case "useip6", "useipv6", "use_ip6", "use_ipv6", "use_ip_v6", "use-ip6", "use-ipv6", "use-ip-v6":
isIPv4Enable, isIPv6Enable = false, true
}
}

View file

@ -47,8 +47,7 @@ func TestVMessOutbound(t *testing.T) {
Email: "love@example.com",
Level: 255,
Account: serial.ToTypedMessage(&vmess.Account{
Id: "e641f5ad-9397-41e3-bf1a-e8740dfed019",
AlterId: 0,
Id: "e641f5ad-9397-41e3-bf1a-e8740dfed019",
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_AUTO,
},
@ -74,14 +73,12 @@ func TestVMessInbound(t *testing.T) {
{
"id": "27848739-7e62-4138-9fd3-098a63964b6b",
"level": 0,
"alterId": 16,
"email": "love@example.com",
"security": "aes-128-gcm"
}
],
"default": {
"level": 0,
"alterId": 32
"level": 0
},
"detour": {
"to": "tag_to_detour"
@ -95,8 +92,7 @@ func TestVMessInbound(t *testing.T) {
Level: 0,
Email: "love@example.com",
Account: serial.ToTypedMessage(&vmess.Account{
Id: "27848739-7e62-4138-9fd3-098a63964b6b",
AlterId: 16,
Id: "27848739-7e62-4138-9fd3-098a63964b6b",
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_AES128_GCM,
},
@ -104,8 +100,7 @@ func TestVMessInbound(t *testing.T) {
},
},
Default: &inbound.DefaultConfig{
Level: 0,
AlterId: 32,
Level: 0,
},
Detour: &inbound.DetourConfig{
To: "tag_to_detour",

View file

@ -11,9 +11,8 @@ import (
"github.com/xtls/xray-core/app/proxyman"
"github.com/xtls/xray-core/app/stats"
"github.com/xtls/xray-core/common/serial"
"github.com/xtls/xray-core/transport/internet"
core "github.com/xtls/xray-core/core"
"github.com/xtls/xray-core/transport/internet"
"github.com/xtls/xray-core/transport/internet/xtls"
)

View file

@ -72,7 +72,6 @@ func TestXrayConfig(t *testing.T) {
"settings": {
"clients": [
{
"alterId": 100,
"security": "aes-128-gcm",
"id": "0cdf8a45-303d-4fed-9780-29aa7f54175e"
}
@ -102,7 +101,6 @@ func TestXrayConfig(t *testing.T) {
"settings": {
"clients": [
{
"alterId": 100,
"security": "aes-128-gcm",
"id": "0cdf8a45-303d-4fed-9780-29aa7f54175e"
}
@ -266,8 +264,7 @@ func TestXrayConfig(t *testing.T) {
{
Level: 0,
Account: serial.ToTypedMessage(&vmess.Account{
Id: "0cdf8a45-303d-4fed-9780-29aa7f54175e",
AlterId: 100,
Id: "0cdf8a45-303d-4fed-9780-29aa7f54175e",
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_AES128_GCM,
},
@ -322,8 +319,7 @@ func TestXrayConfig(t *testing.T) {
{
Level: 0,
Account: serial.ToTypedMessage(&vmess.Account{
Id: "0cdf8a45-303d-4fed-9780-29aa7f54175e",
AlterId: 100,
Id: "0cdf8a45-303d-4fed-9780-29aa7f54175e",
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_AES128_GCM,
},