github.com/EagleQL/Xray-core@v1.4.3/infra/conf/mtproto_test.go (about)

     1  package conf_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/xtls/xray-core/common/protocol"
     7  	"github.com/xtls/xray-core/common/serial"
     8  	. "github.com/xtls/xray-core/infra/conf"
     9  	"github.com/xtls/xray-core/proxy/mtproto"
    10  )
    11  
    12  func TestMTProtoServerConfig(t *testing.T) {
    13  	creator := func() Buildable {
    14  		return new(MTProtoServerConfig)
    15  	}
    16  
    17  	runMultiTestCase(t, []TestCase{
    18  		{
    19  			Input: `{
    20  				"users": [{
    21  					"email": "love@example.com",
    22  					"level": 1,
    23  					"secret": "b0cbcef5a486d9636472ac27f8e11a9d"
    24  				}]
    25  			}`,
    26  			Parser: loadJSON(creator),
    27  			Output: &mtproto.ServerConfig{
    28  				User: []*protocol.User{
    29  					{
    30  						Email: "love@example.com",
    31  						Level: 1,
    32  						Account: serial.ToTypedMessage(&mtproto.Account{
    33  							Secret: []byte{176, 203, 206, 245, 164, 134, 217, 99, 100, 114, 172, 39, 248, 225, 26, 157},
    34  						}),
    35  					},
    36  				},
    37  			},
    38  		},
    39  	})
    40  }