json_test.go 1.7 KB

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