MCPcopy
hub / github.com/livekit/livekit / TestMultiNodeRevokePublishPermission

Function TestMultiNodeRevokePublishPermission

test/multinode_test.go:331–381  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

329}
330
331func TestMultiNodeRevokePublishPermission(t *testing.T) {
332 _, _, finish := setupMultiNodeTest("TestMultiNodeRevokePublishPermission")
333 defer finish()
334
335 for _, testRTCServicePath := range testRTCServicePaths {
336 t.Run(fmt.Sprintf("testRTCServicePath=%s", testRTCServicePath.String()), func(t *testing.T) {
337 c1 := createRTCClient("c1", defaultServerPort, testRTCServicePath, nil)
338 c2 := createRTCClient("c2", secondServerPort, testRTCServicePath, nil)
339 waitUntilConnected(t, c1, c2)
340
341 // c1 publishes a track for c2
342 writers := publishTracksForClients(t, c1)
343 defer stopWriters(writers...)
344
345 testutils.WithTimeout(t, func() string {
346 if len(c2.SubscribedTracks()[c1.ID()]) != 2 {
347 return "c2 did not receive c1's tracks"
348 }
349 return ""
350 })
351
352 // revoke permission
353 ctx := contextWithToken(adminRoomToken(testRoom))
354 _, err := roomClient.UpdateParticipant(ctx, &livekit.UpdateParticipantRequest{
355 Room: testRoom,
356 Identity: "c1",
357 Permission: &livekit.ParticipantPermission{
358 CanPublish: false,
359 CanPublishData: true,
360 CanSubscribe: true,
361 },
362 })
363 require.NoError(t, err)
364
365 // ensure c1 no longer has track published, c2 no longer see track under C1
366 testutils.WithTimeout(t, func() string {
367 if len(c1.GetPublishedTrackIDs()) != 0 {
368 return "c1 did not unpublish tracks"
369 }
370 remoteC1 := c2.GetRemoteParticipant(c1.ID())
371 if remoteC1 == nil {
372 return "c2 doesn't know about c1"
373 }
374 if len(remoteC1.Tracks) != 0 {
375 return "c2 still has c1's tracks"
376 }
377 return ""
378 })
379 })
380 }
381}
382
383func TestCloseDisconnectedParticipantOnSignalClose(t *testing.T) {
384 _, _, finish := setupMultiNodeTest("TestCloseDisconnectedParticipantOnSignalClose")

Callers

nothing calls this directly

Calls 15

WithTimeoutFunction · 0.92
setupMultiNodeTestFunction · 0.85
createRTCClientFunction · 0.85
waitUntilConnectedFunction · 0.85
publishTracksForClientsFunction · 0.85
stopWritersFunction · 0.85
contextWithTokenFunction · 0.85
adminRoomTokenFunction · 0.85
SubscribedTracksMethod · 0.80
GetPublishedTrackIDsMethod · 0.80
GetRemoteParticipantMethod · 0.80
IDMethod · 0.65

Tested by

no test coverage detected