github.com/imannamdari/v2ray-core/v5@v5.0.5/infra/conf/v4/freedom_test.go (about)

     1  package v4_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/imannamdari/v2ray-core/v5/common/net"
     7  	"github.com/imannamdari/v2ray-core/v5/common/protocol"
     8  	"github.com/imannamdari/v2ray-core/v5/infra/conf/cfgcommon"
     9  	"github.com/imannamdari/v2ray-core/v5/infra/conf/cfgcommon/testassist"
    10  	v4 "github.com/imannamdari/v2ray-core/v5/infra/conf/v4"
    11  	"github.com/imannamdari/v2ray-core/v5/proxy/freedom"
    12  )
    13  
    14  func TestFreedomConfig(t *testing.T) {
    15  	creator := func() cfgcommon.Buildable {
    16  		return new(v4.FreedomConfig)
    17  	}
    18  
    19  	testassist.RunMultiTestCase(t, []testassist.TestCase{
    20  		{
    21  			Input: `{
    22  				"domainStrategy": "AsIs",
    23  				"timeout": 10,
    24  				"redirect": "127.0.0.1:3366",
    25  				"userLevel": 1
    26  			}`,
    27  			Parser: testassist.LoadJSON(creator),
    28  			Output: &freedom.Config{
    29  				DomainStrategy: freedom.Config_AS_IS,
    30  				Timeout:        10,
    31  				DestinationOverride: &freedom.DestinationOverride{
    32  					Server: &protocol.ServerEndpoint{
    33  						Address: &net.IPOrDomain{
    34  							Address: &net.IPOrDomain_Ip{
    35  								Ip: []byte{127, 0, 0, 1},
    36  							},
    37  						},
    38  						Port: 3366,
    39  					},
    40  				},
    41  				UserLevel: 1,
    42  			},
    43  		},
    44  	})
    45  }