spec/jwt/access_token_spec.rb in twilio-ruby-5.0.0.rc17 vs spec/jwt/access_token_spec.rb in twilio-ruby-5.0.0.rc18
- old
+ new
@@ -40,29 +40,10 @@
expect(payload['grants']).not_to be_nil
expect(payload['grants'].count).to eq(1)
expect(payload['grants']['identity']).to eq('abc')
end
- it 'should be able to add conversation grant' do
- scat = Twilio::JWT::AccessToken.new 'AC123', 'SK123','secret'
- scat.add_grant(Twilio::JWT::AccessToken::ConversationsGrant.new)
-
- token = scat.to_s
- expect(token).not_to be_nil
- payload, header = JWT.decode token, 'secret'
-
- expect(payload['iss']).to eq('SK123')
- expect(payload['sub']).to eq('AC123')
- expect(payload['exp']).not_to be_nil
- expect(payload['exp']).to be >= Time.now.to_i
- expect(payload['jti']).not_to be_nil
- expect(payload['jti']).to start_with payload['iss']
- expect(payload['grants']).not_to be_nil
- expect(payload['grants'].count).to eq(1)
- expect(payload['grants']['rtc']).not_to be_nil
- end
-
it 'should be able to add endpoint grants' do
scat = Twilio::JWT::AccessToken.new 'AC123', 'SK123','secret'
grant = Twilio::JWT::AccessToken::IpMessagingGrant.new
grant.push_credential_sid = 'CR123'
@@ -117,11 +98,11 @@
expect(payload['grants']['data_sync']['endpoint_id']).to eq('EP123')
end
it 'should add rest grants' do
scat = Twilio::JWT::AccessToken.new 'AC123', 'SK123','secret'
- scat.add_grant(Twilio::JWT::AccessToken::ConversationsGrant.new)
+ scat.add_grant(Twilio::JWT::AccessToken::VideoGrant.new)
scat.add_grant(Twilio::JWT::AccessToken::IpMessagingGrant.new)
token = scat.to_s
expect(token).not_to be_nil
payload, header = JWT.decode token, 'secret'
@@ -132,11 +113,11 @@
expect(payload['exp']).to be >= Time.now.to_i
expect(payload['jti']).not_to be_nil
expect(payload['jti']).to start_with payload['iss']
expect(payload['grants']).not_to be_nil
expect(payload['grants'].count).to eq(2)
- expect(payload['grants']['rtc']).not_to be_nil
+ expect(payload['grants']['video']).not_to be_nil
expect(payload['grants']['ip_messaging']).not_to be_nil
end
it 'should add programmable voice grant' do
scat = Twilio::JWT::AccessToken.new 'AC123', 'SK123','secret'
@@ -161,6 +142,29 @@
expect(payload['grants']['voice']).not_to be_nil
expect(payload['grants']['voice']['outgoing']['application_sid']).to eq('AP123')
expect(payload['grants']['voice']['outgoing']['params']['foo']).to eq('bar')
end
-end
\ No newline at end of file
+ it 'should add video grant' do
+ scat = Twilio::JWT::AccessToken.new 'AC123', 'SK123','secret'
+ vg = Twilio::JWT::AccessToken::VideoGrant.new
+ vg.room = 'room'
+
+ scat.add_grant(vg)
+
+ token = scat.to_s
+ expect(token).not_to be_nil
+ payload, header = JWT.decode token, 'secret'
+
+ expect(payload['iss']).to eq('SK123')
+ expect(payload['sub']).to eq('AC123')
+ expect(payload['exp']).not_to be_nil
+ expect(payload['exp']).to be >= Time.now.to_i
+ expect(payload['jti']).not_to be_nil
+ expect(payload['jti']).to start_with payload['iss']
+ expect(payload['grants']).not_to be_nil
+ expect(payload['grants'].count).to eq(1)
+ expect(payload['grants']['video']).not_to be_nil
+ expect(payload['grants']['video']['room']).to eq('room')
+ end
+
+end