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