Skip to content

Commit 8d93b2a

Browse files
authored
Merge branch 'main' into feature/jwt-change
2 parents 6284770 + 3f10580 commit 8d93b2a

File tree

1 file changed

+41
-19
lines changed

1 file changed

+41
-19
lines changed

tests/OpenTokTest/OpenTokTest.php

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -742,31 +742,53 @@ public function testFailsWhenGeneratingTokenUsingInvalidRole(): void
742742
$token = $this->opentok->generateToken('SESSIONID', array('role' => 'notarole'), true);
743743
}
744744

745-
public function testWillCreateJwt(): void
745+
public function testWillCreateLegacyT1WhenRequested(): void
746746
{
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);
749749

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+
}
757752

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', []);
762757

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));
768759
}
769760

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+
770792
public function testStartsArchive(): void
771793
{
772794
// Arrange

0 commit comments

Comments
 (0)