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 ,
@@ -80,30 +79,17 @@ def test_identity(self):
80
79
'identity' : 'test@twilio.com'
81
80
}, decoded_token .payload ['grants' ])
82
81
83
- def test_conversations_grant (self ):
84
- scat = AccessToken (ACCOUNT_SID , SIGNING_KEY_SID , 'secret' )
85
- scat .add_grant (ConversationsGrant (configuration_profile_sid = 'CP123' ))
86
-
87
- token = scat .to_jwt ()
88
- assert_is_not_none (token )
89
- decoded_token = AccessToken .from_jwt (token , 'secret' )
90
- self ._validate_claims (decoded_token .payload )
91
- assert_equal (1 , len (decoded_token .payload ['grants' ]))
92
- assert_equal ({
93
- 'configuration_profile_sid' : 'CP123'
94
- }, decoded_token .payload ['grants' ]['rtc' ])
95
-
96
82
def test_video_grant (self ):
97
83
scat = AccessToken (ACCOUNT_SID , SIGNING_KEY_SID , 'secret' )
98
- scat .add_grant (VideoGrant (configuration_profile_sid = 'CP123' ))
84
+ scat .add_grant (VideoGrant (room = 'CP123' ))
99
85
100
86
token = scat .to_jwt ()
101
87
assert_is_not_none (token )
102
88
decoded_token = AccessToken .from_jwt (token , 'secret' )
103
89
self ._validate_claims (decoded_token .payload )
104
90
assert_equal (1 , len (decoded_token .payload ['grants' ]))
105
91
assert_equal ({
106
- 'configuration_profile_sid ' : 'CP123'
92
+ 'room ' : 'CP123'
107
93
}, decoded_token .payload ['grants' ]['video' ])
108
94
109
95
def test_ip_messaging_grant (self ):
@@ -138,15 +124,15 @@ def test_sync_grant(self):
138
124
139
125
def test_grants (self ):
140
126
scat = AccessToken (ACCOUNT_SID , SIGNING_KEY_SID , 'secret' )
141
- scat .add_grant (ConversationsGrant ())
127
+ scat .add_grant (VideoGrant ())
142
128
scat .add_grant (IpMessagingGrant ())
143
129
144
130
token = scat .to_jwt ()
145
131
assert_is_not_none (token )
146
132
decoded_token = AccessToken .from_jwt (token , 'secret' )
147
133
self ._validate_claims (decoded_token .payload )
148
134
assert_equal (2 , len (decoded_token .payload ['grants' ]))
149
- assert_equal ({}, decoded_token .payload ['grants' ]['rtc ' ])
135
+ assert_equal ({}, decoded_token .payload ['grants' ]['video ' ])
150
136
assert_equal ({}, decoded_token .payload ['grants' ]['ip_messaging' ])
151
137
152
138
def test_programmable_voice_grant (self ):
@@ -176,7 +162,7 @@ def test_programmable_voice_grant(self):
176
162
177
163
def test_pass_grants_in_constructor (self ):
178
164
grants = [
179
- ConversationsGrant (),
165
+ VideoGrant (),
180
166
IpMessagingGrant ()
181
167
]
182
168
scat = AccessToken (ACCOUNT_SID , SIGNING_KEY_SID , 'secret' , grants = grants )
@@ -187,15 +173,15 @@ def test_pass_grants_in_constructor(self):
187
173
decoded_token = AccessToken .from_jwt (token , 'secret' )
188
174
self ._validate_claims (decoded_token .payload )
189
175
assert_equal (2 , len (decoded_token .payload ['grants' ]))
190
- assert_equal ({}, decoded_token .payload ['grants' ]['rtc ' ])
176
+ assert_equal ({}, decoded_token .payload ['grants' ]['video ' ])
191
177
assert_equal ({}, decoded_token .payload ['grants' ]['ip_messaging' ])
192
178
193
179
def test_constructor_validates_grants (self ):
194
- grants = [ConversationsGrant , 'GrantMeAccessToEverything' ]
180
+ grants = [VideoGrant , 'GrantMeAccessToEverything' ]
195
181
self .assertRaises (ValueError , AccessToken , ACCOUNT_SID , SIGNING_KEY_SID , 'secret' ,
196
182
grants = grants )
197
183
198
184
def test_add_grant_validates_grant (self ):
199
185
scat = AccessToken (ACCOUNT_SID , SIGNING_KEY_SID , 'secret' )
200
- scat .add_grant (ConversationsGrant ())
186
+ scat .add_grant (VideoGrant ())
201
187
self .assertRaises (ValueError , scat .add_grant , 'GrantRootAccess' )
0 commit comments