File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,25 @@ def test_programmable_voice_grant(self):
190190 }
191191 }, decoded_token .payload ['grants' ]['voice' ])
192192
193+ def test_programmable_voice_grant_incoming (self ):
194+ grant = VoiceGrant (
195+ incoming_allow = True
196+ )
197+
198+ scat = AccessToken (ACCOUNT_SID , SIGNING_KEY_SID , 'secret' )
199+ scat .add_grant (grant )
200+
201+ token = scat .to_jwt ()
202+ assert_is_not_none (token )
203+ decoded_token = AccessToken .from_jwt (token , 'secret' )
204+ self ._validate_claims (decoded_token .payload )
205+ assert_equal (1 , len (decoded_token .payload ['grants' ]))
206+ assert_equal ({
207+ 'incoming' : {
208+ 'allow' : True
209+ }
210+ }, decoded_token .payload ['grants' ]['voice' ])
211+
193212 def test_task_router_grant (self ):
194213 grant = TaskRouterGrant (
195214 workspace_sid = 'WS123' ,
Original file line number Diff line number Diff line change @@ -98,10 +98,13 @@ def to_payload(self):
9898class VoiceGrant (AccessTokenGrant ):
9999 """Grant to access Twilio Programmable Voice"""
100100 def __init__ (self ,
101+ incoming_allow = None ,
101102 outgoing_application_sid = None ,
102103 outgoing_application_params = None ,
103104 push_credential_sid = None ,
104105 endpoint_id = None ):
106+ self .incoming_allow = incoming_allow
107+ """ :type : bool """
105108 self .outgoing_application_sid = outgoing_application_sid
106109 """ :type : str """
107110 self .outgoing_application_params = outgoing_application_params
@@ -117,6 +120,10 @@ def key(self):
117120
118121 def to_payload (self ):
119122 grant = {}
123+ if self .incoming_allow is True :
124+ grant ['incoming' ] = {}
125+ grant ['incoming' ]['allow' ] = True
126+
120127 if self .outgoing_application_sid :
121128 grant ['outgoing' ] = {}
122129 grant ['outgoing' ]['application_sid' ] = self .outgoing_application_sid
You can’t perform that action at this time.
0 commit comments