converter_test.go 981 B

1234567891011121314151617181920212223242526272829303132333435
  1. package convert
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. // https://v2.hysteria.network/zh/docs/developers/URI-Scheme/
  7. func TestConvertsV2Ray_normal(t *testing.T) {
  8. hy2test := "hysteria2://letmein@example.com:8443/?insecure=1&obfs=salamander&obfs-password=gawrgura&pinSHA256=deadbeef&sni=real.example.com&up=114&down=514&alpn=h3,h4#hy2test"
  9. expected := []map[string]interface{}{
  10. {
  11. "name": "hy2test",
  12. "type": "hysteria2",
  13. "server": "example.com",
  14. "port": "8443",
  15. "sni": "real.example.com",
  16. "obfs": "salamander",
  17. "obfs-password": "gawrgura",
  18. "alpn": []string{"h3", "h4"},
  19. "password": "letmein",
  20. "up": "114",
  21. "down": "514",
  22. "skip-cert-verify": true,
  23. "fingerprint": "deadbeef",
  24. },
  25. }
  26. proxies, err := ConvertsV2Ray([]byte(hy2test))
  27. assert.Nil(t, err)
  28. assert.Equal(t, expected, proxies)
  29. }