updated-packages

This commit is contained in:
RafficMohammed
2023-01-08 00:13:22 +05:30
parent 3ff7df7487
commit da241bacb6
12659 changed files with 563377 additions and 510538 deletions

View File

@@ -1,37 +1,18 @@
<?php namespace League\OAuth1\Client\Tests;
/**
* Part of the Sentry package.
*
* NOTICE OF LICENSE
*
* Licensed under the 3-clause BSD License.
*
* This source file is subject to the 3-clause BSD License that is
* bundled with this package in the LICENSE file. It is also available at
* the following URL: http://www.opensource.org/licenses/BSD-3-Clause
*
* @package Sentry
* @version 2.0.0
* @author Cartalyst LLC
* @license BSD License (3-clause)
* @copyright (c) 2011 - 2013, Cartalyst LLC
* @link http://cartalyst.com
*/
<?php
namespace League\OAuth1\Client\Tests;
use League\OAuth1\Client\Credentials\ClientCredentials;
use Mockery as m;
use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
class ClientCredentialsTest extends PHPUnit_Framework_TestCase
class ClientCredentialsTest extends TestCase
{
/**
* Close mockery.
*
* @return void
*/
public function tearDown()
protected function tearDown(): void
{
m::close();
parent::tearDown();
}
public function testManipulating()
@@ -44,4 +25,4 @@ class ClientCredentialsTest extends PHPUnit_Framework_TestCase
$credentials->setSecret('foo');
$this->assertEquals('foo', $credentials->getSecret());
}
}
}

View File

@@ -1,38 +1,18 @@
<?php namespace League\OAuth1\Client\Tests;
<?php
/**
* Part of the Sentry package.
*
* NOTICE OF LICENSE
*
* Licensed under the 3-clause BSD License.
*
* This source file is subject to the 3-clause BSD License that is
* bundled with this package in the LICENSE file. It is also available at
* the following URL: http://www.opensource.org/licenses/BSD-3-Clause
*
* @package Sentry
* @version 2.0.0
* @author Cartalyst LLC
* @license BSD License (3-clause)
* @copyright (c) 2011 - 2013, Cartalyst LLC
* @link http://cartalyst.com
*/
namespace League\OAuth1\Client\Tests;
use League\OAuth1\Client\Signature\HmacSha1Signature;
use Mockery as m;
use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
class HmacSha1SignatureTest extends PHPUnit_Framework_TestCase
class HmacSha1SignatureTest extends TestCase
{
/**
* Close mockery.
*
* @return void
*/
public function tearDown()
protected function tearDown(): void
{
m::close();
parent::tearDown();
}
public function testSigningRequest()
@@ -40,14 +20,24 @@ class HmacSha1SignatureTest extends PHPUnit_Framework_TestCase
$signature = new HmacSha1Signature($this->getMockClientCredentials());
$uri = 'http://www.example.com/?qux=corge';
$parameters = array('foo' => 'bar', 'baz' => null);
$parameters = ['foo' => 'bar', 'baz' => null];
$this->assertEquals('A3Y7C1SUHXR1EBYIUlT3d6QT1cQ=', $signature->sign($uri, $parameters));
}
public function testSigningRequestWhereThePortIsNotStandard()
{
$signature = new HmacSha1Signature($this->getMockClientCredentials());
$uri = 'http://www.example.com:8080/?qux=corge';
$parameters = ['foo' => 'bar', 'baz' => null];
$this->assertEquals('ECcWxyi5UOC1G0MxH0ygm6Pd6JE=', $signature->sign($uri, $parameters));
}
public function testQueryStringFromArray()
{
$array = array('a' => 'b');
$array = ['a' => 'b'];
$res = $this->invokeQueryStringFromData($array);
$this->assertSame(
@@ -58,7 +48,7 @@ class HmacSha1SignatureTest extends PHPUnit_Framework_TestCase
public function testQueryStringFromIndexedArray()
{
$array = array('a', 'b');
$array = ['a', 'b'];
$res = $this->invokeQueryStringFromData($array);
$this->assertSame(
@@ -69,20 +59,20 @@ class HmacSha1SignatureTest extends PHPUnit_Framework_TestCase
public function testQueryStringFromMultiDimensionalArray()
{
$array = array(
'a' => array(
'b' => array(
$array = [
'a' => [
'b' => [
'c' => 'd',
),
'e' => array(
],
'e' => [
'f' => 'g',
),
),
],
],
'h' => 'i',
'empty' => '',
'null' => null,
'false' => false,
);
];
// Convert to query string.
$res = $this->invokeQueryStringFromData($array);
@@ -105,20 +95,20 @@ class HmacSha1SignatureTest extends PHPUnit_Framework_TestCase
// And ensure it matches the orignal array (approximately).
$this->assertSame(
array(
'a' => array(
'b' => array(
[
'a' => [
'b' => [
'c' => 'd',
),
'e' => array(
],
'e' => [
'f' => 'g',
),
),
],
],
'h' => 'i',
'empty' => '',
'null' => '', // null value gets lost in string translation
'false' => '', // false value gets lost in string translation
),
],
$original_array
);
}
@@ -128,20 +118,20 @@ class HmacSha1SignatureTest extends PHPUnit_Framework_TestCase
$signature = new HmacSha1Signature($this->getMockClientCredentials());
$uri = 'http://www.example.com/';
$parameters = array(
'a' => array(
'b' => array(
$parameters = [
'a' => [
'b' => [
'c' => 'd',
),
'e' => array(
],
'e' => [
'f' => 'g',
),
),
],
],
'h' => 'i',
'empty' => '',
'null' => null,
'false' => false,
);
];
$this->assertEquals('ZUxiJKugeEplaZm9e4hshN0I70U=', $signature->sign($uri, $parameters));
}
@@ -152,13 +142,15 @@ class HmacSha1SignatureTest extends PHPUnit_Framework_TestCase
$refl = new \ReflectionObject($signature);
$method = $refl->getMethod('queryStringFromData');
$method->setAccessible(true);
return $method->invokeArgs($signature, array($args));
return $method->invokeArgs($signature, [$args]);
}
protected function getMockClientCredentials()
{
$clientCredentials = m::mock('League\OAuth1\Client\Credentials\ClientCredentialsInterface');
$clientCredentials->shouldReceive('getSecret')->andReturn('clientsecret');
return $clientCredentials;
}
}

View File

@@ -1,37 +1,18 @@
<?php namespace League\OAuth1\Client\Tests;
/**
* Part of the Sentry package.
*
* NOTICE OF LICENSE
*
* Licensed under the 3-clause BSD License.
*
* This source file is subject to the 3-clause BSD License that is
* bundled with this package in the LICENSE file. It is also available at
* the following URL: http://www.opensource.org/licenses/BSD-3-Clause
*
* @package Sentry
* @version 2.0.0
* @author Cartalyst LLC
* @license BSD License (3-clause)
* @copyright (c) 2011 - 2013, Cartalyst LLC
* @link http://cartalyst.com
*/
<?php
namespace League\OAuth1\Client\Tests;
use League\OAuth1\Client\Signature\PlainTextSignature;
use Mockery as m;
use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
class PlainTextSignatureTest extends PHPUnit_Framework_TestCase
class PlainTextSignatureTest extends TestCase
{
/**
* Close mockery.
*
* @return void
*/
public function tearDown()
protected function tearDown(): void
{
m::close();
parent::tearDown();
}
public function testSigningRequest()
@@ -48,6 +29,7 @@ class PlainTextSignatureTest extends PHPUnit_Framework_TestCase
{
$clientCredentials = m::mock('League\OAuth1\Client\Credentials\ClientCredentialsInterface');
$clientCredentials->shouldReceive('getSecret')->andReturn('clientsecret');
return $clientCredentials;
}
@@ -55,6 +37,7 @@ class PlainTextSignatureTest extends PHPUnit_Framework_TestCase
{
$credentials = m::mock('League\OAuth1\Client\Credentials\CredentialsInterface');
$credentials->shouldReceive('getSecret')->andReturn('tokensecret');
return $credentials;
}
}

View File

@@ -0,0 +1,75 @@
<?php
namespace League\OAuth1\Client\Tests;
use League\OAuth1\Client\Credentials\CredentialsException;
use League\OAuth1\Client\Credentials\RsaClientCredentials;
use OpenSSLAsymmetricKey;
use PHPUnit\Framework\TestCase;
class RsaClientCredentialsTest extends TestCase
{
public function testGetRsaPublicKey()
{
$credentials = new RsaClientCredentials();
$credentials->setRsaPublicKey(__DIR__ . '/test_rsa_publickey.pem');
/** @var resource|OpenSSLAsymmetricKey $key */
$key = $credentials->getRsaPublicKey();
$this->assertFalse(is_null($key));
$this->assertEquals($key, $credentials->getRsaPublicKey());
}
public function testGetRsaPublicKeyNotExists()
{
$this->expectException(CredentialsException::class);
$credentials = new RsaClientCredentials();
$credentials->setRsaPublicKey('fail');
$credentials->getRsaPublicKey();
}
public function testGetRsaPublicKeyInvalid()
{
$this->expectException(CredentialsException::class);
$credentials = new RsaClientCredentials();
$credentials->setRsaPublicKey(__DIR__ . '/test_rsa_invalidkey.pem');
$credentials->getRsaPublicKey();
}
public function testGetRsaPrivateKey()
{
$credentials = new RsaClientCredentials();
$credentials->setRsaPrivateKey(__DIR__ . '/test_rsa_privatekey.pem');
/** @var resource|OpenSSLAsymmetricKey $key */
$key = $credentials->getRsaPrivateKey();
$this->assertFalse(is_null($key));
$this->assertEquals($key, $credentials->getRsaPrivateKey());
}
public function testGetRsaPrivateKeyNotExists()
{
$this->expectException(CredentialsException::class);
$credentials = new RsaClientCredentials();
$credentials->setRsaPrivateKey('fail');
$credentials->getRsaPrivateKey();
}
public function testGetRsaPrivateKeyInvalid()
{
$this->expectException(CredentialsException::class);
$credentials = new RsaClientCredentials();
$credentials->setRsaPrivateKey(__DIR__ . '/test_rsa_invalidkey.pem');
$credentials->getRsaPrivateKey();
}
}

View File

@@ -0,0 +1,148 @@
<?php
namespace League\OAuth1\Client\Tests;
use League\OAuth1\Client\Credentials\ClientCredentialsInterface;
use League\OAuth1\Client\Credentials\RsaClientCredentials;
use League\OAuth1\Client\Signature\RsaSha1Signature;
use Mockery;
use PHPUnit\Framework\TestCase;
class RsaSha1SignatureTest extends TestCase
{
public function testMethod()
{
$signature = new RsaSha1Signature($this->getClientCredentials());
$this->assertEquals('RSA-SHA1', $signature->method());
}
public function testSigningRequest()
{
$signature = new RsaSha1Signature($this->getClientCredentials());
$uri = 'http://www.example.com/?qux=corge';
$parameters = ['foo' => 'bar', 'baz' => null];
$this->assertEquals('h8vpV4CYnLwss+rWicKE4sY6AiW2+DT6Fe7qB8jA7LSLhX5jvLEeX1D8E2ynSePSksAY48j+OSLu9vo5juS2duwNK8UA2Rtnnvuj6UFxpx70dpjHAsQg6EbycGptL/SChDkxfpG8LhuwX1FlFa+H0jLYXI5Dy8j90g51GRJbj48=', $signature->sign($uri, $parameters));
}
public function testQueryStringFromArray()
{
$array = ['a' => 'b'];
$res = $this->invokeQueryStringFromData($array);
$this->assertSame(
'a%3Db',
$res
);
}
public function testQueryStringFromIndexedArray()
{
$array = ['a', 'b'];
$res = $this->invokeQueryStringFromData($array);
$this->assertSame(
'0%3Da%261%3Db',
$res
);
}
public function testQueryStringFromMultiDimensionalArray()
{
$array = [
'a' => [
'b' => [
'c' => 'd',
],
'e' => [
'f' => 'g',
],
],
'h' => 'i',
'empty' => '',
'null' => null,
'false' => false,
];
// Convert to query string.
$res = $this->invokeQueryStringFromData($array);
$this->assertSame(
'a%5Bb%5D%5Bc%5D%3Dd%26a%5Be%5D%5Bf%5D%3Dg%26h%3Di%26empty%3D%26null%3D%26false%3D',
$res
);
// Reverse engineer the string.
$res = urldecode($res);
$this->assertSame(
'a[b][c]=d&a[e][f]=g&h=i&empty=&null=&false=',
$res
);
// Finally, parse the string back to an array.
parse_str($res, $original_array);
// And ensure it matches the orignal array (approximately).
$this->assertSame(
[
'a' => [
'b' => [
'c' => 'd',
],
'e' => [
'f' => 'g',
],
],
'h' => 'i',
'empty' => '',
'null' => '', // null value gets lost in string translation
'false' => '', // false value gets lost in string translation
],
$original_array
);
}
public function testSigningRequestWithMultiDimensionalParams()
{
$signature = new RsaSha1Signature($this->getClientCredentials());
$uri = 'http://www.example.com/';
$parameters = [
'a' => [
'b' => [
'c' => 'd',
],
'e' => [
'f' => 'g',
],
],
'h' => 'i',
'empty' => '',
'null' => null,
'false' => false,
];
$this->assertEquals('X9EkmOEbA5CoF2Hicf3ciAumpp1zkKxnVZkh/mEwWyF2DDcrfou9XF11WvbBu3G4loJGeX4GY1FsIrQpsjEILbn0e7Alyii/x8VA9mBwdqMhQVl49jF0pdowocc03M04cAbAOMNObT7tMmDs+YTFgRxEGCiUkq9AizP1cW3+eBo=', $signature->sign($uri, $parameters));
}
protected function invokeQueryStringFromData(array $args)
{
$signature = new RsaSha1Signature(Mockery::mock(ClientCredentialsInterface::class));
$refl = new \ReflectionObject($signature);
$method = $refl->getMethod('queryStringFromData');
$method->setAccessible(true);
return $method->invokeArgs($signature, [$args]);
}
protected function getClientCredentials()
{
$credentials = new RsaClientCredentials();
$credentials->setRsaPublicKey(__DIR__ . '/test_rsa_publickey.pem');
$credentials->setRsaPrivateKey(__DIR__ . '/test_rsa_privatekey.pem');
return $credentials;
}
}

View File

@@ -1,47 +1,32 @@
<?php namespace League\OAuth1\Client\Tests;
/**
* Part of the Sentry package.
*
* NOTICE OF LICENSE
*
* Licensed under the 3-clause BSD License.
*
* This source file is subject to the 3-clause BSD License that is
* bundled with this package in the LICENSE file. It is also available at
* the following URL: http://www.opensource.org/licenses/BSD-3-Clause
*
* @package Sentry
* @version 2.0.0
* @author Cartalyst LLC
* @license BSD License (3-clause)
* @copyright (c) 2011 - 2013, Cartalyst LLC
* @link http://cartalyst.com
*/
<?php
namespace League\OAuth1\Client\Tests;
use InvalidArgumentException;
use League\OAuth1\Client\Credentials\ClientCredentials;
use League\OAuth1\Client\Credentials\RsaClientCredentials;
use League\OAuth1\Client\Signature\RsaSha1Signature;
use Mockery as m;
use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface;
class ServerTest extends PHPUnit_Framework_TestCase
class ServerTest extends TestCase
{
/**
* Setup resources and dependencies.
*
* @return void
*/
public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
require_once __DIR__.'/stubs/ServerStub.php';
parent::setUpBeforeClass();
require_once __DIR__ . '/stubs/ServerStub.php';
}
/**
* Close mockery.
*
* @return void
*/
public function tearDown()
protected function tearDown(): void
{
m::close();
parent::tearDown();
}
public function testCreatingWithArray()
@@ -55,6 +40,24 @@ class ServerTest extends PHPUnit_Framework_TestCase
$this->assertEquals('http://app.dev/', $credentials->getCallbackUri());
}
public function testCreatingWithArrayRsa()
{
$config = [
'identifier' => 'app_key',
'secret' => 'secret',
'callback_uri' => 'https://example.com/callback',
'rsa_public_key' => __DIR__ . '/test_rsa_publickey.pem',
'rsa_private_key' => __DIR__ . '/test_rsa_privatekey.pem',
];
$server = new ServerStub($config);
$credentials = $server->getClientCredentials();
$this->assertInstanceOf(RsaClientCredentials::class, $credentials);
$signature = $server->getSignature();
$this->assertInstanceOf(RsaSha1Signature::class, $signature);
}
public function testCreatingWithObject()
{
$credentials = new ClientCredentials;
@@ -67,22 +70,21 @@ class ServerTest extends PHPUnit_Framework_TestCase
$this->assertEquals($credentials, $server->getClientCredentials());
}
/**
* @expectedException InvalidArgumentException
**/
public function testCreatingWithInvalidInput()
{
$server = new ServerStub(uniqid());
$this->expectException(InvalidArgumentException::class);
new ServerStub(uniqid());
}
public function testGettingTemporaryCredentials()
{
$server = m::mock('League\OAuth1\Client\Tests\ServerStub[createHttpClient]', array($this->getMockClientCredentials()));
$server = m::mock('League\OAuth1\Client\Tests\ServerStub[createHttpClient]', [$this->getMockClientCredentials()]);
$server->shouldReceive('createHttpClient')->andReturn($client = m::mock('stdClass'));
$me = $this;
$client->shouldReceive('post')->with('http://www.example.com/temporary', m::on(function($options) use ($me) {
$client->shouldReceive('post')->with('http://www.example.com/temporary', m::on(function ($options) use ($me) {
$headers = $options['headers'];
$me->assertTrue(isset($headers['Authorization']));
@@ -90,14 +92,17 @@ class ServerTest extends PHPUnit_Framework_TestCase
// OAuth protocol specifies a strict number of
// headers should be sent, in the correct order.
// We'll validate that here.
$pattern = '/OAuth oauth_consumer_key=".*?", oauth_nonce="[a-zA-Z0-9]+", oauth_signature_method="HMAC-SHA1", oauth_timestamp="\d{10}", oauth_version="1.0", oauth_callback="'.preg_quote('http%3A%2F%2Fapp.dev%2F', '/').'", oauth_signature=".*?"/';
$pattern
= '/OAuth oauth_consumer_key=".*?", oauth_nonce="[a-zA-Z0-9]+", oauth_signature_method="HMAC-SHA1", oauth_timestamp="\d{10}", oauth_version="1.0", oauth_callback="'
. preg_quote('http%3A%2F%2Fapp.dev%2F', '/') . '", oauth_signature=".*?"/';
$matches = preg_match($pattern, $headers['Authorization']);
$me->assertEquals(1, $matches, 'Asserting that the authorization header contains the correct expression.');
return true;
}))->once()->andReturn($response = m::mock('stdClass'));
$response->shouldReceive('getBody')->andReturn('oauth_token=temporarycredentialsidentifier&oauth_token_secret=temporarycredentialssecret&oauth_callback_confirmed=true');
$response->shouldReceive('getBody')
->andReturn('oauth_token=temporarycredentialsidentifier&oauth_token_secret=temporarycredentialssecret&oauth_callback_confirmed=true');
$credentials = $server->getTemporaryCredentials();
$this->assertInstanceOf('League\OAuth1\Client\Credentials\TemporaryCredentials', $credentials);
@@ -118,9 +123,16 @@ class ServerTest extends PHPUnit_Framework_TestCase
$this->assertEquals($expected, $server->getAuthorizationUrl($credentials));
}
/**
* @expectedException InvalidArgumentException
*/
public function testGettingAuthorizationUrlWithOptions()
{
$server = new ServerStub($this->getMockClientCredentials());
$expected = 'http://www.example.com/authorize?oauth_token=foo';
$this->assertEquals($expected, $server->getAuthorizationUrl('foo', ['oauth_token' => 'bar']));
$expected = 'http://www.example.com/authorize?test=bar&oauth_token=foo';
$this->assertEquals($expected, $server->getAuthorizationUrl('foo', ['test' => 'bar']));
}
public function testGettingTokenCredentialsFailsWithManInTheMiddle()
{
$server = new ServerStub($this->getMockClientCredentials());
@@ -128,12 +140,14 @@ class ServerTest extends PHPUnit_Framework_TestCase
$credentials = m::mock('League\OAuth1\Client\Credentials\TemporaryCredentials');
$credentials->shouldReceive('getIdentifier')->andReturn('foo');
$this->expectException(InvalidArgumentException::class);
$server->getTokenCredentials($credentials, 'bar', 'verifier');
}
public function testGettingTokenCredentials()
{
$server = m::mock('League\OAuth1\Client\Tests\ServerStub[createHttpClient]', array($this->getMockClientCredentials()));
$server = m::mock('League\OAuth1\Client\Tests\ServerStub[createHttpClient]', [$this->getMockClientCredentials()]);
$temporaryCredentials = m::mock('League\OAuth1\Client\Credentials\TemporaryCredentials');
$temporaryCredentials->shouldReceive('getIdentifier')->andReturn('temporarycredentialsidentifier');
@@ -142,7 +156,7 @@ class ServerTest extends PHPUnit_Framework_TestCase
$server->shouldReceive('createHttpClient')->andReturn($client = m::mock('stdClass'));
$me = $this;
$client->shouldReceive('post')->with('http://www.example.com/token', m::on(function($options) use ($me) {
$client->shouldReceive('post')->with('http://www.example.com/token', m::on(function ($options) use ($me) {
$headers = $options['headers'];
$body = $options['form_params'];
@@ -152,16 +166,18 @@ class ServerTest extends PHPUnit_Framework_TestCase
// OAuth protocol specifies a strict number of
// headers should be sent, in the correct order.
// We'll validate that here.
$pattern = '/OAuth oauth_consumer_key=".*?", oauth_nonce="[a-zA-Z0-9]+", oauth_signature_method="HMAC-SHA1", oauth_timestamp="\d{10}", oauth_version="1.0", oauth_token="temporarycredentialsidentifier", oauth_signature=".*?"/';
$pattern
= '/OAuth oauth_consumer_key=".*?", oauth_nonce="[a-zA-Z0-9]+", oauth_signature_method="HMAC-SHA1", oauth_timestamp="\d{10}", oauth_version="1.0", oauth_token="temporarycredentialsidentifier", oauth_signature=".*?"/';
$matches = preg_match($pattern, $headers['Authorization']);
$me->assertEquals(1, $matches, 'Asserting that the authorization header contains the correct expression.');
$me->assertSame($body, array('oauth_verifier' => 'myverifiercode'));
$me->assertSame($body, ['oauth_verifier' => 'myverifiercode']);
return true;
}))->once()->andReturn($response = m::mock('stdClass'));
$response->shouldReceive('getBody')->andReturn('oauth_token=tokencredentialsidentifier&oauth_token_secret=tokencredentialssecret');
$response->shouldReceive('getBody')
->andReturn('oauth_token=tokencredentialsidentifier&oauth_token_secret=tokencredentialssecret');
$credentials = $server->getTokenCredentials($temporaryCredentials, 'temporarycredentialsidentifier', 'myverifiercode');
$this->assertInstanceOf('League\OAuth1\Client\Credentials\TokenCredentials', $credentials);
@@ -172,7 +188,7 @@ class ServerTest extends PHPUnit_Framework_TestCase
public function testGettingTokenCredentialsWithUserAgent()
{
$userAgent = 'FooBar';
$server = m::mock('League\OAuth1\Client\Tests\ServerStub[createHttpClient]', array($this->getMockClientCredentials()));
$server = m::mock('League\OAuth1\Client\Tests\ServerStub[createHttpClient]', [$this->getMockClientCredentials()]);
$temporaryCredentials = m::mock('League\OAuth1\Client\Credentials\TemporaryCredentials');
$temporaryCredentials->shouldReceive('getIdentifier')->andReturn('temporarycredentialsidentifier');
@@ -181,7 +197,7 @@ class ServerTest extends PHPUnit_Framework_TestCase
$server->shouldReceive('createHttpClient')->andReturn($client = m::mock('stdClass'));
$me = $this;
$client->shouldReceive('post')->with('http://www.example.com/token', m::on(function($options) use ($me, $userAgent) {
$client->shouldReceive('post')->with('http://www.example.com/token', m::on(function ($options) use ($me, $userAgent) {
$headers = $options['headers'];
$body = $options['form_params'];
@@ -192,27 +208,32 @@ class ServerTest extends PHPUnit_Framework_TestCase
// OAuth protocol specifies a strict number of
// headers should be sent, in the correct order.
// We'll validate that here.
$pattern = '/OAuth oauth_consumer_key=".*?", oauth_nonce="[a-zA-Z0-9]+", oauth_signature_method="HMAC-SHA1", oauth_timestamp="\d{10}", oauth_version="1.0", oauth_token="temporarycredentialsidentifier", oauth_signature=".*?"/';
$pattern
= '/OAuth oauth_consumer_key=".*?", oauth_nonce="[a-zA-Z0-9]+", oauth_signature_method="HMAC-SHA1", oauth_timestamp="\d{10}", oauth_version="1.0", oauth_token="temporarycredentialsidentifier", oauth_signature=".*?"/';
$matches = preg_match($pattern, $headers['Authorization']);
$me->assertEquals(1, $matches, 'Asserting that the authorization header contains the correct expression.');
$me->assertSame($body, array('oauth_verifier' => 'myverifiercode'));
$me->assertSame($body, ['oauth_verifier' => 'myverifiercode']);
return true;
}))->once()->andReturn($response = m::mock('stdClass'));
$response->shouldReceive('getBody')->andReturn('oauth_token=tokencredentialsidentifier&oauth_token_secret=tokencredentialssecret');
$response->shouldReceive('getBody')
->andReturn('oauth_token=tokencredentialsidentifier&oauth_token_secret=tokencredentialssecret');
$credentials = $server->setUserAgent($userAgent)->getTokenCredentials($temporaryCredentials, 'temporarycredentialsidentifier', 'myverifiercode');
$credentials = $server->setUserAgent($userAgent)
->getTokenCredentials($temporaryCredentials, 'temporarycredentialsidentifier', 'myverifiercode');
$this->assertInstanceOf('League\OAuth1\Client\Credentials\TokenCredentials', $credentials);
$this->assertEquals('tokencredentialsidentifier', $credentials->getIdentifier());
$this->assertEquals('tokencredentialssecret', $credentials->getSecret());
}
public function testGettingUserDetails()
{
$server = m::mock('League\OAuth1\Client\Tests\ServerStub[createHttpClient,protocolHeader]', array($this->getMockClientCredentials()));
$server = m::mock(
'League\OAuth1\Client\Tests\ServerStub[createHttpClient,protocolHeader]',
[$this->getMockClientCredentials()]
);
$temporaryCredentials = m::mock('League\OAuth1\Client\Credentials\TokenCredentials');
$temporaryCredentials->shouldReceive('getIdentifier')->andReturn('tokencredentialsidentifier');
@@ -221,7 +242,7 @@ class ServerTest extends PHPUnit_Framework_TestCase
$server->shouldReceive('createHttpClient')->andReturn($client = m::mock('stdClass'));
$me = $this;
$client->shouldReceive('get')->with('http://www.example.com/user', m::on(function($options) use ($me) {
$client->shouldReceive('get')->with('http://www.example.com/user', m::on(function ($options) use ($me) {
$headers = $options['headers'];
$me->assertTrue(isset($headers['Authorization']));
@@ -229,14 +250,20 @@ class ServerTest extends PHPUnit_Framework_TestCase
// OAuth protocol specifies a strict number of
// headers should be sent, in the correct order.
// We'll validate that here.
$pattern = '/OAuth oauth_consumer_key=".*?", oauth_nonce="[a-zA-Z0-9]+", oauth_signature_method="HMAC-SHA1", oauth_timestamp="\d{10}", oauth_version="1.0", oauth_token="tokencredentialsidentifier", oauth_signature=".*?"/';
$pattern
= '/OAuth oauth_consumer_key=".*?", oauth_nonce="[a-zA-Z0-9]+", oauth_signature_method="HMAC-SHA1", oauth_timestamp="\d{10}", oauth_version="1.0", oauth_token="tokencredentialsidentifier", oauth_signature=".*?"/';
$matches = preg_match($pattern, $headers['Authorization']);
$me->assertEquals(1, $matches, 'Asserting that the authorization header contains the correct expression.');
return true;
}))->once()->andReturn($response = m::mock('stdClass'));
$response->shouldReceive('getBody')->once()->andReturn(json_encode(array('foo' => 'bar', 'id' => 123, 'contact_email' => 'baz@qux.com', 'username' => 'fred')));
}))->once()->andReturn($response = m::mock(ResponseInterface::class));
$response->shouldReceive('getBody')->once()->andReturn(json_encode([
'foo' => 'bar',
'id' => 123,
'contact_email' => 'baz@qux.com',
'username' => 'fred',
]));
$user = $server->getUserDetails($temporaryCredentials);
$this->assertInstanceOf('League\OAuth1\Client\Server\User', $user);
@@ -257,7 +284,8 @@ class ServerTest extends PHPUnit_Framework_TestCase
// OAuth protocol specifies a strict number of
// headers should be sent, in the correct order.
// We'll validate that here.
$pattern = '/OAuth oauth_consumer_key=".*?", oauth_nonce="[a-zA-Z0-9]+", oauth_signature_method="HMAC-SHA1", oauth_timestamp="\d{10}", oauth_version="1.0", oauth_token="mock_identifier", oauth_signature=".*?"/';
$pattern
= '/OAuth oauth_consumer_key=".*?", oauth_nonce="[a-zA-Z0-9]+", oauth_signature_method="HMAC-SHA1", oauth_timestamp="\d{10}", oauth_version="1.0", oauth_token="mock_identifier", oauth_signature=".*?"/';
// With a GET request
$headers = $server->getHeaders($tokenCredentials, 'GET', 'http://example.com/');
@@ -267,7 +295,7 @@ class ServerTest extends PHPUnit_Framework_TestCase
$this->assertEquals(1, $matches, 'Asserting that the authorization header contains the correct expression.');
// With a POST request
$headers = $server->getHeaders($tokenCredentials, 'POST', 'http://example.com/', array('body' => 'params'));
$headers = $server->getHeaders($tokenCredentials, 'POST', 'http://example.com/', ['body' => 'params']);
$this->assertTrue(isset($headers['Authorization']));
$matches = preg_match($pattern, $headers['Authorization']);
@@ -276,10 +304,10 @@ class ServerTest extends PHPUnit_Framework_TestCase
protected function getMockClientCredentials()
{
return array(
return [
'identifier' => 'myidentifier',
'secret' => 'mysecret',
'callback_uri' => 'http://app.dev/',
);
];
}
}

View File

@@ -1,20 +1,21 @@
<?php namespace League\OAuth1\Client\Tests;
use League\OAuth1\Client\Server\Trello;
use InvalidArgumentException;
use League\OAuth1\Client\Credentials\ClientCredentials;
use League\OAuth1\Client\Server\Trello;
use Mockery as m;
use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
class TrelloTest extends PHPUnit_Framework_TestCase
use Psr\Http\Message\ResponseInterface;
class TrelloTest extends TestCase
{
/**
* Close mockery.
*
* @return void
*/
public function tearDown()
protected function tearDown(): void
{
m::close();
parent::tearDown();
}
public function testCreatingWithArray()
@@ -42,12 +43,12 @@ class TrelloTest extends PHPUnit_Framework_TestCase
public function testGettingTemporaryCredentials()
{
$server = m::mock('League\OAuth1\Client\Server\Trello[createHttpClient]', array($this->getMockClientCredentials()));
$server = m::mock('League\OAuth1\Client\Server\Trello[createHttpClient]', [$this->getMockClientCredentials()]);
$server->shouldReceive('createHttpClient')->andReturn($client = m::mock('stdClass'));
$me = $this;
$client->shouldReceive('post')->with('https://trello.com/1/OAuthGetRequestToken', m::on(function($options) use ($me) {
$client->shouldReceive('post')->with('https://trello.com/1/OAuthGetRequestToken', m::on(function ($options) use ($me) {
$headers = $options['headers'];
$me->assertTrue(isset($headers['Authorization']));
@@ -55,13 +56,13 @@ class TrelloTest extends PHPUnit_Framework_TestCase
// OAuth protocol specifies a strict number of
// headers should be sent, in the correct order.
// We'll validate that here.
$pattern = '/OAuth oauth_consumer_key=".*?", oauth_nonce="[a-zA-Z0-9]+", oauth_signature_method="HMAC-SHA1", oauth_timestamp="\d{10}", oauth_version="1.0", oauth_callback="'.preg_quote('http%3A%2F%2Fapp.dev%2F', '/').'", oauth_signature=".*?"/';
$pattern = '/OAuth oauth_consumer_key=".*?", oauth_nonce="[a-zA-Z0-9]+", oauth_signature_method="HMAC-SHA1", oauth_timestamp="\d{10}", oauth_version="1.0", oauth_callback="' . preg_quote('http%3A%2F%2Fapp.dev%2F', '/') . '", oauth_signature=".*?"/';
$matches = preg_match($pattern, $headers['Authorization']);
$me->assertEquals(1, $matches, 'Asserting that the authorization header contains the correct expression.');
return true;
}))->once()->andReturn($response = m::mock('stdClass'));
}))->once()->andReturn($response = m::mock(ResponseInterface::class));
$response->shouldReceive('getBody')->andReturn('oauth_token=temporarycredentialsidentifier&oauth_token_secret=temporarycredentialssecret&oauth_callback_confirmed=true');
$credentials = $server->getTemporaryCredentials();
@@ -90,7 +91,7 @@ class TrelloTest extends PHPUnit_Framework_TestCase
$credentials['expiration'] = $expiration;
$server = new Trello($credentials);
$expected = 'https://trello.com/1/OAuthAuthorizeToken?response_type=fragment&scope=read&expiration='.urlencode($expiration).'&oauth_token=foo';
$expected = 'https://trello.com/1/OAuthAuthorizeToken?response_type=fragment&scope=read&expiration=' . urlencode($expiration) . '&oauth_token=foo';
$this->assertEquals($expected, $server->getAuthorizationUrl('foo'));
@@ -105,7 +106,7 @@ class TrelloTest extends PHPUnit_Framework_TestCase
$server = new Trello($this->getMockClientCredentials());
$server->setApplicationExpiration($expiration);
$expected = 'https://trello.com/1/OAuthAuthorizeToken?response_type=fragment&scope=read&expiration='.urlencode($expiration).'&oauth_token=foo';
$expected = 'https://trello.com/1/OAuthAuthorizeToken?response_type=fragment&scope=read&expiration=' . urlencode($expiration) . '&oauth_token=foo';
$this->assertEquals($expected, $server->getAuthorizationUrl('foo'));
@@ -121,7 +122,7 @@ class TrelloTest extends PHPUnit_Framework_TestCase
$credentials['name'] = $name;
$server = new Trello($credentials);
$expected = 'https://trello.com/1/OAuthAuthorizeToken?response_type=fragment&scope=read&expiration=1day&name='.urlencode($name).'&oauth_token=foo';
$expected = 'https://trello.com/1/OAuthAuthorizeToken?response_type=fragment&scope=read&expiration=1day&name=' . urlencode($name) . '&oauth_token=foo';
$this->assertEquals($expected, $server->getAuthorizationUrl('foo'));
@@ -136,7 +137,7 @@ class TrelloTest extends PHPUnit_Framework_TestCase
$server = new Trello($this->getMockClientCredentials());
$server->setApplicationName($name);
$expected = 'https://trello.com/1/OAuthAuthorizeToken?response_type=fragment&scope=read&expiration=1day&name='.urlencode($name).'&oauth_token=foo';
$expected = 'https://trello.com/1/OAuthAuthorizeToken?response_type=fragment&scope=read&expiration=1day&name=' . urlencode($name) . '&oauth_token=foo';
$this->assertEquals($expected, $server->getAuthorizationUrl('foo'));
@@ -152,7 +153,7 @@ class TrelloTest extends PHPUnit_Framework_TestCase
$credentials['scope'] = $scope;
$server = new Trello($credentials);
$expected = 'https://trello.com/1/OAuthAuthorizeToken?response_type=fragment&scope='.urlencode($scope).'&expiration=1day&oauth_token=foo';
$expected = 'https://trello.com/1/OAuthAuthorizeToken?response_type=fragment&scope=' . urlencode($scope) . '&expiration=1day&oauth_token=foo';
$this->assertEquals($expected, $server->getAuthorizationUrl('foo'));
@@ -167,7 +168,7 @@ class TrelloTest extends PHPUnit_Framework_TestCase
$server = new Trello($this->getMockClientCredentials());
$server->setApplicationScope($scope);
$expected = 'https://trello.com/1/OAuthAuthorizeToken?response_type=fragment&scope='.urlencode($scope).'&expiration=1day&oauth_token=foo';
$expected = 'https://trello.com/1/OAuthAuthorizeToken?response_type=fragment&scope=' . urlencode($scope) . '&expiration=1day&oauth_token=foo';
$this->assertEquals($expected, $server->getAuthorizationUrl('foo'));
@@ -176,9 +177,6 @@ class TrelloTest extends PHPUnit_Framework_TestCase
$this->assertEquals($expected, $server->getAuthorizationUrl($credentials));
}
/**
* @expectedException InvalidArgumentException
*/
public function testGettingTokenCredentialsFailsWithManInTheMiddle()
{
$server = new Trello($this->getMockClientCredentials());
@@ -186,12 +184,14 @@ class TrelloTest extends PHPUnit_Framework_TestCase
$credentials = m::mock('League\OAuth1\Client\Credentials\TemporaryCredentials');
$credentials->shouldReceive('getIdentifier')->andReturn('foo');
$this->expectException(InvalidArgumentException::class);
$server->getTokenCredentials($credentials, 'bar', 'verifier');
}
public function testGettingTokenCredentials()
{
$server = m::mock('League\OAuth1\Client\Server\Trello[createHttpClient]', array($this->getMockClientCredentials()));
$server = m::mock('League\OAuth1\Client\Server\Trello[createHttpClient]', [$this->getMockClientCredentials()]);
$temporaryCredentials = m::mock('League\OAuth1\Client\Credentials\TemporaryCredentials');
$temporaryCredentials->shouldReceive('getIdentifier')->andReturn('temporarycredentialsidentifier');
@@ -200,7 +200,7 @@ class TrelloTest extends PHPUnit_Framework_TestCase
$server->shouldReceive('createHttpClient')->andReturn($client = m::mock('stdClass'));
$me = $this;
$client->shouldReceive('post')->with('https://trello.com/1/OAuthGetAccessToken', m::on(function($options) use ($me) {
$client->shouldReceive('post')->with('https://trello.com/1/OAuthGetAccessToken', m::on(function ($options) use ($me) {
$headers = $options['headers'];
$body = $options['form_params'];
@@ -214,10 +214,10 @@ class TrelloTest extends PHPUnit_Framework_TestCase
$matches = preg_match($pattern, $headers['Authorization']);
$me->assertEquals(1, $matches, 'Asserting that the authorization header contains the correct expression.');
$me->assertSame($body, array('oauth_verifier' => 'myverifiercode'));
$me->assertSame($body, ['oauth_verifier' => 'myverifiercode']);
return true;
}))->once()->andReturn($response = m::mock('stdClass'));
}))->once()->andReturn($response = m::mock(ResponseInterface::class));
$response->shouldReceive('getBody')->andReturn('oauth_token=tokencredentialsidentifier&oauth_token_secret=tokencredentialssecret');
$credentials = $server->getTokenCredentials($temporaryCredentials, 'temporarycredentialsidentifier', 'myverifiercode');
@@ -228,7 +228,7 @@ class TrelloTest extends PHPUnit_Framework_TestCase
public function testGettingUserDetails()
{
$server = m::mock('League\OAuth1\Client\Server\Trello[createHttpClient,protocolHeader]', array($this->getMockClientCredentials()));
$server = m::mock('League\OAuth1\Client\Server\Trello[createHttpClient,protocolHeader]', [$this->getMockClientCredentials()]);
$temporaryCredentials = m::mock('League\OAuth1\Client\Credentials\TokenCredentials');
$temporaryCredentials->shouldReceive('getIdentifier')->andReturn('tokencredentialsidentifier');
@@ -237,7 +237,7 @@ class TrelloTest extends PHPUnit_Framework_TestCase
$server->shouldReceive('createHttpClient')->andReturn($client = m::mock('stdClass'));
$me = $this;
$client->shouldReceive('get')->with('https://trello.com/1/members/me?key='.$this->getApplicationKey().'&token='.$this->getAccessToken(), m::on(function($options) use ($me) {
$client->shouldReceive('get')->with('https://trello.com/1/members/me?key=' . $this->getApplicationKey() . '&token=' . $this->getAccessToken(), m::on(function ($options) use ($me) {
$headers = $options['headers'];
$me->assertTrue(isset($headers['Authorization']));
@@ -251,7 +251,7 @@ class TrelloTest extends PHPUnit_Framework_TestCase
$me->assertEquals(1, $matches, 'Asserting that the authorization header contains the correct expression.');
return true;
}))->once()->andReturn($response = m::mock('stdClass'));
}))->once()->andReturn($response = m::mock(ResponseInterface::class));
$response->shouldReceive('getBody')->once()->andReturn($this->getUserPayload());
$user = $server
@@ -266,11 +266,11 @@ class TrelloTest extends PHPUnit_Framework_TestCase
protected function getMockClientCredentials()
{
return array(
return [
'identifier' => $this->getApplicationKey(),
'secret' => 'mysecret',
'callback_uri' => 'http://app.dev/',
);
];
}
protected function getAccessToken()
@@ -285,7 +285,7 @@ class TrelloTest extends PHPUnit_Framework_TestCase
protected function getApplicationExpiration($days = 0)
{
return is_numeric($days) && $days > 0 ? $days.'day'.($days == 1 ? '' : 's') : 'never';
return is_numeric($days) && $days > 0 ? $days . 'day' . ($days == 1 ? '' : 's') : 'never';
}
protected function getApplicationName()

View File

@@ -0,0 +1,38 @@
<?php
namespace League\OAuth1\Client\Tests;
use Generator;
use League\OAuth1\Client\Server\Twitter;
use PHPUnit\Framework\TestCase;
class TwitterServerTest extends TestCase
{
public function sampleTemporaryCredentialUrls(): Generator
{
yield 'No application scope' => [
null, 'https://api.twitter.com/oauth/request_token',
];
yield "Read" => [
'read', 'https://api.twitter.com/oauth/request_token?x_auth_access_type=read',
];
yield "Write" => [
'write', 'https://api.twitter.com/oauth/request_token?x_auth_access_type=write',
];
}
/** @dataProvider sampleTemporaryCredentialUrls */
public function testItProvidesNoApplicationScopeByDefault(?string $applicationScope, string $url): void
{
$twitter = new Twitter([
'identifier' => 'mykey',
'secret' => 'mysecret',
'callback_uri' => 'http://app.dev/',
'scope' => $applicationScope,
]);
self::assertEquals($url, $twitter->urlTemporaryCredentials());
}
}

View File

@@ -1,20 +1,21 @@
<?php namespace League\OAuth1\Client\Tests;
use League\OAuth1\Client\Server\Xing;
use InvalidArgumentException;
use League\OAuth1\Client\Credentials\ClientCredentials;
use League\OAuth1\Client\Server\Xing;
use Mockery as m;
use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;
class XingTest extends PHPUnit_Framework_TestCase
use Psr\Http\Message\ResponseInterface;
class XingTest extends TestCase
{
/**
* Close mockery.
*
* @return void
*/
public function tearDown()
protected function tearDown(): void
{
m::close();
parent::tearDown();
}
public function testCreatingWithArray()
@@ -42,7 +43,7 @@ class XingTest extends PHPUnit_Framework_TestCase
public function testGettingTemporaryCredentials()
{
$server = m::mock('League\OAuth1\Client\Server\Xing[createHttpClient]', array($this->getMockClientCredentials()));
$server = m::mock('League\OAuth1\Client\Server\Xing[createHttpClient]', [$this->getMockClientCredentials()]);
$server->shouldReceive('createHttpClient')->andReturn($client = m::mock('stdClass'));
@@ -54,13 +55,13 @@ class XingTest extends PHPUnit_Framework_TestCase
// OAuth protocol specifies a strict number of
// headers should be sent, in the correct order.
// We'll validate that here.
$pattern = '/OAuth oauth_consumer_key=".*?", oauth_nonce="[a-zA-Z0-9]+", oauth_signature_method="HMAC-SHA1", oauth_timestamp="\d{10}", oauth_version="1.0", oauth_callback="'.preg_quote('http%3A%2F%2Fapp.dev%2F', '/').'", oauth_signature=".*?"/';
$pattern = '/OAuth oauth_consumer_key=".*?", oauth_nonce="[a-zA-Z0-9]+", oauth_signature_method="HMAC-SHA1", oauth_timestamp="\d{10}", oauth_version="1.0", oauth_callback="' . preg_quote('http%3A%2F%2Fapp.dev%2F', '/') . '", oauth_signature=".*?"/';
$matches = preg_match($pattern, $headers['Authorization']);
$me->assertEquals(1, $matches, 'Asserting that the authorization header contains the correct expression.');
return true;
}))->once()->andReturn($response = m::mock('stdClass'));
}))->once()->andReturn($response = m::mock(ResponseInterface::class));
$response->shouldReceive('getBody')->andReturn('oauth_token=temporarycredentialsidentifier&oauth_token_secret=temporarycredentialssecret&oauth_callback_confirmed=true');
$credentials = $server->getTemporaryCredentials();
@@ -82,9 +83,6 @@ class XingTest extends PHPUnit_Framework_TestCase
$this->assertEquals($expected, $server->getAuthorizationUrl($credentials));
}
/**
* @expectedException InvalidArgumentException
*/
public function testGettingTokenCredentialsFailsWithManInTheMiddle()
{
$server = new Xing($this->getMockClientCredentials());
@@ -92,12 +90,14 @@ class XingTest extends PHPUnit_Framework_TestCase
$credentials = m::mock('League\OAuth1\Client\Credentials\TemporaryCredentials');
$credentials->shouldReceive('getIdentifier')->andReturn('foo');
$this->expectException(InvalidArgumentException::class);
$server->getTokenCredentials($credentials, 'bar', 'verifier');
}
public function testGettingTokenCredentials()
{
$server = m::mock('League\OAuth1\Client\Server\Xing[createHttpClient]', array($this->getMockClientCredentials()));
$server = m::mock('League\OAuth1\Client\Server\Xing[createHttpClient]', [$this->getMockClientCredentials()]);
$temporaryCredentials = m::mock('League\OAuth1\Client\Credentials\TemporaryCredentials');
$temporaryCredentials->shouldReceive('getIdentifier')->andReturn('temporarycredentialsidentifier');
@@ -120,10 +120,10 @@ class XingTest extends PHPUnit_Framework_TestCase
$matches = preg_match($pattern, $headers['Authorization']);
$me->assertEquals(1, $matches, 'Asserting that the authorization header contains the correct expression.');
$me->assertSame($body, array('oauth_verifier' => 'myverifiercode'));
$me->assertSame($body, ['oauth_verifier' => 'myverifiercode']);
return true;
}))->once()->andReturn($response = m::mock('stdClass'));
}))->once()->andReturn($response = m::mock(ResponseInterface::class));
$response->shouldReceive('getBody')->andReturn('oauth_token=tokencredentialsidentifier&oauth_token_secret=tokencredentialssecret');
$credentials = $server->getTokenCredentials($temporaryCredentials, 'temporarycredentialsidentifier', 'myverifiercode');
@@ -134,7 +134,7 @@ class XingTest extends PHPUnit_Framework_TestCase
public function testGettingUserDetails()
{
$server = m::mock('League\OAuth1\Client\Server\Xing[createHttpClient,protocolHeader]', array($this->getMockClientCredentials()));
$server = m::mock('League\OAuth1\Client\Server\Xing[createHttpClient,protocolHeader]', [$this->getMockClientCredentials()]);
$temporaryCredentials = m::mock('League\OAuth1\Client\Credentials\TokenCredentials');
$temporaryCredentials->shouldReceive('getIdentifier')->andReturn('tokencredentialsidentifier');
@@ -157,7 +157,7 @@ class XingTest extends PHPUnit_Framework_TestCase
$me->assertEquals(1, $matches, 'Asserting that the authorization header contains the correct expression.');
return true;
}))->once()->andReturn($response = m::mock('stdClass'));
}))->once()->andReturn($response = m::mock(ResponseInterface::class));
$response->shouldReceive('getBody')->once()->andReturn($this->getUserPayload());
$user = $server->getUserDetails($temporaryCredentials);
@@ -170,11 +170,11 @@ class XingTest extends PHPUnit_Framework_TestCase
protected function getMockClientCredentials()
{
return array(
return [
'identifier' => $this->getApplicationKey(),
'secret' => 'mysecret',
'callback_uri' => 'http://app.dev/',
);
];
}
protected function getApplicationKey()
@@ -184,7 +184,7 @@ class XingTest extends PHPUnit_Framework_TestCase
protected function getApplicationExpiration($days = 0)
{
return is_numeric($days) && $days > 0 ? $days.'day'.($days == 1 ? '' : 's') : 'never';
return is_numeric($days) && $days > 0 ? $days . 'day' . ($days == 1 ? '' : 's') : 'never';
}
protected function getApplicationName()

View File

@@ -9,7 +9,7 @@ use League\OAuth1\Client\Server\User;
class ServerStub extends Server
{
/**
* {@inheritDoc}
* @inheritDoc
*/
public function urlTemporaryCredentials()
{
@@ -17,7 +17,7 @@ class ServerStub extends Server
}
/**
* {@inheritDoc}
* @inheritDoc
*/
public function urlAuthorization()
{
@@ -25,7 +25,7 @@ class ServerStub extends Server
}
/**
* {@inheritDoc}
* @inheritDoc
*/
public function urlTokenCredentials()
{
@@ -33,7 +33,7 @@ class ServerStub extends Server
}
/**
* {@inheritDoc}
* @inheritDoc
*/
public function urlUserDetails()
{
@@ -41,17 +41,18 @@ class ServerStub extends Server
}
/**
* {@inheritDoc}
* @inheritDoc
*/
public function userDetails($data, TokenCredentials $tokenCredentials)
{
$user = new User;
$user->firstName = $data['foo'];
return $user;
}
/**
* {@inheritDoc}
* @inheritDoc
*/
public function userUid($data, TokenCredentials $tokenCredentials)
{
@@ -59,7 +60,7 @@ class ServerStub extends Server
}
/**
* {@inheritDoc}
* @inheritDoc
*/
public function userEmail($data, TokenCredentials $tokenCredentials)
{
@@ -67,7 +68,7 @@ class ServerStub extends Server
}
/**
* {@inheritDoc}
* @inheritDoc
*/
public function userScreenName($data, TokenCredentials $tokenCredentials)
{

View File

@@ -0,0 +1 @@
not a valid RSA key

View File

@@ -0,0 +1,15 @@
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQDJScPCpHHPakw9v4nhxi+cBumCml3WpMNDaE3Cxnkf6HALzoi8
fQPx3XRfKSoLG6b7uTG+vDoLCL49ZCyYwrnggsFF08bJMqIhUHlZrkiyT5UhdTIh
XEEFfb6XmieHNtra+ur8E3PVal4PEdOCEmJehBMJkiCsxNOJ/kCeYSMdbQIDAQAB
AoGAMo7JkcEWKP/NCJFsg33xBWKjEj/NpBUcSnkPVwXc9IvAYObOZ3GLJRv3l9NS
ERov9fgNK5hBh/X5OphHr1LxtqU5gAFYx5Qgt/WG3ZH9KScXkaPS3Oq2qK9krbA2
BXYKP4NEqhjJTecy7M8bju5+lsjteyqVSsVLHdLhUfPRbE0CQQDyYP6iChqZm1AK
A8x8PKvJsd4zSdxWXUYSmD7mAtek5VeWblbcXYYdeYPN6hNmqzaLelmrZI51x1Uf
hf1ryIfrAkEA1JmdSsNuxi9MOY3HqErWYsqZ//mVOxVyCAwf7OWQ0rTHEQBhQwpS
9nk0YFHI9t6nVUwXrZ7/7UJPTu8OjPKyBwJAYw2OomwcqM/XKvCYfeFRl1DwbOdv
e4AM5gaAFgHtXP85B0o6hz5VU/BYFCvoF9o6pU+wG6IxsiJvQD3C7mx6VwJAbXYW
PVs4WsQZe/ya0vSNQ1pLRjdr9XrKNoh/m4prMYGwiPloGotjQdIP/JO/ZBQplcpS
2qrl3HPqv5poJHwE2wJBAM37BVINHR0zcSHfFLmSYrqmLx2oC3UAB3exmpYSUgOz
wJqPfmPWuuXuu6h0Z2DazUan+2EiecX6C4ywkm+qk1I=
-----END RSA PRIVATE KEY-----

View File

@@ -0,0 +1,19 @@
-----BEGIN CERTIFICATE-----
MIIDEDCCAnmgAwIBAgIJAMhMVuHMz+EgMA0GCSqGSIb3DQEBBQUAMGQxCzAJBgNV
BAYTAlVTMQswCQYDVQQIEwJUWDEPMA0GA1UEBxMGQXVzdGluMSEwHwYDVQQKExhJ
bnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxFDASBgNVBAMTC2V4YW1wbGUuY29tMB4X
DTE2MTEwMjIxMDUzNVoXDTIxMTEwMTIxMDUzNVowZDELMAkGA1UEBhMCVVMxCzAJ
BgNVBAgTAlRYMQ8wDQYDVQQHEwZBdXN0aW4xITAfBgNVBAoTGEludGVybmV0IFdp
ZGdpdHMgUHR5IEx0ZDEUMBIGA1UEAxMLZXhhbXBsZS5jb20wgZ8wDQYJKoZIhvcN
AQEBBQADgY0AMIGJAoGBAMlJw8Kkcc9qTD2/ieHGL5wG6YKaXdakw0NoTcLGeR/o
cAvOiLx9A/HddF8pKgsbpvu5Mb68OgsIvj1kLJjCueCCwUXTxskyoiFQeVmuSLJP
lSF1MiFcQQV9vpeaJ4c22tr66vwTc9VqXg8R04ISYl6EEwmSIKzE04n+QJ5hIx1t
AgMBAAGjgckwgcYwHQYDVR0OBBYEFLYKQbsK2oqRO83NbNXC2R6MkNcRMIGWBgNV
HSMEgY4wgYuAFLYKQbsK2oqRO83NbNXC2R6MkNcRoWikZjBkMQswCQYDVQQGEwJV
UzELMAkGA1UECBMCVFgxDzANBgNVBAcTBkF1c3RpbjEhMB8GA1UEChMYSW50ZXJu
ZXQgV2lkZ2l0cyBQdHkgTHRkMRQwEgYDVQQDEwtleGFtcGxlLmNvbYIJAMhMVuHM
z+EgMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEASwEwGQnRCqcNrb6k
g6/xpeyHE9/ruTBIE4dtArQI0NosaERC3i4nRKbgfJfIuYEaYiga4dC51CQqKrbH
YZ0dgYMzzp21OMQyKdz3E7csMJv5xxe5D2svdPzbBGU5+N80FYLx17f3UqsYFaAC
X0/YTQsdlM5tHZOd1ZbQUrERqLs=
-----END CERTIFICATE-----