config_json_test.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // +build json
  2. package point_test
  3. import (
  4. "path/filepath"
  5. "testing"
  6. _ "github.com/v2ray/v2ray-core/app/router/rules"
  7. netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
  8. _ "github.com/v2ray/v2ray-core/proxy/dokodemo"
  9. _ "github.com/v2ray/v2ray-core/proxy/freedom"
  10. _ "github.com/v2ray/v2ray-core/proxy/socks"
  11. _ "github.com/v2ray/v2ray-core/proxy/vmess/inbound"
  12. _ "github.com/v2ray/v2ray-core/proxy/vmess/outbound"
  13. . "github.com/v2ray/v2ray-core/shell/point"
  14. v2testing "github.com/v2ray/v2ray-core/testing"
  15. "github.com/v2ray/v2ray-core/testing/assert"
  16. )
  17. func TestClientSampleConfig(t *testing.T) {
  18. v2testing.Current(t)
  19. // TODO: fix for Windows
  20. baseDir := "$GOPATH/src/github.com/v2ray/v2ray-core/release/config"
  21. pointConfig, err := LoadConfig(filepath.Join(baseDir, "vpoint_socks_vmess.json"))
  22. assert.Error(err).IsNil()
  23. netassert.Port(pointConfig.Port).IsValid()
  24. assert.Pointer(pointConfig.InboundConfig).IsNotNil()
  25. assert.Pointer(pointConfig.OutboundConfig).IsNotNil()
  26. assert.StringLiteral(pointConfig.InboundConfig.Protocol).Equals("socks")
  27. assert.Pointer(pointConfig.InboundConfig.Settings).IsNotNil()
  28. assert.StringLiteral(pointConfig.OutboundConfig.Protocol).Equals("vmess")
  29. assert.Pointer(pointConfig.OutboundConfig.Settings).IsNotNil()
  30. }
  31. func TestServerSampleConfig(t *testing.T) {
  32. v2testing.Current(t)
  33. // TODO: fix for Windows
  34. baseDir := "$GOPATH/src/github.com/v2ray/v2ray-core/release/config"
  35. pointConfig, err := LoadConfig(filepath.Join(baseDir, "vpoint_vmess_freedom.json"))
  36. assert.Error(err).IsNil()
  37. netassert.Port(pointConfig.Port).IsValid()
  38. assert.Pointer(pointConfig.InboundConfig).IsNotNil()
  39. assert.Pointer(pointConfig.OutboundConfig).IsNotNil()
  40. assert.StringLiteral(pointConfig.InboundConfig.Protocol).Equals("vmess")
  41. assert.Pointer(pointConfig.InboundConfig.Settings).IsNotNil()
  42. assert.StringLiteral(pointConfig.OutboundConfig.Protocol).Equals("freedom")
  43. assert.Pointer(pointConfig.OutboundConfig.Settings).IsNotNil()
  44. }