2015-09-20 05:45:40 -04:00
|
|
|
package json
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"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"
|
|
|
|
|
|
|
|
config, err := LoadConfig(filepath.Join(baseDir, "vpoint_socks_vmess.json"))
|
|
|
|
assert.Error(err).IsNil()
|
|
|
|
|
2015-09-20 05:51:24 -04:00
|
|
|
assert.Uint16(config.Port()).Positive()
|
|
|
|
assert.Pointer(config.InboundConfig()).IsNotNil()
|
|
|
|
assert.Pointer(config.OutboundConfig()).IsNotNil()
|
2015-09-20 05:45:40 -04:00
|
|
|
|
2015-09-20 05:51:24 -04:00
|
|
|
assert.String(config.InboundConfig().Protocol()).Equals("socks")
|
|
|
|
assert.Int(len(config.InboundConfig().Content())).GreaterThan(0)
|
2015-09-20 05:45:40 -04:00
|
|
|
|
2015-09-20 05:51:24 -04:00
|
|
|
assert.String(config.OutboundConfig().Protocol()).Equals("vmess")
|
|
|
|
assert.Int(len(config.OutboundConfig().Content())).GreaterThan(0)
|
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"
|
|
|
|
|
|
|
|
config, err := LoadConfig(filepath.Join(baseDir, "vpoint_vmess_freedom.json"))
|
|
|
|
assert.Error(err).IsNil()
|
|
|
|
|
2015-09-20 05:51:24 -04:00
|
|
|
assert.Uint16(config.Port()).Positive()
|
|
|
|
assert.Pointer(config.InboundConfig()).IsNotNil()
|
|
|
|
assert.Pointer(config.OutboundConfig()).IsNotNil()
|
2015-09-20 05:45:40 -04:00
|
|
|
|
2015-09-20 05:51:24 -04:00
|
|
|
assert.String(config.InboundConfig().Protocol()).Equals("vmess")
|
|
|
|
assert.Int(len(config.InboundConfig().Content())).GreaterThan(0)
|
2015-09-20 05:45:40 -04:00
|
|
|
|
2015-09-20 05:51:24 -04:00
|
|
|
assert.String(config.OutboundConfig().Protocol()).Equals("freedom")
|
2015-09-20 07:08:05 -04:00
|
|
|
assert.Int(len(config.OutboundConfig().Content())).Equals(0)
|
2015-09-20 05:45:40 -04:00
|
|
|
}
|