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

@ -181,8 +181,7 @@ func TestCommanderAddRemoveUser(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: u1.String(),
AlterId: 64,
Id: u1.String(),
}),
},
},
@ -248,8 +247,7 @@ func TestCommanderAddRemoveUser(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: u2.String(),
AlterId: 64,
Id: u2.String(),
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_AES128_GCM,
},
@ -285,8 +283,7 @@ func TestCommanderAddRemoveUser(t *testing.T) {
User: &protocol.User{
Email: "test@example.com",
Account: serial.ToTypedMessage(&vmess.Account{
Id: u2.String(),
AlterId: 64,
Id: u2.String(),
}),
},
}),
@ -376,8 +373,7 @@ func TestCommanderStats(t *testing.T) {
Level: 1,
Email: "test",
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
}),
},
},
@ -432,8 +428,7 @@ func TestCommanderStats(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_AES128_GCM,
},

View file

@ -673,8 +673,7 @@ func TestDialXray(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
}),
},
},
@ -705,8 +704,7 @@ func TestDialXray(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_AES128_GCM,
},

View file

@ -76,8 +76,7 @@ func TestVMessClosing(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
}),
},
},
@ -130,8 +129,7 @@ func TestVMessClosing(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_AES128_GCM,
},
@ -190,8 +188,7 @@ func TestZeroBuffer(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
}),
},
},
@ -238,8 +235,7 @@ func TestZeroBuffer(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_AES128_GCM,
},

View file

@ -93,8 +93,7 @@ func TestReverseProxy(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
}),
},
},
@ -168,8 +167,7 @@ func TestReverseProxy(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_AES128_GCM,
},
@ -278,8 +276,7 @@ func TestReverseProxyLongRunning(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
}),
},
},
@ -367,8 +364,7 @@ func TestReverseProxyLongRunning(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_AES128_GCM,
},

View file

@ -125,7 +125,7 @@ func TestSimpleTLSConnection(t *testing.T) {
common.Must(err)
defer CloseAllServers(servers)
if err := testTCPConn(clientPort, 1024, time.Second*2)(); err != nil {
if err := testTCPConn(clientPort, 1024, time.Second*20)(); err != nil {
t.Fatal(err)
}
}
@ -247,7 +247,7 @@ func TestAutoIssuingCertificate(t *testing.T) {
defer CloseAllServers(servers)
for i := 0; i < 10; i++ {
if err := testTCPConn(clientPort, 1024, time.Second*2)(); err != nil {
if err := testTCPConn(clientPort, 1024, time.Second*20)(); err != nil {
t.Error(err)
}
}
@ -350,7 +350,7 @@ func TestTLSOverKCP(t *testing.T) {
common.Must(err)
defer CloseAllServers(servers)
if err := testTCPConn(clientPort, 1024, time.Second*2)(); err != nil {
if err := testTCPConn(clientPort, 1024, time.Second*20)(); err != nil {
t.Error(err)
}
}
@ -925,7 +925,7 @@ func TestSimpleTLSConnectionPinned(t *testing.T) {
common.Must(err)
defer CloseAllServers(servers)
if err := testTCPConn(clientPort, 1024, time.Second*2)(); err != nil {
if err := testTCPConn(clientPort, 1024, time.Second*20)(); err != nil {
t.Fatal(err)
}
}

View file

@ -290,8 +290,7 @@ func TestVMessQuic(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
}),
},
},
@ -354,8 +353,7 @@ func TestVMessQuic(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_AES128_GCM,
},

View file

@ -216,8 +216,7 @@ func TestVMessGCM(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
}),
},
},
@ -264,8 +263,7 @@ func TestVMessGCM(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_AES128_GCM,
},
@ -322,8 +320,7 @@ func TestVMessGCMReadv(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
}),
},
},
@ -370,8 +367,7 @@ func TestVMessGCMReadv(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_AES128_GCM,
},
@ -431,8 +427,7 @@ func TestVMessGCMUDP(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
}),
},
},
@ -479,8 +474,7 @@ func TestVMessGCMUDP(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_AES128_GCM,
},
@ -534,8 +528,7 @@ func TestVMessChacha20(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
}),
},
},
@ -582,8 +575,7 @@ func TestVMessChacha20(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_CHACHA20_POLY1305,
},
@ -638,8 +630,7 @@ func TestVMessNone(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
}),
},
},
@ -686,8 +677,7 @@ func TestVMessNone(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_NONE,
},
@ -744,8 +734,7 @@ func TestVMessKCP(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
}),
},
},
@ -792,8 +781,7 @@ func TestVMessKCP(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_AES128_GCM,
},
@ -874,8 +862,7 @@ func TestVMessKCPLarge(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
}),
},
},
@ -922,8 +909,7 @@ func TestVMessKCPLarge(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_AES128_GCM,
},
@ -1005,8 +991,7 @@ func TestVMessGCMMux(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
}),
},
},
@ -1059,8 +1044,7 @@ func TestVMessGCMMux(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_AES128_GCM,
},
@ -1124,8 +1108,7 @@ func TestVMessGCMMuxUDP(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
}),
},
},
@ -1192,8 +1175,7 @@ func TestVMessGCMMuxUDP(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_AES128_GCM,
},
@ -1255,8 +1237,7 @@ func TestVMessZero(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
}),
},
},
@ -1303,8 +1284,7 @@ func TestVMessZero(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_ZERO,
},
@ -1358,8 +1338,7 @@ func TestVMessGCMLengthAuth(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
}),
},
},
@ -1406,8 +1385,7 @@ func TestVMessGCMLengthAuth(t *testing.T) {
User: []*protocol.User{
{
Account: serial.ToTypedMessage(&vmess.Account{
Id: userID.String(),
AlterId: 64,
Id: userID.String(),
SecuritySettings: &protocol.SecurityConfig{
Type: protocol.SecurityType_AES128_GCM,
},