77import json
88import datetime
99import pytz
10+ from .validate_jwt import validate_jwt_header
1011
1112from opentok import OpenTok , Archive , ArchiveList , OutputModes , __version__
1213
@@ -41,7 +42,7 @@ def test_start_archive(self):
4142
4243 archive = self .opentok .start_archive (self .session_id )
4344
44- expect ( httpretty .last_request ().headers [u ('x-tb-partner -auth' )]). to . equal ( self . api_key + u ( ':' ) + self . api_secret )
45+ validate_jwt_header ( self , httpretty .last_request ().headers [u ('x-tb-opentok -auth' )])
4546 expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
4647 expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
4748 # non-deterministic json encoding. have to decode to test it properly
@@ -92,7 +93,7 @@ def test_start_archive_with_name(self):
9293
9394 archive = self .opentok .start_archive (self .session_id , name = u ('ARCHIVE NAME' ))
9495
95- expect ( httpretty .last_request ().headers [u ('x-tb-partner -auth' )]). to . equal ( self . api_key + u ( ':' ) + self . api_secret )
96+ validate_jwt_header ( self , httpretty .last_request ().headers [u ('x-tb-opentok -auth' )])
9697 expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
9798 expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
9899 # non-deterministic json encoding. have to decode to test it properly
@@ -141,7 +142,7 @@ def test_start_voice_archive(self):
141142
142143 archive = self .opentok .start_archive (self .session_id , name = u ('ARCHIVE NAME' ), has_video = False )
143144
144- expect ( httpretty .last_request ().headers [u ('x-tb-partner -auth' )]). to . equal ( self . api_key + u ( ':' ) + self . api_secret )
145+ validate_jwt_header ( self , httpretty .last_request ().headers [u ('x-tb-opentok -auth' )])
145146 expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
146147 expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
147148 # non-deterministic json encoding. have to decode to test it properly
@@ -192,7 +193,7 @@ def test_start_individual_archive(self):
192193
193194 archive = self .opentok .start_archive (self .session_id , name = u ('ARCHIVE NAME' ), output_mode = OutputModes .individual )
194195
195- expect ( httpretty .last_request ().headers [u ('x-tb-partner -auth' )]). to . equal ( self . api_key + u ( ':' ) + self . api_secret )
196+ validate_jwt_header ( self , httpretty .last_request ().headers [u ('x-tb-opentok -auth' )])
196197 expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
197198 expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
198199 # non-deterministic json encoding. have to decode to test it properly
@@ -244,7 +245,7 @@ def test_start_composed_archive(self):
244245
245246 archive = self .opentok .start_archive (self .session_id , name = u ('ARCHIVE NAME' ), output_mode = OutputModes .composed )
246247
247- expect ( httpretty .last_request ().headers [u ('x-tb-partner -auth' )]). to . equal ( self . api_key + u ( ':' ) + self . api_secret )
248+ validate_jwt_header ( self , httpretty .last_request ().headers [u ('x-tb-opentok -auth' )])
248249 expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
249250 expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
250251 # non-deterministic json encoding. have to decode to test it properly
@@ -297,7 +298,7 @@ def test_stop_archive(self):
297298
298299 archive = self .opentok .stop_archive (archive_id )
299300
300- expect ( httpretty .last_request ().headers [u ('x-tb-partner -auth' )]). to . equal ( self . api_key + u ( ':' ) + self . api_secret )
301+ validate_jwt_header ( self , httpretty .last_request ().headers [u ('x-tb-opentok -auth' )])
301302 expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
302303 expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
303304 expect (archive ).to .be .an (Archive )
@@ -324,7 +325,7 @@ def test_delete_archive(self):
324325
325326 self .opentok .delete_archive (archive_id )
326327
327- expect ( httpretty .last_request ().headers [u ('x-tb-partner -auth' )]). to . equal ( self . api_key + u ( ':' ) + self . api_secret )
328+ validate_jwt_header ( self , httpretty .last_request ().headers [u ('x-tb-opentok -auth' )])
328329 expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
329330 expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
330331
@@ -353,7 +354,7 @@ def test_find_archive(self):
353354
354355 archive = self .opentok .get_archive (archive_id )
355356
356- expect ( httpretty .last_request ().headers [u ('x-tb-partner -auth' )]). to . equal ( self . api_key + u ( ':' ) + self . api_secret )
357+ validate_jwt_header ( self , httpretty .last_request ().headers [u ('x-tb-opentok -auth' )])
357358 expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
358359 expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
359360 expect (archive ).to .be .an (Archive )
@@ -468,7 +469,7 @@ def test_find_archives(self):
468469
469470 archive_list = self .opentok .get_archives ()
470471
471- expect ( httpretty .last_request ().headers [u ('x-tb-partner -auth' )]). to . equal ( self . api_key + u ( ':' ) + self . api_secret )
472+ validate_jwt_header ( self , httpretty .last_request ().headers [u ('x-tb-opentok -auth' )])
472473 expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
473474 expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
474475 expect (archive_list ).to .be .an (ArchiveList )
@@ -528,7 +529,7 @@ def test_find_archives_with_offset(self):
528529
529530 archive_list = self .opentok .get_archives (offset = 3 )
530531
531- expect ( httpretty .last_request ().headers [u ('x-tb-partner -auth' )]). to . equal ( self . api_key + u ( ':' ) + self . api_secret )
532+ validate_jwt_header ( self , httpretty .last_request ().headers [u ('x-tb-opentok -auth' )])
532533 expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
533534 expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
534535 expect (httpretty .last_request ()).to .have .property ("querystring" ).being .equal ({
@@ -578,7 +579,7 @@ def test_find_archives_with_count(self):
578579
579580 archive_list = self .opentok .get_archives (count = 2 )
580581
581- expect ( httpretty .last_request ().headers [u ('x-tb-partner -auth' )]). to . equal ( self . api_key + u ( ':' ) + self . api_secret )
582+ validate_jwt_header ( self , httpretty .last_request ().headers [u ('x-tb-opentok -auth' )])
582583 expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
583584 expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
584585 expect (httpretty .last_request ()).to .have .property ("querystring" ).being .equal ({
@@ -654,7 +655,7 @@ def test_find_archives_with_offset_and_count(self):
654655
655656 archive_list = self .opentok .get_archives (count = 4 , offset = 2 )
656657
657- expect ( httpretty .last_request ().headers [u ('x-tb-partner -auth' )]). to . equal ( self . api_key + u ( ':' ) + self . api_secret )
658+ validate_jwt_header ( self , httpretty .last_request ().headers [u ('x-tb-opentok -auth' )])
658659 expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
659660 expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
660661 expect (httpretty .last_request ()).to .have .property ("querystring" ).being .equal ({
0 commit comments