spec/jwt/access_token_spec.rb in twilio-ruby-5.0.0.rc14 vs spec/jwt/access_token_spec.rb in twilio-ruby-5.0.0.rc15
- old
+ new
@@ -109,6 +109,31 @@
expect(payload['grants'].count).to eq(2)
expect(payload['grants']['rtc']).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'
+ pvg = Twilio::JWT::AccessToken::VoiceGrant.new
+ pvg.outgoing_application_sid = 'AP123'
+ pvg.outgoing_application_params = { :foo => 'bar' }
+
+ scat.add_grant(pvg)
+
+ 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']['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