2020-11-25 13:01:53 +02:00
|
|
|
package conf_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-12-04 03:36:16 +02:00
|
|
|
"github.com/xtls/xray-core/common/serial"
|
|
|
|
. "github.com/xtls/xray-core/infra/conf"
|
|
|
|
"github.com/xtls/xray-core/proxy/blackhole"
|
2020-11-25 13:01:53 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestHTTPResponseJSON(t *testing.T) {
|
|
|
|
creator := func() Buildable {
|
|
|
|
return new(BlackholeConfig)
|
|
|
|
}
|
|
|
|
|
|
|
|
runMultiTestCase(t, []TestCase{
|
|
|
|
{
|
|
|
|
Input: `{
|
|
|
|
"response": {
|
|
|
|
"type": "http"
|
|
|
|
}
|
|
|
|
}`,
|
|
|
|
Parser: loadJSON(creator),
|
|
|
|
Output: &blackhole.Config{
|
|
|
|
Response: serial.ToTypedMessage(&blackhole.HTTPResponse{}),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Input: `{}`,
|
|
|
|
Parser: loadJSON(creator),
|
|
|
|
Output: &blackhole.Config{},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|