2015-10-06 23:11:08 +02:00
|
|
|
package json_test
|
2015-09-20 11:45:40 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
2016-01-17 15:20:49 +00:00
|
|
|
_ "github.com/v2ray/v2ray-core/app/router/rules"
|
2015-12-06 20:38:01 +01:00
|
|
|
netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
|
2016-01-15 12:43:06 +01:00
|
|
|
_ "github.com/v2ray/v2ray-core/proxy/dokodemo"
|
|
|
|
_ "github.com/v2ray/v2ray-core/proxy/freedom"
|
|
|
|
_ "github.com/v2ray/v2ray-core/proxy/socks"
|
|
|
|
_ "github.com/v2ray/v2ray-core/proxy/vmess/inbound"
|
|
|
|
_ "github.com/v2ray/v2ray-core/proxy/vmess/outbound"
|
2015-12-06 16:41:41 +01:00
|
|
|
"github.com/v2ray/v2ray-core/shell/point/json"
|
2015-10-06 23:11:08 +02:00
|
|
|
|
2015-12-02 14:27:18 +00:00
|
|
|
v2testing "github.com/v2ray/v2ray-core/testing"
|
|
|
|
"github.com/v2ray/v2ray-core/testing/assert"
|
2015-09-20 11:45:40 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestClientSampleConfig(t *testing.T) {
|
2015-12-02 14:27:18 +00:00
|
|
|
v2testing.Current(t)
|
2015-09-20 11:45:40 +02:00
|
|
|
|
|
|
|
// TODO: fix for Windows
|
|
|
|
baseDir := "$GOPATH/src/github.com/v2ray/v2ray-core/release/config"
|
|
|
|
|
2015-10-06 23:11:08 +02:00
|
|
|
pointConfig, err := json.LoadConfig(filepath.Join(baseDir, "vpoint_socks_vmess.json"))
|
2015-09-20 11:45:40 +02:00
|
|
|
assert.Error(err).IsNil()
|
|
|
|
|
2015-12-06 20:38:01 +01:00
|
|
|
netassert.Port(pointConfig.Port()).IsValid()
|
2015-10-06 23:11:08 +02:00
|
|
|
assert.Pointer(pointConfig.InboundConfig()).IsNotNil()
|
|
|
|
assert.Pointer(pointConfig.OutboundConfig()).IsNotNil()
|
2015-09-20 11:45:40 +02:00
|
|
|
|
2015-12-02 15:41:19 +00:00
|
|
|
assert.StringLiteral(pointConfig.InboundConfig().Protocol()).Equals("socks")
|
2015-10-29 23:35:54 +01:00
|
|
|
assert.Pointer(pointConfig.InboundConfig().Settings()).IsNotNil()
|
2015-09-20 11:45:40 +02:00
|
|
|
|
2015-12-02 15:41:19 +00:00
|
|
|
assert.StringLiteral(pointConfig.OutboundConfig().Protocol()).Equals("vmess")
|
2015-10-29 23:35:54 +01:00
|
|
|
assert.Pointer(pointConfig.OutboundConfig().Settings()).IsNotNil()
|
2015-09-20 11:45:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestServerSampleConfig(t *testing.T) {
|
2015-12-02 14:27:18 +00:00
|
|
|
v2testing.Current(t)
|
2015-09-20 11:45:40 +02:00
|
|
|
|
|
|
|
// TODO: fix for Windows
|
|
|
|
baseDir := "$GOPATH/src/github.com/v2ray/v2ray-core/release/config"
|
|
|
|
|
2015-10-06 23:11:08 +02:00
|
|
|
pointConfig, err := json.LoadConfig(filepath.Join(baseDir, "vpoint_vmess_freedom.json"))
|
2015-09-20 11:45:40 +02:00
|
|
|
assert.Error(err).IsNil()
|
|
|
|
|
2015-12-02 20:44:01 +00:00
|
|
|
assert.Uint16(pointConfig.Port().Value()).Positive()
|
2015-10-06 23:11:08 +02:00
|
|
|
assert.Pointer(pointConfig.InboundConfig()).IsNotNil()
|
|
|
|
assert.Pointer(pointConfig.OutboundConfig()).IsNotNil()
|
2015-09-20 11:45:40 +02:00
|
|
|
|
2015-12-02 15:41:19 +00:00
|
|
|
assert.StringLiteral(pointConfig.InboundConfig().Protocol()).Equals("vmess")
|
2015-10-29 23:35:54 +01:00
|
|
|
assert.Pointer(pointConfig.InboundConfig().Settings()).IsNotNil()
|
2015-09-20 11:45:40 +02:00
|
|
|
|
2015-12-02 15:41:19 +00:00
|
|
|
assert.StringLiteral(pointConfig.OutboundConfig().Protocol()).Equals("freedom")
|
2015-10-29 23:35:54 +01:00
|
|
|
assert.Pointer(pointConfig.OutboundConfig().Settings()).IsNotNil()
|
2015-09-20 11:45:40 +02:00
|
|
|
}
|