mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-19 23:03:08 +00:00
cleanup shell/point/config
This commit is contained in:
1 parent
e1c58fae2b
commit
8bee0c4a7b
18 files changed
+341
-37
No files matched your search
@@ -0,0 +1,74 @@
|
||||
package json_test
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
_ "github.com/v2ray/v2ray-core/proxy/dokodemo/config/json"
|
||||
_ "github.com/v2ray/v2ray-core/proxy/freedom/config/json"
|
||||
_ "github.com/v2ray/v2ray-core/proxy/socks/config/json"
|
||||
_ "github.com/v2ray/v2ray-core/proxy/vmess/config/json"
|
||||
"github.com/v2ray/v2ray-core/shell/point/json"
|
||||
|
||||
v2testing "github.com/v2ray/v2ray-core/testing"
|
||||
"github.com/v2ray/v2ray-core/testing/assert"
|
||||
)
|
||||
|
||||
func TestClientSampleConfig(t *testing.T) {
|
||||
v2testing.Current(t)
|
||||
|
||||
// TODO: fix for Windows
|
||||
baseDir := "$GOPATH/src/github.com/v2ray/v2ray-core/release/config"
|
||||
|
||||
pointConfig, err := json.LoadConfig(filepath.Join(baseDir, "vpoint_socks_vmess.json"))
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
assert.Uint16(pointConfig.Port().Value()).Positive()
|
||||
assert.Pointer(pointConfig.InboundConfig()).IsNotNil()
|
||||
assert.Pointer(pointConfig.OutboundConfig()).IsNotNil()
|
||||
|
||||
assert.StringLiteral(pointConfig.InboundConfig().Protocol()).Equals("socks")
|
||||
assert.Pointer(pointConfig.InboundConfig().Settings()).IsNotNil()
|
||||
|
||||
assert.StringLiteral(pointConfig.OutboundConfig().Protocol()).Equals("vmess")
|
||||
assert.Pointer(pointConfig.OutboundConfig().Settings()).IsNotNil()
|
||||
}
|
||||
|
||||
func TestServerSampleConfig(t *testing.T) {
|
||||
v2testing.Current(t)
|
||||
|
||||
// TODO: fix for Windows
|
||||
baseDir := "$GOPATH/src/github.com/v2ray/v2ray-core/release/config"
|
||||
|
||||
pointConfig, err := json.LoadConfig(filepath.Join(baseDir, "vpoint_vmess_freedom.json"))
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
assert.Uint16(pointConfig.Port().Value()).Positive()
|
||||
assert.Pointer(pointConfig.InboundConfig()).IsNotNil()
|
||||
assert.Pointer(pointConfig.OutboundConfig()).IsNotNil()
|
||||
|
||||
assert.StringLiteral(pointConfig.InboundConfig().Protocol()).Equals("vmess")
|
||||
assert.Pointer(pointConfig.InboundConfig().Settings()).IsNotNil()
|
||||
|
||||
assert.StringLiteral(pointConfig.OutboundConfig().Protocol()).Equals("freedom")
|
||||
assert.Pointer(pointConfig.OutboundConfig().Settings()).IsNotNil()
|
||||
}
|
||||
|
||||
func TestDetourConfig(t *testing.T) {
|
||||
v2testing.Current(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.StringLiteral(detour.Protocol()).Equals("dokodemo-door")
|
||||
assert.Uint16(detour.PortRange().From().Value()).Equals(uint16(28394))
|
||||
assert.Uint16(detour.PortRange().To().Value()).Equals(uint16(28394))
|
||||
assert.Pointer(detour.Settings()).IsNotNil()
|
||||
}
|
||||
Reference in new issue
Block a user