@@ -742,31 +742,53 @@ public function testFailsWhenGeneratingTokenUsingInvalidRole(): void
742
742
$ token = $ this ->opentok ->generateToken ('SESSIONID ' , array ('role ' => 'notarole ' ), true );
743
743
}
744
744
745
- public function testWillCreateJwt (): void
745
+ public function testWillCreateLegacyT1WhenRequested (): void
746
746
{
747
- $ openTok = new OpenTok ('my-api-key ' , 'my-super-long-and-cool-api-secret ' );
748
- $ token = $ openTok ->generateToken ('some-token-value ' );
747
+ $ openTok = new OpenTok ('12345678 ' , '0123456789abcdef0123456789abcdef0123456789 ' );
748
+ $ token = $ openTok ->generateToken ('1_MX4xMjM0NTY3OH4-VGh1IEZlYiAyNyAwNDozODozMSBQU1QgMjAxNH4wLjI0NDgyMjI ' , [], true );
749
749
750
- $ config = Configuration::forSymmetricSigner (
751
- new \Lcobucci \JWT \Signer \Hmac \Sha256 (),
752
- \Lcobucci \JWT \Signer \Key \InMemory::plainText ('my-super-long-and-cool-api-secret ' )
753
- );
754
-
755
- $ token = $ config ->parser ()->parse ($ token );
756
- $ this ->assertInstanceOf (Plain::class, $ token );
750
+ $ this ->assertEquals ('T1 ' , substr ($ token , 0 , 2 ));
751
+ }
757
752
758
- $ this -> assertTrue ( $ config -> validator ()-> validate ( $ token , new \ Lcobucci \ JWT \ Validation \ Constraint \ SignedWith (
759
- $ config -> signer (),
760
- $ config -> signingKey ()
761
- )) );
753
+ public function testWillCreateLegacyT1DirectlyToBypassExpBug (): void
754
+ {
755
+ $ openTok = new OpenTok ( ' 12345678 ' , ' 0123456789abcdef0123456789abcdef0123456789 ' );
756
+ $ token = $ openTok -> generateToken ( ' 1_MX4xMjM0NTY3OH4-VGh1IEZlYiAyNyAwNDozODozMSBQU1QgMjAxNH4wLjI0NDgyMjI ' , [] );
762
757
763
- $ this ->assertEquals ('my-api-key ' , $ token ->claims ()->get ('iss ' ));
764
- $ this ->assertEquals ('some-token-value ' , $ token ->claims ()->get ('session_id ' ));
765
- $ this ->assertEquals ('publisher ' , $ token ->claims ()->get ('role ' ));
766
- $ this ->assertEquals ('project ' , $ token ->claims ()->get ('ist ' ));
767
- $ this ->assertEquals ('session.connect ' , $ token ->claims ()->get ('scope ' ));
758
+ $ this ->assertEquals ('T1 ' , substr ($ token , 0 , 2 ));
768
759
}
769
760
761
+ /**
762
+ * Makes sure that a JWT is generated for the client-side token
763
+ *
764
+ * Currently disabled due to the backend requiring an `exp` claim, which was
765
+ * not required on T1s. Uncomment when the backend is fixed. - CRT
766
+ */
767
+ // public function testWillCreateJwt(): void
768
+ // {
769
+ // $openTok = new OpenTok('my-api-key', 'my-super-long-and-cool-api-secret');
770
+ // $token = $openTok->generateToken('some-token-value');
771
+
772
+ // $config = Configuration::forSymmetricSigner(
773
+ // new \Lcobucci\JWT\Signer\Hmac\Sha256(),
774
+ // \Lcobucci\JWT\Signer\Key\InMemory::plainText('my-super-long-and-cool-api-secret')
775
+ // );
776
+
777
+ // $token = $config->parser()->parse($token);
778
+ // $this->assertInstanceOf(Plain::class, $token);
779
+
780
+ // $this->assertTrue($config->validator()->validate($token, new \Lcobucci\JWT\Validation\Constraint\SignedWith(
781
+ // $config->signer(),
782
+ // $config->signingKey()
783
+ // )));
784
+
785
+ // $this->assertEquals('my-api-key', $token->claims()->get('iss'));
786
+ // $this->assertEquals('some-token-value', $token->claims()->get('session_id'));
787
+ // $this->assertEquals('publisher', $token->claims()->get('role'));
788
+ // $this->assertEquals('project', $token->claims()->get('ist'));
789
+ // $this->assertEquals('session.connect', $token->claims()->get('scope'));
790
+ // }
791
+
770
792
public function testStartsArchive (): void
771
793
{
772
794
// Arrange
0 commit comments