ensure that token accurately reflects out of band updates
(t *testing.T)
| 198 | |
| 199 | // ensure that token accurately reflects out of band updates |
| 200 | func 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 |
| 253 | func TestMultiNodeUpdateAttributes(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…