mirror of https://github.com/v2ray/v2ray-core
fix test break
parent
54e1bb96cc
commit
16051587b5
|
@ -4,6 +4,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"v2ray.com/core/common"
|
||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
. "v2ray.com/core/common/protocol"
|
. "v2ray.com/core/common/protocol"
|
||||||
"v2ray.com/core/common/uuid"
|
"v2ray.com/core/common/uuid"
|
||||||
|
@ -39,19 +40,25 @@ func TestUserInServerSpec(t *testing.T) {
|
||||||
uuid1 := uuid.New()
|
uuid1 := uuid.New()
|
||||||
uuid2 := uuid.New()
|
uuid2 := uuid.New()
|
||||||
|
|
||||||
|
toAccount := func(a *vmess.Account) Account {
|
||||||
|
account, err := a.AsAccount()
|
||||||
|
common.Must(err)
|
||||||
|
return account
|
||||||
|
}
|
||||||
|
|
||||||
spec := NewServerSpec(net.Destination{}, AlwaysValid(), &MemoryUser{
|
spec := NewServerSpec(net.Destination{}, AlwaysValid(), &MemoryUser{
|
||||||
Email: "test1@v2ray.com",
|
Email: "test1@v2ray.com",
|
||||||
Account: &vmess.Account{Id: uuid1.String()},
|
Account: toAccount(&vmess.Account{Id: uuid1.String()}),
|
||||||
})
|
})
|
||||||
assert(spec.HasUser(&MemoryUser{
|
assert(spec.HasUser(&MemoryUser{
|
||||||
Email: "test1@v2ray.com",
|
Email: "test1@v2ray.com",
|
||||||
Account: &vmess.Account{Id: uuid2.String()},
|
Account: toAccount(&vmess.Account{Id: uuid2.String()}),
|
||||||
}), IsFalse)
|
}), IsFalse)
|
||||||
|
|
||||||
spec.AddUser(&MemoryUser{Email: "test2@v2ray.com"})
|
spec.AddUser(&MemoryUser{Email: "test2@v2ray.com"})
|
||||||
assert(spec.HasUser(&MemoryUser{
|
assert(spec.HasUser(&MemoryUser{
|
||||||
Email: "test1@v2ray.com",
|
Email: "test1@v2ray.com",
|
||||||
Account: &vmess.Account{Id: uuid1.String()},
|
Account: toAccount(&vmess.Account{Id: uuid1.String()}),
|
||||||
}), IsTrue)
|
}), IsTrue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"v2ray.com/core/common"
|
"v2ray.com/core/common"
|
||||||
"v2ray.com/core/common/serial"
|
|
||||||
"v2ray.com/core/common/uuid"
|
"v2ray.com/core/common/uuid"
|
||||||
|
|
||||||
"v2ray.com/core/common/protocol"
|
"v2ray.com/core/common/protocol"
|
||||||
|
@ -20,10 +19,16 @@ func TestUserValidator(t *testing.T) {
|
||||||
v := NewTimedUserValidator(hasher)
|
v := NewTimedUserValidator(hasher)
|
||||||
defer common.Close(v)
|
defer common.Close(v)
|
||||||
|
|
||||||
|
toAccount := func(a *Account) protocol.Account {
|
||||||
|
account, err := a.AsAccount()
|
||||||
|
common.Must(err)
|
||||||
|
return account
|
||||||
|
}
|
||||||
|
|
||||||
id := uuid.New()
|
id := uuid.New()
|
||||||
user := &protocol.User{
|
user := &protocol.MemoryUser{
|
||||||
Email: "test",
|
Email: "test",
|
||||||
Account: serial.ToTypedMessage(&Account{
|
Account: toAccount(&Account{
|
||||||
Id: id.String(),
|
Id: id.String(),
|
||||||
AlterId: 8,
|
AlterId: 8,
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in New Issue