File tree 2 files changed +31
-0
lines changed
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -267,6 +267,23 @@ def _generate_payload
267
267
payload
268
268
end
269
269
end
270
+
271
+ class PlaybackGrant
272
+ include AccessTokenGrant
273
+ attr_accessor :grant
274
+
275
+ def _key
276
+ 'player'
277
+ end
278
+
279
+ def _generate_payload
280
+ payload = { }
281
+
282
+ payload [ :grant ] = grant if grant
283
+
284
+ payload
285
+ end
286
+ end
270
287
end
271
288
end
272
289
end
Original file line number Diff line number Diff line change 142
142
expect ( payload [ 'grants' ] [ 'task_router' ] [ 'role' ] ) . to eq ( 'worker' )
143
143
end
144
144
145
+ it 'Playback grant' do
146
+ playback_grant = Twilio ::JWT ::AccessToken ::PlaybackGrant . new
147
+ grant = {
148
+ 'requestCredentials' : nil ,
149
+ 'playbackUrl' : 'https://000.us-east-1.playback.live-video.net/api/video/v1/us-east-000.channel.000?token=xxxxx' ,
150
+ 'playerStreamerSid' : 'VJXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
151
+ }
152
+ playback_grant . grant = grant
153
+ @scat . add_grant ( playback_grant )
154
+ payload , _ = JWT . decode @scat . to_s , 'secret'
155
+ expect ( payload [ 'grants' ] . count ) . to eq ( 1 )
156
+ expect ( payload [ 'grants' ] [ 'player' ] [ 'grant' ] ) . to eq ( grant )
157
+ end
158
+
145
159
it 'multiple grants' do
146
160
room_grant = Twilio ::JWT ::AccessToken ::VideoGrant . new
147
161
room_grant . room = 'RM123'
You can’t perform that action at this time.
0 commit comments