json_test.go 2.0 KB

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