2015-10-06 17:11:08 -04:00
|
|
|
package json_test
|
2015-09-20 05:45:40 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
2015-11-01 17:01:15 -05:00
|
|
|
_ "github.com/v2ray/v2ray-core/proxy/dokodemo/config/json"
|
2015-10-06 17:11:08 -04:00
|
|
|
_ "github.com/v2ray/v2ray-core/proxy/freedom/config/json"
|
|
|
|
_ "github.com/v2ray/v2ray-core/proxy/socks/config/json"
|
2015-10-16 06:03:22 -04:00
|
|
|
_ "github.com/v2ray/v2ray-core/proxy/vmess/config/json"
|
2015-11-29 08:45:32 -05:00
|
|
|
"github.com/v2ray/v2ray-core/shell/point/config/json"
|
2015-10-06 17:11:08 -04:00
|
|
|
|
2015-09-20 05:45:40 -04:00
|
|
|
"github.com/v2ray/v2ray-core/testing/unit"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestClientSampleConfig(t *testing.T) {
|
|
|
|
assert := unit.Assert(t)
|
|
|
|
|
|
|
|
// 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-10-06 17:11:08 -04:00
|
|
|
assert.Uint16(pointConfig.Port()).Positive()
|
|
|
|
assert.Pointer(pointConfig.InboundConfig()).IsNotNil()
|
|
|
|
assert.Pointer(pointConfig.OutboundConfig()).IsNotNil()
|
2015-09-20 05:45:40 -04:00
|
|
|
|
2015-10-06 17:11:08 -04:00
|
|
|
assert.String(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-10-06 17:11:08 -04:00
|
|
|
assert.String(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) {
|
|
|
|
assert := unit.Assert(t)
|
|
|
|
|
|
|
|
// 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-10-06 17:11:08 -04:00
|
|
|
assert.Uint16(pointConfig.Port()).Positive()
|
|
|
|
assert.Pointer(pointConfig.InboundConfig()).IsNotNil()
|
|
|
|
assert.Pointer(pointConfig.OutboundConfig()).IsNotNil()
|
2015-09-20 05:45:40 -04:00
|
|
|
|
2015-10-06 17:11:08 -04:00
|
|
|
assert.String(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-10-06 17:11:08 -04:00
|
|
|
assert.String(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
|
|
|
}
|
2015-11-01 17:01:15 -05:00
|
|
|
|
|
|
|
func TestDetourConfig(t *testing.T) {
|
|
|
|
assert := unit.Assert(t)
|
|
|
|
|
|
|
|
// TODO: fix for Windows
|
|
|
|
baseDir := "$GOPATH/src/github.com/v2ray/v2ray-core/release/config"
|
|
|
|
|
|
|
|
pointConfig, err := json.LoadConfig(filepath.Join(baseDir, "vpoint_dns_detour.json"))
|
|
|
|
assert.Error(err).IsNil()
|
|
|
|
|
|
|
|
detours := pointConfig.InboundDetours()
|
|
|
|
assert.Int(len(detours)).Equals(1)
|
|
|
|
|
|
|
|
detour := detours[0]
|
|
|
|
assert.String(detour.Protocol()).Equals("dokodemo-door")
|
2015-12-02 06:47:54 -05:00
|
|
|
assert.Uint16(detour.PortRange().From().Value()).Equals(uint16(28394))
|
|
|
|
assert.Uint16(detour.PortRange().To().Value()).Equals(uint16(28394))
|
2015-11-01 17:01:15 -05:00
|
|
|
assert.Pointer(detour.Settings()).IsNotNil()
|
|
|
|
}
|