json_test.go 2.0 KB

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