snapshot of https://github.com/pion/webrtc.git (main, 2026-09-15; blobs > 131072B omitted)
Some checks failed
REUSE Compliance Check / lint (push) Failing after 0s
Browser E2E / Test (push) Failing after 3s
Test / test (1.24) (push) Failing after 0s
Test / test-i386 (1.25) (push) Failing after 0s
Test / test-i386 (1.24) (push) Failing after 0s
Test / test-windows (1.25) (push) Failing after 0s
Test / test-windows (1.24) (push) Failing after 0s
Test / test (1.25) (push) Failing after 0s
Examples Tests / Test (push) Failing after 3s
Test / test-macos (1.25) (push) Failing after 0s
Test / test-macos (1.24) (push) Failing after 0s
Go mod tidy / tidy (push) Failing after 0s
Test / test-wasm (push) Failing after 0s
CodeQL / analyze (push) Failing after 1s
Fuzz / fuzz (push) Failing after 0s
Some checks failed
REUSE Compliance Check / lint (push) Failing after 0s
Browser E2E / Test (push) Failing after 3s
Test / test (1.24) (push) Failing after 0s
Test / test-i386 (1.25) (push) Failing after 0s
Test / test-i386 (1.24) (push) Failing after 0s
Test / test-windows (1.25) (push) Failing after 0s
Test / test-windows (1.24) (push) Failing after 0s
Test / test (1.25) (push) Failing after 0s
Examples Tests / Test (push) Failing after 3s
Test / test-macos (1.25) (push) Failing after 0s
Test / test-macos (1.24) (push) Failing after 0s
Go mod tidy / tidy (push) Failing after 0s
Test / test-wasm (push) Failing after 0s
CodeQL / analyze (push) Failing after 1s
Fuzz / fuzz (push) Failing after 0s
This commit is contained in:
84
dtlsrole_test.go
Normal file
84
dtlsrole_test.go
Normal file
@@ -0,0 +1,84 @@
|
||||
// SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package webrtc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/pion/sdp/v3"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestDTLSRole_String(t *testing.T) {
|
||||
testCases := []struct {
|
||||
role DTLSRole
|
||||
expectedString string
|
||||
}{
|
||||
{DTLSRoleUnknown, ErrUnknownType.Error()},
|
||||
{DTLSRoleAuto, "auto"},
|
||||
{DTLSRoleClient, "client"},
|
||||
{DTLSRoleServer, "server"},
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
assert.Equal(t,
|
||||
testCase.expectedString,
|
||||
testCase.role.String(),
|
||||
"testCase: %d %v", i, testCase,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDTLSRoleFromSDP(t *testing.T) {
|
||||
parseSDP := func(raw string) *sdp.SessionDescription {
|
||||
parsed := &sdp.SessionDescription{}
|
||||
assert.NoError(t, parsed.Unmarshal([]byte(raw)))
|
||||
|
||||
return parsed
|
||||
}
|
||||
|
||||
const noMedia = `v=0
|
||||
o=- 4596489990601351948 2 IN IP4 127.0.0.1
|
||||
s=-
|
||||
t=0 0
|
||||
`
|
||||
|
||||
const mediaNoSetup = `v=0
|
||||
o=- 4596489990601351948 2 IN IP4 127.0.0.1
|
||||
s=-
|
||||
t=0 0
|
||||
m=application 47299 DTLS/SCTP 5000
|
||||
c=IN IP4 192.168.20.129
|
||||
`
|
||||
|
||||
const mediaSetupDeclared = `v=0
|
||||
o=- 4596489990601351948 2 IN IP4 127.0.0.1
|
||||
s=-
|
||||
t=0 0
|
||||
m=application 47299 DTLS/SCTP 5000
|
||||
c=IN IP4 192.168.20.129
|
||||
a=setup:%s
|
||||
`
|
||||
|
||||
testCases := []struct {
|
||||
test string
|
||||
sessionDescription *sdp.SessionDescription
|
||||
expectedRole DTLSRole
|
||||
}{
|
||||
{"nil SessionDescription", nil, DTLSRoleAuto},
|
||||
{"No MediaDescriptions", parseSDP(noMedia), DTLSRoleAuto},
|
||||
{"MediaDescription, no setup", parseSDP(mediaNoSetup), DTLSRoleAuto},
|
||||
{"MediaDescription, setup:actpass", parseSDP(fmt.Sprintf(mediaSetupDeclared, "actpass")), DTLSRoleAuto},
|
||||
{"MediaDescription, setup:passive", parseSDP(fmt.Sprintf(mediaSetupDeclared, "passive")), DTLSRoleServer},
|
||||
{"MediaDescription, setup:active", parseSDP(fmt.Sprintf(mediaSetupDeclared, "active")), DTLSRoleClient},
|
||||
}
|
||||
for _, testCase := range testCases {
|
||||
assert.Equal(t,
|
||||
testCase.expectedRole,
|
||||
dtlsRoleFromSDP(testCase.sessionDescription),
|
||||
"TestDTLSRoleFromSDP (%s)", testCase.test,
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user