@@ -87,9 +87,9 @@ public void testCreateDefaultSession() throws OpenTokException {
87
87
88
88
verify (postRequestedFor (urlMatching ("/session/create" ))
89
89
.withRequestBody (matching (".*p2p.preference=enabled.*" ))
90
- .withRequestBody (matching (".*archiveMode=manual.*" ))
91
- . withHeader ( "X-TB-PARTNER-AUTH" , matching ( this .apiKey + ":" + this .apiSecret ))
92
- . withHeader ( "User-Agent" , matching ( ".*Opentok-Java-SDK/" + Version . VERSION + ".*" )) );
90
+ .withRequestBody (matching (".*archiveMode=manual.*" )));
91
+ Helpers . verifyPartnerAuth ( this .apiKey , this .apiSecret );
92
+ Helpers . verifyUserAgent ( );
93
93
}
94
94
95
95
@ Test
@@ -116,9 +116,9 @@ public void testCreateRoutedSession() throws OpenTokException {
116
116
117
117
verify (postRequestedFor (urlMatching ("/session/create" ))
118
118
// NOTE: this is a pretty bad way to verify, ideally we can decode the body and then query the object
119
- .withRequestBody (matching (".*p2p.preference=disabled.*" ))
120
- . withHeader ( "X-TB-PARTNER-AUTH" , matching ( this .apiKey + ":" + this .apiSecret ))
121
- . withHeader ( "User-Agent" , matching ( ".*Opentok-Java-SDK/" + Version . VERSION + ".*" )) );
119
+ .withRequestBody (matching (".*p2p.preference=disabled.*" )));
120
+ Helpers . verifyPartnerAuth ( this .apiKey , this .apiSecret );
121
+ Helpers . verifyUserAgent ( );
122
122
}
123
123
124
124
@ Test
@@ -146,9 +146,9 @@ public void testCreateLocationHintSession() throws OpenTokException {
146
146
147
147
verify (postRequestedFor (urlMatching ("/session/create" ))
148
148
// TODO: this is a pretty bad way to verify, ideally we can decode the body and then query the object
149
- .withRequestBody (matching (".*location=" +locationHint +".*" ))
150
- . withHeader ( "X-TB-PARTNER-AUTH" , matching ( this .apiKey + ":" + this .apiSecret ))
151
- . withHeader ( "User-Agent" , matching ( ".*Opentok-Java-SDK/" + Version . VERSION + ".*" )) );
149
+ .withRequestBody (matching (".*location=" +locationHint +".*" )));
150
+ Helpers . verifyPartnerAuth ( this .apiKey , this .apiSecret );
151
+ Helpers . verifyUserAgent ( );
152
152
}
153
153
154
154
@ Test
@@ -176,9 +176,9 @@ public void testCreateAlwaysArchivedSession() throws OpenTokException {
176
176
177
177
verify (postRequestedFor (urlMatching ("/session/create" ))
178
178
// TODO: this is a pretty bad way to verify, ideally we can decode the body and then query the object
179
- .withRequestBody (matching (".*archiveMode=always.*" ))
180
- . withHeader ( "X-TB-PARTNER-AUTH" , matching ( this .apiKey + ":" + this .apiSecret ))
181
- . withHeader ( "User-Agent" , matching ( ".*Opentok-Java-SDK/" + Version . VERSION + ".*" )) );
179
+ .withRequestBody (matching (".*archiveMode=always.*" )));
180
+ Helpers . verifyPartnerAuth ( this .apiKey , this .apiSecret );
181
+ Helpers . verifyUserAgent ( );
182
182
}
183
183
184
184
@ Test (expected = InvalidArgumentException .class )
@@ -400,9 +400,9 @@ public void testGetArchive() throws OpenTokException {
400
400
assertEquals ("http://tokbox.com.archive2.s3.amazonaws.com/123456%2F" +archiveId +"%2Farchive.mp4?Expires=13951" +
401
401
"94362&AWSAccessKeyId=AKIAI6LQCPIXYVWCQV6Q&Signature=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" , archive .getUrl ());
402
402
403
- verify (getRequestedFor (urlMatching ("/v2/partner/" +this .apiKey +"/archive/" +archiveId ))
404
- . withHeader ( "X-TB-PARTNER-AUTH" , matching ( this .apiKey + ":" + this .apiSecret ))
405
- . withHeader ( "User-Agent" , matching ( ".*Opentok-Java-SDK/" + Version . VERSION + ".*" )) );
403
+ verify (getRequestedFor (urlMatching ("/v2/partner/" +this .apiKey +"/archive/" +archiveId )));
404
+ Helpers . verifyPartnerAuth ( this .apiKey , this .apiSecret );
405
+ Helpers . verifyUserAgent ( );
406
406
}
407
407
408
408
// TODO: test get archive failure scenarios
@@ -505,9 +505,9 @@ public void testListArchives() throws OpenTokException {
505
505
assertThat (archives .get (0 ), instanceOf (Archive .class ));
506
506
assertEquals ("ef546c5a-4fd7-4e59-ab3d-f1cfb4148d1d" , archives .get (0 ).getId ());
507
507
508
- verify (getRequestedFor (urlMatching ("/v2/partner/" +this .apiKey +"/archive" ))
509
- . withHeader ( "X-TB-PARTNER-AUTH" , matching ( this .apiKey + ":" + this .apiSecret ))
510
- . withHeader ( "User-Agent" , matching ( ".*Opentok-Java-SDK/" + Version . VERSION + ".*" )) );
508
+ verify (getRequestedFor (urlMatching ("/v2/partner/" +this .apiKey +"/archive" )));
509
+ Helpers . verifyPartnerAuth ( this .apiKey , this .apiSecret );
510
+ Helpers . verifyUserAgent ( );
511
511
}
512
512
513
513
// TODO: test list archives with count and offset
@@ -541,11 +541,11 @@ public void testStartArchive() throws OpenTokException {
541
541
assertEquals (sessionId , archive .getSessionId ());
542
542
assertNotNull (archive .getId ());
543
543
544
- verify (postRequestedFor (urlMatching ("/v2/partner/" +this .apiKey +"/archive" ))
544
+ verify (postRequestedFor (urlMatching ("/v2/partner/" +this .apiKey +"/archive" )));
545
545
// TODO: find a way to match JSON without caring about spacing
546
546
//.withRequestBody(matching(".*"+".*"))
547
- . withHeader ( "X-TB-PARTNER-AUTH" , matching ( this .apiKey + ":" + this .apiSecret ))
548
- . withHeader ( "User-Agent" , matching ( ".*Opentok-Java-SDK/" + Version . VERSION + ".*" )) );
547
+ Helpers . verifyPartnerAuth ( this .apiKey , this .apiSecret );
548
+ Helpers . verifyUserAgent ( );
549
549
}
550
550
551
551
@ Test
@@ -576,11 +576,11 @@ public void testStartArchiveWithName() throws OpenTokException {
576
576
assertEquals (name , archive .getName ());
577
577
assertNotNull (archive .getId ());
578
578
579
- verify (postRequestedFor (urlMatching ("/v2/partner/" +this .apiKey +"/archive" ))
579
+ verify (postRequestedFor (urlMatching ("/v2/partner/" +this .apiKey +"/archive" )));
580
580
// TODO: find a way to match JSON without caring about spacing
581
581
//.withRequestBody(matching(".*"+".*"))
582
- . withHeader ( "X-TB-PARTNER-AUTH" , matching ( this .apiKey + ":" + this .apiSecret ))
583
- . withHeader ( "User-Agent" , matching ( ".*Opentok-Java-SDK/" + Version . VERSION + ".*" )) );
582
+ Helpers . verifyPartnerAuth ( this .apiKey , this .apiSecret );
583
+ Helpers . verifyUserAgent ( );
584
584
}
585
585
586
586
@ Test
@@ -612,11 +612,11 @@ public void testStartVoiceOnlyArchive() throws OpenTokException {
612
612
assertEquals (sessionId , archive .getSessionId ());
613
613
assertNotNull (archive .getId ());
614
614
615
- verify (postRequestedFor (urlMatching ("/v2/partner/" +this .apiKey +"/archive" ))
615
+ verify (postRequestedFor (urlMatching ("/v2/partner/" +this .apiKey +"/archive" )));
616
616
// TODO: find a way to match JSON without caring about spacing
617
617
//.withRequestBody(matching(".*"+".*"))
618
- . withHeader ( "X-TB-PARTNER-AUTH" , matching ( this .apiKey + ":" + this .apiSecret ))
619
- . withHeader ( "User-Agent" , matching ( ".*Opentok-Java-SDK/" + Version . VERSION + ".*" )) );
618
+ Helpers . verifyPartnerAuth ( this .apiKey , this .apiSecret );
619
+ Helpers . verifyUserAgent ( );
620
620
}
621
621
622
622
@ Test
@@ -648,11 +648,11 @@ public void testStartComposedArchive() throws OpenTokException {
648
648
assertNotNull (archive .getId ());
649
649
assertEquals (OutputMode .COMPOSED , archive .getOutputMode ());
650
650
651
- verify (postRequestedFor (urlMatching ("/v2/partner/" +this .apiKey +"/archive" ))
651
+ verify (postRequestedFor (urlMatching ("/v2/partner/" +this .apiKey +"/archive" )));
652
652
// TODO: find a way to match JSON without caring about spacing
653
653
//.withRequestBody(matching(".*"+".*"))
654
- . withHeader ( "X-TB-PARTNER-AUTH" , matching ( this .apiKey + ":" + this .apiSecret ))
655
- . withHeader ( "User-Agent" , matching ( ".*Opentok-Java-SDK/" + Version . VERSION + ".*" )) );
654
+ Helpers . verifyPartnerAuth ( this .apiKey , this .apiSecret );
655
+ Helpers . verifyUserAgent ( );
656
656
}
657
657
658
658
@ Test
@@ -685,11 +685,11 @@ public void testStartIndividualArchive() throws OpenTokException {
685
685
assertNotNull (archive .getId ());
686
686
assertEquals (OutputMode .INDIVIDUAL , archive .getOutputMode ());
687
687
688
- verify (postRequestedFor (urlMatching ("/v2/partner/" +this .apiKey +"/archive" ))
688
+ verify (postRequestedFor (urlMatching ("/v2/partner/" +this .apiKey +"/archive" )));
689
689
// TODO: find a way to match JSON without caring about spacing
690
690
//.withRequestBody(matching(".*"+".*"))
691
- . withHeader ( "X-TB-PARTNER-AUTH" , matching ( this .apiKey + ":" + this .apiSecret ))
692
- . withHeader ( "User-Agent" , matching ( ".*Opentok-Java-SDK/" + Version . VERSION + ".*" )) );
691
+ Helpers . verifyPartnerAuth ( this .apiKey , this .apiSecret );
692
+ Helpers . verifyUserAgent ( );
693
693
}
694
694
695
695
// TODO: test start archive with name
@@ -722,9 +722,9 @@ public void testStopArchive() throws OpenTokException {
722
722
assertEquals ("SESSIONID" , archive .getSessionId ());
723
723
assertEquals (archiveId , archive .getId ());
724
724
725
- verify (postRequestedFor (urlMatching ("/v2/partner/" +this .apiKey +"/archive/" +archiveId +"/stop" ))
726
- . withHeader ( "X-TB-PARTNER-AUTH" , matching ( this .apiKey + ":" + this .apiSecret ))
727
- . withHeader ( "User-Agent" , matching ( ".*Opentok-Java-SDK/" + Version . VERSION + ".*" )) );
725
+ verify (postRequestedFor (urlMatching ("/v2/partner/" +this .apiKey +"/archive/" +archiveId +"/stop" )));
726
+ Helpers . verifyPartnerAuth ( this .apiKey , this .apiSecret );
727
+ Helpers . verifyUserAgent ( );
728
728
}
729
729
730
730
// TODO: test stop archive failure scenarios
@@ -739,9 +739,9 @@ public void testDeleteArchive() throws OpenTokException {
739
739
740
740
sdk .deleteArchive (archiveId );
741
741
742
- verify (deleteRequestedFor (urlMatching ("/v2/partner/" +this .apiKey +"/archive/" +archiveId ))
743
- . withHeader ( "X-TB-PARTNER-AUTH" , matching ( this .apiKey + ":" + this .apiSecret ))
744
- . withHeader ( "User-Agent" , matching ( ".*Opentok-Java-SDK/" + Version . VERSION + ".*" )) );
742
+ verify (deleteRequestedFor (urlMatching ("/v2/partner/" +this .apiKey +"/archive/" +archiveId )));
743
+ Helpers . verifyPartnerAuth ( this .apiKey , this .apiSecret );
744
+ Helpers . verifyUserAgent ( );
745
745
}
746
746
747
747
// TODO: test delete archive failure scenarios
@@ -820,4 +820,5 @@ public void testDeleteArchive() throws OpenTokException {
820
820
821
821
assertNotNull (archive );
822
822
}
823
+
823
824
}
0 commit comments