summaryrefslogtreecommitdiffstats
path: root/Twilio/Tests/Unit/Jwt/AccessTokenTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'Twilio/Tests/Unit/Jwt/AccessTokenTest.php')
-rw-r--r--Twilio/Tests/Unit/Jwt/AccessTokenTest.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/Twilio/Tests/Unit/Jwt/AccessTokenTest.php b/Twilio/Tests/Unit/Jwt/AccessTokenTest.php
index 4bea715..287eb3c 100644
--- a/Twilio/Tests/Unit/Jwt/AccessTokenTest.php
+++ b/Twilio/Tests/Unit/Jwt/AccessTokenTest.php
@@ -4,6 +4,7 @@ namespace Twilio\Tests\Unit\Jwt;
use Twilio\Jwt\Grants\ConversationsGrant;
use Twilio\Jwt\Grants\IpMessagingGrant;
+use Twilio\Jwt\Grants\ProgrammableVoiceGrant;
use Twilio\Jwt\JWT;
use Twilio\Tests\Unit\UnitTest;
use Twilio\Jwt\AccessToken;
@@ -108,4 +109,31 @@ class AccessTokenTest extends UnitTest {
$this->assertEquals('{}', json_encode($payload->grants->ip_messaging));
}
+ function testProgrammableVoiceGrant() {
+ $scat = new AccessToken(self::ACCOUNT_SID, self::SIGNING_KEY_SID, 'secret');
+ $scat->setIdentity('test identity');
+
+ $pvg = new ProgrammableVoiceGrant();
+ $pvg->setOutgoingApplication('AP123', array('foo' => 'bar'));
+
+ $scat->addGrant($pvg);
+
+ $token = $scat->toJWT();
+
+ $this->assertNotNull($token);
+ $payload = JWT::decode($token, 'secret');
+ $this->validateClaims($payload);
+
+ $grants = json_decode(json_encode($payload->grants), true);
+ $this->assertEquals(2, count($grants));
+ $this->assertEquals('test identity', $payload->grants->identity);
+
+ $decodedGrant = $grants['programmable_voice'];
+ $outgoing = $decodedGrant['outgoing'];
+ $this->assertEquals('AP123', $outgoing['application_sid']);
+
+ $params = $outgoing['params'];
+ $this->assertEquals('bar', $params['foo']);
+ }
+
} \ No newline at end of file