MCPcopy
hub / github.com/livekit/livekit / TestTURNAuthHandler_HandleAuth_ValidCredentials

Function TestTURNAuthHandler_HandleAuth_ValidCredentials

pkg/service/turn_test.go:48–72  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46}
47
48func TestTURNAuthHandler_HandleAuth_ValidCredentials(t *testing.T) {
49 h := newTestTurnAuthHandler()
50 pID := livekit.ParticipantID("PA_valid")
51 username, expectedKey := mustAuthCreds(t, h, pID, 300)
52
53 for _, method := range []stun.Method{
54 stun.MethodAllocate,
55 stun.MethodRefresh,
56 stun.MethodCreatePermission,
57 stun.MethodChannelBind,
58 stun.MethodSend,
59 } {
60 t.Run(method.String(), func(t *testing.T) {
61 userID, key, ok := h.HandleAuth(&turn.RequestAttributes{
62 Username: username,
63 Realm: LivekitRealm,
64 SrcAddr: &net.UDPAddr{IP: net.ParseIP("127.0.0.1"), Port: 1234},
65 Method: method,
66 })
67 require.True(t, ok)
68 require.Equal(t, string(pID), userID)
69 require.Equal(t, expectedKey, key)
70 })
71 }
72}
73
74func TestTURNAuthHandler_HandleAuth_ExpiredAllocateRejected(t *testing.T) {
75 h := newTestTurnAuthHandler()

Callers

nothing calls this directly

Calls 6

newTestTurnAuthHandlerFunction · 0.85
mustAuthCredsFunction · 0.85
HandleAuthMethod · 0.80
ParticipantIDMethod · 0.45
RunMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected