7
7
import json
8
8
import datetime
9
9
import pytz
10
+ from .validate_jwt import validate_jwt_header
10
11
11
12
from opentok import OpenTok , Archive , ArchiveList , OutputModes , __version__
12
13
@@ -41,7 +42,7 @@ def test_start_archive(self):
41
42
42
43
archive = self .opentok .start_archive (self .session_id )
43
44
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' )])
45
46
expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
46
47
expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
47
48
# non-deterministic json encoding. have to decode to test it properly
@@ -92,7 +93,7 @@ def test_start_archive_with_name(self):
92
93
93
94
archive = self .opentok .start_archive (self .session_id , name = u ('ARCHIVE NAME' ))
94
95
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' )])
96
97
expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
97
98
expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
98
99
# non-deterministic json encoding. have to decode to test it properly
@@ -141,7 +142,7 @@ def test_start_voice_archive(self):
141
142
142
143
archive = self .opentok .start_archive (self .session_id , name = u ('ARCHIVE NAME' ), has_video = False )
143
144
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' )])
145
146
expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
146
147
expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
147
148
# non-deterministic json encoding. have to decode to test it properly
@@ -192,7 +193,7 @@ def test_start_individual_archive(self):
192
193
193
194
archive = self .opentok .start_archive (self .session_id , name = u ('ARCHIVE NAME' ), output_mode = OutputModes .individual )
194
195
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' )])
196
197
expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
197
198
expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
198
199
# non-deterministic json encoding. have to decode to test it properly
@@ -244,7 +245,7 @@ def test_start_composed_archive(self):
244
245
245
246
archive = self .opentok .start_archive (self .session_id , name = u ('ARCHIVE NAME' ), output_mode = OutputModes .composed )
246
247
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' )])
248
249
expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
249
250
expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
250
251
# non-deterministic json encoding. have to decode to test it properly
@@ -297,7 +298,7 @@ def test_stop_archive(self):
297
298
298
299
archive = self .opentok .stop_archive (archive_id )
299
300
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' )])
301
302
expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
302
303
expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
303
304
expect (archive ).to .be .an (Archive )
@@ -324,7 +325,7 @@ def test_delete_archive(self):
324
325
325
326
self .opentok .delete_archive (archive_id )
326
327
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' )])
328
329
expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
329
330
expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
330
331
@@ -353,7 +354,7 @@ def test_find_archive(self):
353
354
354
355
archive = self .opentok .get_archive (archive_id )
355
356
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' )])
357
358
expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
358
359
expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
359
360
expect (archive ).to .be .an (Archive )
@@ -468,7 +469,7 @@ def test_find_archives(self):
468
469
469
470
archive_list = self .opentok .get_archives ()
470
471
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' )])
472
473
expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
473
474
expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
474
475
expect (archive_list ).to .be .an (ArchiveList )
@@ -528,7 +529,7 @@ def test_find_archives_with_offset(self):
528
529
529
530
archive_list = self .opentok .get_archives (offset = 3 )
530
531
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' )])
532
533
expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
533
534
expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
534
535
expect (httpretty .last_request ()).to .have .property ("querystring" ).being .equal ({
@@ -578,7 +579,7 @@ def test_find_archives_with_count(self):
578
579
579
580
archive_list = self .opentok .get_archives (count = 2 )
580
581
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' )])
582
583
expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
583
584
expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
584
585
expect (httpretty .last_request ()).to .have .property ("querystring" ).being .equal ({
@@ -654,7 +655,7 @@ def test_find_archives_with_offset_and_count(self):
654
655
655
656
archive_list = self .opentok .get_archives (count = 4 , offset = 2 )
656
657
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' )])
658
659
expect (httpretty .last_request ().headers [u ('user-agent' )]).to .contain (u ('OpenTok-Python-SDK/' )+ __version__ )
659
660
expect (httpretty .last_request ().headers [u ('content-type' )]).to .equal (u ('application/json' ))
660
661
expect (httpretty .last_request ()).to .have .property ("querystring" ).being .equal ({
0 commit comments