config_json_test.go 810 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // +build json
  2. package outbound_test
  3. import (
  4. "encoding/json"
  5. "testing"
  6. "v2ray.com/core/common/protocol"
  7. "v2ray.com/core/proxy/vmess"
  8. . "v2ray.com/core/proxy/vmess/outbound"
  9. "v2ray.com/core/testing/assert"
  10. )
  11. func TestConfigTargetParsing(t *testing.T) {
  12. assert := assert.On(t)
  13. rawJson := `{
  14. "vnext": [{
  15. "address": "127.0.0.1",
  16. "port": 80,
  17. "users": [
  18. {
  19. "id": "e641f5ad-9397-41e3-bf1a-e8740dfed019",
  20. "email": "love@v2ray.com",
  21. "level": 255
  22. }
  23. ]
  24. }]
  25. }`
  26. config := new(Config)
  27. err := json.Unmarshal([]byte(rawJson), &config)
  28. assert.Error(err).IsNil()
  29. specPB := config.Receiver[0]
  30. spec := protocol.NewServerSpecFromPB(vmess.NewAccount, *specPB)
  31. assert.Destination(spec.Destination()).EqualsString("tcp:127.0.0.1:80")
  32. }