outbound_test.go 805 B

123456789101112131415161718192021222324252627282930313233
  1. package json_test
  2. import (
  3. "encoding/json"
  4. "testing"
  5. jsonconfig "github.com/v2ray/v2ray-core/proxy/vmess/outbound/json"
  6. v2testing "github.com/v2ray/v2ray-core/testing"
  7. "github.com/v2ray/v2ray-core/testing/assert"
  8. )
  9. func TestConfigTargetParsing(t *testing.T) {
  10. v2testing.Current(t)
  11. rawJson := `{
  12. "address": "127.0.0.1",
  13. "port": 80,
  14. "users": [
  15. {
  16. "id": "e641f5ad-9397-41e3-bf1a-e8740dfed019",
  17. "email": "love@v2ray.com",
  18. "level": 999
  19. }
  20. ]
  21. }`
  22. var target *jsonconfig.ConfigTarget
  23. err := json.Unmarshal([]byte(rawJson), &target)
  24. assert.Error(err).IsNil()
  25. assert.String(target.Destination).Equals("tcp:127.0.0.1:80")
  26. assert.Int(len(target.Users)).Equals(1)
  27. assert.String(target.Users[0].ID()).Equals("e641f5ad-9397-41e3-bf1a-e8740dfed019")
  28. }