Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 9771524

Browse files
committed
Fix linting
1 parent 48d6dcc commit 9771524

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

wsnet/dial_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func ExampleDial_basic() {
4646
// You now have access to the proxied remote port in `conn`.
4747
}
4848

49-
// nolint:gocognit,nestif
49+
// nolint:gocognit
5050
func TestDial(t *testing.T) {
5151
t.Run("Ping", func(t *testing.T) {
5252
connectAddr, listenAddr := createDumbBroker(t)
@@ -204,12 +204,11 @@ func TestDial(t *testing.T) {
204204
t.Error(err)
205205
return
206206
}
207-
pass := "test"
208-
turnAddr, closeTurn := createTURNServer(t, ice.SchemeTypeTURN, pass)
207+
turnAddr, closeTurn := createTURNServer(t, ice.SchemeTypeTURN)
209208
dialer, err := DialWebsocket(context.Background(), connectAddr, []webrtc.ICEServer{{
210209
URLs: []string{fmt.Sprintf("turn:%s", turnAddr)},
211210
Username: "example",
212-
Credential: pass,
211+
Credential: testPass,
213212
CredentialType: webrtc.ICECredentialTypePassword,
214213
}})
215214
if err != nil {

wsnet/rtc_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ func TestDialICE(t *testing.T) {
1616
t.Run("TURN with TLS", func(t *testing.T) {
1717
t.Parallel()
1818

19-
addr, _ := createTURNServer(t, ice.SchemeTypeTURNS, "test")
19+
addr, _ := createTURNServer(t, ice.SchemeTypeTURNS)
2020
err := DialICE(webrtc.ICEServer{
2121
URLs: []string{fmt.Sprintf("turns:%s", addr)},
2222
Username: "example",
23-
Credential: "test",
23+
Credential: testPass,
2424
CredentialType: webrtc.ICECredentialTypePassword,
2525
}, &DialICEOptions{
2626
Timeout: time.Millisecond,
@@ -34,11 +34,11 @@ func TestDialICE(t *testing.T) {
3434
t.Run("Protocol mismatch", func(t *testing.T) {
3535
t.Parallel()
3636

37-
addr, _ := createTURNServer(t, ice.SchemeTypeTURNS, "test")
37+
addr, _ := createTURNServer(t, ice.SchemeTypeTURNS)
3838
err := DialICE(webrtc.ICEServer{
3939
URLs: []string{fmt.Sprintf("turn:%s", addr)},
4040
Username: "example",
41-
Credential: "test",
41+
Credential: testPass,
4242
CredentialType: webrtc.ICECredentialTypePassword,
4343
}, &DialICEOptions{
4444
Timeout: time.Millisecond,
@@ -52,7 +52,7 @@ func TestDialICE(t *testing.T) {
5252
t.Run("Invalid auth", func(t *testing.T) {
5353
t.Parallel()
5454

55-
addr, _ := createTURNServer(t, ice.SchemeTypeTURNS, "test")
55+
addr, _ := createTURNServer(t, ice.SchemeTypeTURNS)
5656
err := DialICE(webrtc.ICEServer{
5757
URLs: []string{fmt.Sprintf("turns:%s", addr)},
5858
Username: "example",

wsnet/wsnet_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ import (
2525
"nhooyr.io/websocket"
2626
)
2727

28+
const (
29+
// Password used connecting to the test TURN server.
30+
testPass = "test"
31+
)
32+
2833
// createDumbBroker proxies sockets between /listen and /connect
2934
// to emulate an authenticated WebSocket pair.
3035
func createDumbBroker(t testing.TB) (connectAddr string, listenAddr string) {
@@ -86,7 +91,7 @@ func createDumbBroker(t testing.TB) (connectAddr string, listenAddr string) {
8691
}
8792

8893
// createTURNServer allocates a TURN server and returns the address.
89-
func createTURNServer(t *testing.T, server ice.SchemeType, pass string) (string, func()) {
94+
func createTURNServer(t *testing.T, server ice.SchemeType) (string, func()) {
9095
var (
9196
listeners []turn.ListenerConfig
9297
pcListeners []turn.PacketConnConfig
@@ -136,7 +141,7 @@ func createTURNServer(t *testing.T, server ice.SchemeType, pass string) (string,
136141
ListenerConfigs: listeners,
137142
Realm: "coder",
138143
AuthHandler: func(username, realm string, srcAddr net.Addr) (key []byte, ok bool) {
139-
return turn.GenerateAuthKey(username, realm, pass), true
144+
return turn.GenerateAuthKey(username, realm, testPass), true
140145
},
141146
LoggerFactory: lf,
142147
})

0 commit comments

Comments
 (0)