blackhole_test.go 610 B

12345678910111213141516171819202122232425262728293031323334
  1. package conf_test
  2. import (
  3. "testing"
  4. "github.com/xtls/xray-core/common/serial"
  5. . "github.com/xtls/xray-core/infra/conf"
  6. "github.com/xtls/xray-core/proxy/blackhole"
  7. )
  8. func TestHTTPResponseJSON(t *testing.T) {
  9. creator := func() Buildable {
  10. return new(BlackholeConfig)
  11. }
  12. runMultiTestCase(t, []TestCase{
  13. {
  14. Input: `{
  15. "response": {
  16. "type": "http"
  17. }
  18. }`,
  19. Parser: loadJSON(creator),
  20. Output: &blackhole.Config{
  21. Response: serial.ToTypedMessage(&blackhole.HTTPResponse{}),
  22. },
  23. },
  24. {
  25. Input: `{}`,
  26. Parser: loadJSON(creator),
  27. Output: &blackhole.Config{},
  28. },
  29. })
  30. }