mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-09-21 08:36:53 +00:00
https://github.com/XTLS/Xray-core/pull/6711#issuecomment-5508683394 --------- Co-authored-by: Raaad1on <djilyawhite@gmail.com>
58 lines
1022 B
Go
58 lines
1022 B
Go
package conf_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
. "github.com/xtls/xray-core/infra/conf"
|
|
"github.com/xtls/xray-core/proxy/blackhole"
|
|
)
|
|
|
|
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: &blackhole.Response{Type: "http"},
|
|
},
|
|
},
|
|
{
|
|
Input: `{}`,
|
|
Parser: loadJSON(creator),
|
|
Output: &blackhole.Config{},
|
|
},
|
|
})
|
|
}
|
|
|
|
func TestCustomResponseJSON(t *testing.T) {
|
|
creator := func() Buildable {
|
|
return new(BlackholeConfig)
|
|
}
|
|
|
|
runMultiTestCase(t, []TestCase{
|
|
{
|
|
Input: `{
|
|
"response": {
|
|
"type": "custom",
|
|
"customResponseData": "Y3VzdG9tIHJlc3BvbnNl"
|
|
}
|
|
}`,
|
|
Parser: loadJSON(creator),
|
|
Output: &blackhole.Config{
|
|
Response: &blackhole.Response{
|
|
Type: "custom",
|
|
CustomResponseData: []byte("custom response"),
|
|
},
|
|
},
|
|
},
|
|
})
|
|
}
|