updated-packages
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user