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):
190
190
}
191
191
}, decoded_token .payload ['grants' ]['voice' ])
192
192
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
+
193
212
def test_task_router_grant (self ):
194
213
grant = TaskRouterGrant (
195
214
workspace_sid = 'WS123' ,
Original file line number Diff line number Diff line change @@ -98,10 +98,13 @@ def to_payload(self):
98
98
class VoiceGrant (AccessTokenGrant ):
99
99
"""Grant to access Twilio Programmable Voice"""
100
100
def __init__ (self ,
101
+ incoming_allow = None ,
101
102
outgoing_application_sid = None ,
102
103
outgoing_application_params = None ,
103
104
push_credential_sid = None ,
104
105
endpoint_id = None ):
106
+ self .incoming_allow = incoming_allow
107
+ """ :type : bool """
105
108
self .outgoing_application_sid = outgoing_application_sid
106
109
""" :type : str """
107
110
self .outgoing_application_params = outgoing_application_params
@@ -117,6 +120,10 @@ def key(self):
117
120
118
121
def to_payload (self ):
119
122
grant = {}
123
+ if self .incoming_allow is True :
124
+ grant ['incoming' ] = {}
125
+ grant ['incoming' ]['allow' ] = True
126
+
120
127
if self .outgoing_application_sid :
121
128
grant ['outgoing' ] = {}
122
129
grant ['outgoing' ]['application_sid' ] = self .outgoing_application_sid
You can’t perform that action at this time.
0 commit comments