1
|
|
using System.Net;
|
2
|
|
using Libplanet.Stun.Messages;
|
3
|
|
using Xunit;
|
4
|
|
|
5
|
|
namespace Libplanet.Stun.Tests.Messages
|
6
|
|
{
|
7
|
|
public class CreatePermissionRequestTest
|
8
|
|
{
|
9
|
|
[Fact]
|
10
|
|
public void EncodeToBytes()
|
11
|
1
|
{
|
12
|
1
|
var request = new CreatePermissionRequest(
|
13
|
1
|
new IPEndPoint(IPAddress.Parse("54.65.63.212"), 37005)
|
14
|
1
|
)
|
15
|
1
|
{
|
16
|
1
|
TransactionId = new byte[]
|
17
|
1
|
{
|
18
|
1
|
0xf8, 0x57, 0xe3, 0x50, 0x4c, 0x8f, 0xd3, 0x9d, 0xb8, 0xca,
|
19
|
1
|
0x69, 0x83,
|
20
|
1
|
},
|
21
|
1
|
};
|
22
|
1
|
var ctx = new TestStunContext()
|
23
|
1
|
{
|
24
|
1
|
Username = "ae0633cd58ba097a1167c6d2cc4e236db52256a40d565f11edf76c02d13db93c",
|
25
|
1
|
Password = "U/X7qP2MosBElz8/T2CESYkvqyUIOoGTlOJoSsHvZkQ=",
|
26
|
1
|
Realm = "twilio.com",
|
27
|
1
|
Nonce = new byte[]
|
28
|
1
|
{
|
29
|
1
|
0x64, 0x32, 0x34, 0x35, 0x39, 0x35, 0x35, 0x39, 0x61, 0x33,
|
30
|
1
|
0x38, 0x37, 0x34, 0x63, 0x39, 0x61,
|
31
|
1
|
},
|
32
|
1
|
};
|
33
|
|
|
34
|
1
|
Assert.Equal(
|
35
|
1
|
new byte[]
|
36
|
1
|
{
|
37
|
1
|
0x00, 0x08, 0x00, 0x94, 0x21, 0x12, 0xa4, 0x42, 0xf8, 0x57,
|
38
|
1
|
0xe3, 0x50, 0x4c, 0x8f, 0xd3, 0x9d, 0xb8, 0xca, 0x69, 0x83,
|
39
|
1
|
0x00, 0x12, 0x00, 0x08, 0x00, 0x01, 0xb1, 0x9f, 0x17, 0x53,
|
40
|
1
|
0x9b, 0x96, 0x00, 0x06, 0x00, 0x40, 0x61, 0x65, 0x30, 0x36,
|
41
|
1
|
0x33, 0x33, 0x63, 0x64, 0x35, 0x38, 0x62, 0x61, 0x30, 0x39,
|
42
|
1
|
0x37, 0x61, 0x31, 0x31, 0x36, 0x37, 0x63, 0x36, 0x64, 0x32,
|
43
|
1
|
0x63, 0x63, 0x34, 0x65, 0x32, 0x33, 0x36, 0x64, 0x62, 0x35,
|
44
|
1
|
0x32, 0x32, 0x35, 0x36, 0x61, 0x34, 0x30, 0x64, 0x35, 0x36,
|
45
|
1
|
0x35, 0x66, 0x31, 0x31, 0x65, 0x64, 0x66, 0x37, 0x36, 0x63,
|
46
|
1
|
0x30, 0x32, 0x64, 0x31, 0x33, 0x64, 0x62, 0x39, 0x33, 0x63,
|
47
|
1
|
0x00, 0x15, 0x00, 0x10, 0x64, 0x32, 0x34, 0x35, 0x39, 0x35,
|
48
|
1
|
0x35, 0x39, 0x61, 0x33, 0x38, 0x37, 0x34, 0x63, 0x39, 0x61,
|
49
|
1
|
0x00, 0x14, 0x00, 0x0a, 0x74, 0x77, 0x69, 0x6c, 0x69, 0x6f,
|
50
|
1
|
0x2e, 0x63, 0x6f, 0x6d, 0x00, 0x00, 0x00, 0x08, 0x00, 0x14,
|
51
|
1
|
0xe9, 0x4a, 0x95, 0x2a, 0x53, 0xb0, 0xdc, 0x8c, 0x3a, 0x42,
|
52
|
1
|
0xd7, 0xfd, 0x21, 0xeb, 0x0c, 0xd4, 0x2f, 0x6c, 0x8d, 0x40,
|
53
|
1
|
0x80, 0x28, 0x00, 0x04, 0x31, 0x5b, 0x2f, 0x0e,
|
54
|
1
|
},
|
55
|
1
|
request.Encode(ctx));
|
56
|
1
|
}
|
57
|
|
}
|
58
|
|
}
|