6
6
7
7
from twilio .jwt .access_token import AccessToken
8
8
from twilio .jwt .access_token .grants import (
9
- ConversationsGrant ,
10
9
IpMessagingGrant ,
11
10
SyncGrant ,
12
11
VoiceGrant ,
@@ -81,30 +80,17 @@ def test_identity(self):
81
80
'identity' : 'test@twilio.com'
82
81
}, decoded_token .payload ['grants' ])
83
82
84
- def test_conversations_grant (self ):
85
- scat = AccessToken (ACCOUNT_SID , SIGNING_KEY_SID , 'secret' )
86
- scat .add_grant (ConversationsGrant (configuration_profile_sid = 'CP123' ))
87
-
88
- token = scat .to_jwt ()
89
- assert_is_not_none (token )
90
- decoded_token = AccessToken .from_jwt (token , 'secret' )
91
- self ._validate_claims (decoded_token .payload )
92
- assert_equal (1 , len (decoded_token .payload ['grants' ]))
93
- assert_equal ({
94
- 'configuration_profile_sid' : 'CP123'
95
- }, decoded_token .payload ['grants' ]['rtc' ])
96
-
97
83
def test_video_grant (self ):
98
84
scat = AccessToken (ACCOUNT_SID , SIGNING_KEY_SID , 'secret' )
99
- scat .add_grant (VideoGrant (configuration_profile_sid = 'CP123' ))
85
+ scat .add_grant (VideoGrant (room = 'CP123' ))
100
86
101
87
token = scat .to_jwt ()
102
88
assert_is_not_none (token )
103
89
decoded_token = AccessToken .from_jwt (token , 'secret' )
104
90
self ._validate_claims (decoded_token .payload )
105
91
assert_equal (1 , len (decoded_token .payload ['grants' ]))
106
92
assert_equal ({
107
- 'configuration_profile_sid ' : 'CP123'
93
+ 'room ' : 'CP123'
108
94
}, decoded_token .payload ['grants' ]['video' ])
109
95
110
96
def test_ip_messaging_grant (self ):
@@ -139,15 +125,15 @@ def test_sync_grant(self):
139
125
140
126
def test_grants (self ):
141
127
scat = AccessToken (ACCOUNT_SID , SIGNING_KEY_SID , 'secret' )
142
- scat .add_grant (ConversationsGrant ())
128
+ scat .add_grant (VideoGrant ())
143
129
scat .add_grant (IpMessagingGrant ())
144
130
145
131
token = scat .to_jwt ()
146
132
assert_is_not_none (token )
147
133
decoded_token = AccessToken .from_jwt (token , 'secret' )
148
134
self ._validate_claims (decoded_token .payload )
149
135
assert_equal (2 , len (decoded_token .payload ['grants' ]))
150
- assert_equal ({}, decoded_token .payload ['grants' ]['rtc ' ])
136
+ assert_equal ({}, decoded_token .payload ['grants' ]['video ' ])
151
137
assert_equal ({}, decoded_token .payload ['grants' ]['ip_messaging' ])
152
138
153
139
def test_programmable_voice_grant (self ):
@@ -198,7 +184,7 @@ def test_task_router_grant(self):
198
184
199
185
def test_pass_grants_in_constructor (self ):
200
186
grants = [
201
- ConversationsGrant (),
187
+ VideoGrant (),
202
188
IpMessagingGrant ()
203
189
]
204
190
scat = AccessToken (ACCOUNT_SID , SIGNING_KEY_SID , 'secret' , grants = grants )
@@ -209,15 +195,15 @@ def test_pass_grants_in_constructor(self):
209
195
decoded_token = AccessToken .from_jwt (token , 'secret' )
210
196
self ._validate_claims (decoded_token .payload )
211
197
assert_equal (2 , len (decoded_token .payload ['grants' ]))
212
- assert_equal ({}, decoded_token .payload ['grants' ]['rtc ' ])
198
+ assert_equal ({}, decoded_token .payload ['grants' ]['video ' ])
213
199
assert_equal ({}, decoded_token .payload ['grants' ]['ip_messaging' ])
214
200
215
201
def test_constructor_validates_grants (self ):
216
- grants = [ConversationsGrant , 'GrantMeAccessToEverything' ]
202
+ grants = [VideoGrant , 'GrantMeAccessToEverything' ]
217
203
self .assertRaises (ValueError , AccessToken , ACCOUNT_SID , SIGNING_KEY_SID , 'secret' ,
218
204
grants = grants )
219
205
220
206
def test_add_grant_validates_grant (self ):
221
207
scat = AccessToken (ACCOUNT_SID , SIGNING_KEY_SID , 'secret' )
222
- scat .add_grant (ConversationsGrant ())
208
+ scat .add_grant (VideoGrant ())
223
209
self .assertRaises (ValueError , scat .add_grant , 'GrantRootAccess' )
0 commit comments