github.com/v2fly/v2ray-core/v5@v5.16.2-0.20240507031116-8191faa6e095/infra/conf/v4/dokodemo_test.go (about)

     1  package v4_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/v2fly/v2ray-core/v5/common/net"
     7  	"github.com/v2fly/v2ray-core/v5/infra/conf/cfgcommon"
     8  	"github.com/v2fly/v2ray-core/v5/infra/conf/cfgcommon/testassist"
     9  	v4 "github.com/v2fly/v2ray-core/v5/infra/conf/v4"
    10  	"github.com/v2fly/v2ray-core/v5/proxy/dokodemo"
    11  )
    12  
    13  func TestDokodemoConfig(t *testing.T) {
    14  	creator := func() cfgcommon.Buildable {
    15  		return new(v4.DokodemoConfig)
    16  	}
    17  
    18  	testassist.RunMultiTestCase(t, []testassist.TestCase{
    19  		{
    20  			Input: `{
    21  				"address": "8.8.8.8",
    22  				"port": 53,
    23  				"network": "tcp",
    24  				"timeout": 10,
    25  				"followRedirect": true,
    26  				"userLevel": 1
    27  			}`,
    28  			Parser: testassist.LoadJSON(creator),
    29  			Output: &dokodemo.Config{
    30  				Address: &net.IPOrDomain{
    31  					Address: &net.IPOrDomain_Ip{
    32  						Ip: []byte{8, 8, 8, 8},
    33  					},
    34  				},
    35  				Port:           53,
    36  				Networks:       []net.Network{net.Network_TCP},
    37  				Timeout:        10,
    38  				FollowRedirect: true,
    39  				UserLevel:      1,
    40  			},
    41  		},
    42  	})
    43  }