2016-01-15 06:43:06 -05:00
|
|
|
// +build json
|
|
|
|
|
|
|
|
package outbound_test
|
2015-12-02 16:30:15 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"testing"
|
|
|
|
|
2016-05-28 07:44:11 -04:00
|
|
|
"github.com/v2ray/v2ray-core/common/protocol"
|
2016-01-15 06:43:06 -05:00
|
|
|
. "github.com/v2ray/v2ray-core/proxy/vmess/outbound"
|
2015-12-02 16:30:15 -05:00
|
|
|
"github.com/v2ray/v2ray-core/testing/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestConfigTargetParsing(t *testing.T) {
|
2016-05-24 15:55:46 -04:00
|
|
|
assert := assert.On(t)
|
2015-12-02 16:30:15 -05:00
|
|
|
|
|
|
|
rawJson := `{
|
|
|
|
"address": "127.0.0.1",
|
|
|
|
"port": 80,
|
|
|
|
"users": [
|
|
|
|
{
|
|
|
|
"id": "e641f5ad-9397-41e3-bf1a-e8740dfed019",
|
|
|
|
"email": "love@v2ray.com",
|
2016-01-20 11:31:43 -05:00
|
|
|
"level": 255
|
2015-12-02 16:30:15 -05:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}`
|
|
|
|
|
2016-01-15 06:43:06 -05:00
|
|
|
receiver := new(Receiver)
|
|
|
|
err := json.Unmarshal([]byte(rawJson), &receiver)
|
2015-12-02 16:30:15 -05:00
|
|
|
assert.Error(err).IsNil()
|
2016-05-24 15:55:46 -04:00
|
|
|
assert.Destination(receiver.Destination).EqualsString("tcp:127.0.0.1:80")
|
2016-01-15 06:43:06 -05:00
|
|
|
assert.Int(len(receiver.Accounts)).Equals(1)
|
2016-05-28 07:44:11 -04:00
|
|
|
|
|
|
|
account := receiver.Accounts[0].Account.(*protocol.VMessAccount)
|
|
|
|
assert.String(account.ID.String()).Equals("e641f5ad-9397-41e3-bf1a-e8740dfed019")
|
2015-12-02 16:30:15 -05:00
|
|
|
}
|