-
Notifications
You must be signed in to change notification settings - Fork 152
Expand file tree
/
Copy pathengine_test.go
More file actions
104 lines (99 loc) · 2.07 KB
/
engine_test.go
File metadata and controls
104 lines (99 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package lksdk
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/livekit/protocol/livekit"
)
func TestFilterTURNServers(t *testing.T) {
tests := []struct {
name string
input []*livekit.ICEServer
expected []*livekit.ICEServer
}{
{
name: "removes turn and turns URLs, keeps stun",
input: []*livekit.ICEServer{
{
Urls: []string{
"turn:ip-10-0-0-1.host.livekit.cloud:3478?transport=udp",
"turns:oashburn1b.turn.livekit.cloud:443?transport=tcp",
"stun:stun.l.google.com:19302",
},
Username: "user",
Credential: "pass",
},
},
expected: []*livekit.ICEServer{
{
Urls: []string{"stun:stun.l.google.com:19302"},
Username: "user",
Credential: "pass",
},
},
},
{
name: "case insensitive",
input: []*livekit.ICEServer{
{
Urls: []string{"TURN:host:3478", "TURNS:host:443", "STUN:host:3478"},
Username: "user",
Credential: "pass",
},
},
expected: []*livekit.ICEServer{
{
Urls: []string{"STUN:host:3478"},
Username: "user",
Credential: "pass",
},
},
},
{
name: "drops server entirely when all URLs are turn",
input: []*livekit.ICEServer{
{
Urls: []string{
"turn:host:3478",
"turns:host:443?transport=tcp",
},
Username: "user",
Credential: "pass",
},
},
expected: nil,
},
{
name: "nil input",
input: nil,
expected: nil,
},
{
name: "multiple servers",
input: []*livekit.ICEServer{
{
Urls: []string{"turn:host:3478"},
Username: "user1",
Credential: "pass1",
},
{
Urls: []string{"stun:stun.l.google.com:19302"},
Username: "",
Credential: "",
},
},
expected: []*livekit.ICEServer{
{
Urls: []string{"stun:stun.l.google.com:19302"},
Username: "",
Credential: "",
},
},
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
result := filterTURNServers(tc.input)
require.Equal(t, tc.expected, result)
})
}
}