MCPcopy Create free account
hub / github.com/livekit/livekit / TestMultiNodeRefreshToken

Function TestMultiNodeRefreshToken

test/multinode_test.go:200–250  ·  view source on GitHub ↗

ensure that token accurately reflects out of band updates

(t *testing.T)

Source from the content-addressed store, hash-verified

198
199// ensure that token accurately reflects out of band updates
200func TestMultiNodeRefreshToken(t *testing.T) {
201 _, _, finish := setupMultiNodeTest("TestMultiNodeJoinAfterClose")
202 defer finish()
203
204 for _, testRTCServicePath := range testRTCServicePaths {
205 t.Run(fmt.Sprintf("testRTCServicePath=%s", testRTCServicePath.String()), func(t *testing.T) {
206 // a participant joining with full permissions
207 c1 := createRTCClient("c1", defaultServerPort, testRTCServicePath, nil)
208 waitUntilConnected(t, c1)
209
210 // update permissions and metadata
211 ctx := contextWithToken(adminRoomToken(testRoom))
212 _, err := roomClient.UpdateParticipant(ctx, &livekit.UpdateParticipantRequest{
213 Room: testRoom,
214 Identity: "c1",
215 Permission: &livekit.ParticipantPermission{
216 CanPublish: false,
217 CanSubscribe: true,
218 },
219 Metadata: "metadata",
220 })
221 require.NoError(t, err)
222
223 testutils.WithTimeout(t, func() string {
224 if c1.RefreshToken() == "" {
225 return "did not receive refresh token"
226 }
227 // parse token to ensure it's correct
228 verifier, err := auth.ParseAPIToken(c1.RefreshToken())
229 require.NoError(t, err)
230
231 _, grants, err := verifier.Verify(testApiSecret)
232 require.NoError(t, err)
233
234 if grants.Metadata != "metadata" {
235 return "metadata did not match"
236 }
237 if *grants.Video.CanPublish {
238 return "canPublish should be false"
239 }
240 if *grants.Video.CanPublishData {
241 return "canPublishData should be false"
242 }
243 if !*grants.Video.CanSubscribe {
244 return "canSubscribe should be true"
245 }
246 return ""
247 })
248 })
249 }
250}
251
252// ensure that token accurately reflects out of band updates
253func TestMultiNodeUpdateAttributes(t *testing.T) {

Callers

nothing calls this directly

Calls 11

WithTimeoutFunction · 0.92
setupMultiNodeTestFunction · 0.85
createRTCClientFunction · 0.85
waitUntilConnectedFunction · 0.85
contextWithTokenFunction · 0.85
adminRoomTokenFunction · 0.85
RefreshTokenMethod · 0.80
VerifyMethod · 0.65
RunMethod · 0.45
StringMethod · 0.45
UpdateParticipantMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…