Update v1.0.6.5
This commit is contained in:
82
vendor/tymon/jwt-auth/tests/BlacklistTest.php
vendored
82
vendor/tymon/jwt-auth/tests/BlacklistTest.php
vendored
@@ -1,7 +1,17 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Test\Providers\JWT;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Mockery;
|
||||
use Tymon\JWTAuth\Blacklist;
|
||||
use Tymon\JWTAuth\Payload;
|
||||
@@ -9,17 +19,18 @@ use Tymon\JWTAuth\Claims\Issuer;
|
||||
use Tymon\JWTAuth\Claims\IssuedAt;
|
||||
use Tymon\JWTAuth\Claims\Expiration;
|
||||
use Tymon\JWTAuth\Claims\NotBefore;
|
||||
use Tymon\JWTAuth\Claims\Audience;
|
||||
use Tymon\JWTAuth\Claims\Subject;
|
||||
use Tymon\JWTAuth\Claims\JwtId;
|
||||
use Tymon\JWTAuth\Claims\Custom;
|
||||
|
||||
class BlacklistTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
Carbon::setTestNow(Carbon::createFromTimeStampUTC(123));
|
||||
|
||||
$this->storage = Mockery::mock('Tymon\JWTAuth\Providers\Storage\StorageInterface');
|
||||
$this->blacklist = new Blacklist($this->storage);
|
||||
$this->blacklist->setRefreshTTL(20160);
|
||||
|
||||
$this->validator = Mockery::mock('Tymon\JWTAuth\Validators\PayloadValidator');
|
||||
$this->validator->shouldReceive('setRefreshFlow->check');
|
||||
@@ -36,27 +47,44 @@ class BlacklistTest extends \PHPUnit_Framework_TestCase
|
||||
$claims = [
|
||||
new Subject(1),
|
||||
new Issuer('http://example.com'),
|
||||
new Expiration(123 + 3600),
|
||||
new NotBefore(123),
|
||||
new IssuedAt(123),
|
||||
new JwtId('foo')
|
||||
new Expiration(100 + 3600),
|
||||
new NotBefore(100),
|
||||
new IssuedAt(100),
|
||||
new JwtId('foo'),
|
||||
];
|
||||
$payload = new Payload($claims, $this->validator);
|
||||
|
||||
$this->storage->shouldReceive('add')->with('foo', [], 61);
|
||||
$this->blacklist->add($payload);
|
||||
$this->storage->shouldReceive('add')->once()->with('foo', [], 20160);
|
||||
$this->assertTrue($this->blacklist->add($payload));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_should_return_false_when_adding_an_expired_token_to_the_blacklist()
|
||||
public function it_should_return_true_when_adding_a_refreshable_expired_token_to_the_blacklist()
|
||||
{
|
||||
$claims = [
|
||||
new Subject(1),
|
||||
new Issuer('http://example.com'),
|
||||
new Expiration(123 - 3600),
|
||||
new NotBefore(123),
|
||||
new IssuedAt(123),
|
||||
new JwtId('foo')
|
||||
new Expiration(101),
|
||||
new NotBefore(100),
|
||||
new IssuedAt(100),
|
||||
new JwtId('foo'),
|
||||
];
|
||||
$payload = new Payload($claims, $this->validator, true);
|
||||
|
||||
$this->storage->shouldReceive('add')->once()->with('foo', [], 20160);
|
||||
$this->assertTrue($this->blacklist->add($payload));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_should_return_false_when_adding_an_unrefreshable_token_to_the_blacklist()
|
||||
{
|
||||
$claims = [
|
||||
new Subject(1),
|
||||
new Issuer('http://example.com'),
|
||||
new Expiration(100), // default refresh_ttl
|
||||
new NotBefore(100),
|
||||
new IssuedAt(100 - 20160 * 60),
|
||||
new JwtId('foo'),
|
||||
];
|
||||
$payload = new Payload($claims, $this->validator, true);
|
||||
|
||||
@@ -64,6 +92,24 @@ class BlacklistTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertFalse($this->blacklist->add($payload));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_should_return_false_when_adding_a_unrefreshable_token_after_modifying_refresh_ttl()
|
||||
{
|
||||
$claims = [
|
||||
new Subject(1),
|
||||
new Issuer('http://example.com'),
|
||||
new Expiration(101),
|
||||
new NotBefore(100),
|
||||
new IssuedAt(100),
|
||||
new JwtId('foo'),
|
||||
];
|
||||
$payload = new Payload($claims, $this->validator, true);
|
||||
|
||||
$this->storage->shouldReceive('add')->never();
|
||||
$this->blacklist->setRefreshTTL(0);
|
||||
$this->assertFalse($this->blacklist->add($payload));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_should_check_whether_a_token_has_been_blacklisted()
|
||||
{
|
||||
@@ -73,11 +119,11 @@ class BlacklistTest extends \PHPUnit_Framework_TestCase
|
||||
new Expiration(123 + 3600),
|
||||
new NotBefore(123),
|
||||
new IssuedAt(123),
|
||||
new JwtId('foobar')
|
||||
new JwtId('foobar'),
|
||||
];
|
||||
$payload = new Payload($claims, $this->validator);
|
||||
|
||||
$this->storage->shouldReceive('has')->with('foobar')->andReturn(true);
|
||||
$this->storage->shouldReceive('has')->once()->with('foobar')->andReturn(true);
|
||||
$this->assertTrue($this->blacklist->has($payload));
|
||||
}
|
||||
|
||||
@@ -90,18 +136,18 @@ class BlacklistTest extends \PHPUnit_Framework_TestCase
|
||||
new Expiration(123 + 3600),
|
||||
new NotBefore(123),
|
||||
new IssuedAt(123),
|
||||
new JwtId('foobar')
|
||||
new JwtId('foobar'),
|
||||
];
|
||||
$payload = new Payload($claims, $this->validator);
|
||||
|
||||
$this->storage->shouldReceive('destroy')->with('foobar')->andReturn(true);
|
||||
$this->storage->shouldReceive('destroy')->once()->with('foobar')->andReturn(true);
|
||||
$this->assertTrue($this->blacklist->remove($payload));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_should_empty_the_blacklist()
|
||||
{
|
||||
$this->storage->shouldReceive('flush');
|
||||
$this->storage->shouldReceive('flush')->once();
|
||||
$this->assertTrue($this->blacklist->clear());
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Test;
|
||||
|
||||
use Mockery;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Tymon\JWTAuth\Commands\JWTGenerateCommand;
|
||||
use Illuminate\Foundation\Application;
|
||||
@@ -29,7 +37,7 @@ class JWTGenerateCommandTest extends \PHPUnit_Framework_TestCase
|
||||
// $this->runCommand($this->command);
|
||||
}
|
||||
|
||||
protected function runCommand($command, $input = array())
|
||||
protected function runCommand($command, $input = [])
|
||||
{
|
||||
return $command->run(new ArrayInput($input), new NullOutput);
|
||||
}
|
||||
|
11
vendor/tymon/jwt-auth/tests/JWTAuthTest.php
vendored
11
vendor/tymon/jwt-auth/tests/JWTAuthTest.php
vendored
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Test;
|
||||
|
||||
use Mockery;
|
||||
@@ -93,7 +102,7 @@ class JWTAuthTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->setExpectedException('Tymon\JWTAuth\Exceptions\JWTException');
|
||||
|
||||
$user = $this->jwtAuth->toUser();
|
||||
$this->jwtAuth->toUser();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
|
23
vendor/tymon/jwt-auth/tests/JWTManagerTest.php
vendored
23
vendor/tymon/jwt-auth/tests/JWTManagerTest.php
vendored
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Test\Providers\JWT;
|
||||
|
||||
use Mockery;
|
||||
@@ -10,10 +19,8 @@ use Tymon\JWTAuth\Claims\Issuer;
|
||||
use Tymon\JWTAuth\Claims\IssuedAt;
|
||||
use Tymon\JWTAuth\Claims\Expiration;
|
||||
use Tymon\JWTAuth\Claims\NotBefore;
|
||||
use Tymon\JWTAuth\Claims\Audience;
|
||||
use Tymon\JWTAuth\Claims\Subject;
|
||||
use Tymon\JWTAuth\Claims\JwtId;
|
||||
use Tymon\JWTAuth\Claims\Custom;
|
||||
|
||||
class JWTManagerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@@ -42,7 +49,7 @@ class JWTManagerTest extends \PHPUnit_Framework_TestCase
|
||||
new Expiration(123 + 3600),
|
||||
new NotBefore(123),
|
||||
new IssuedAt(123),
|
||||
new JwtId('foo')
|
||||
new JwtId('foo'),
|
||||
];
|
||||
$payload = new Payload($claims, $this->validator);
|
||||
|
||||
@@ -62,7 +69,7 @@ class JWTManagerTest extends \PHPUnit_Framework_TestCase
|
||||
new Expiration(123 + 3600),
|
||||
new NotBefore(123),
|
||||
new IssuedAt(123),
|
||||
new JwtId('foo')
|
||||
new JwtId('foo'),
|
||||
];
|
||||
$payload = new Payload($claims, $this->validator);
|
||||
$token = new Token('foo.bar.baz');
|
||||
@@ -87,7 +94,7 @@ class JWTManagerTest extends \PHPUnit_Framework_TestCase
|
||||
new Expiration(123 + 3600),
|
||||
new NotBefore(123),
|
||||
new IssuedAt(123),
|
||||
new JwtId('foo')
|
||||
new JwtId('foo'),
|
||||
];
|
||||
$payload = new Payload($claims, $this->validator);
|
||||
$token = new Token('foo.bar.baz');
|
||||
@@ -96,7 +103,7 @@ class JWTManagerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->factory->shouldReceive('setRefreshFlow->make')->with($payload->toArray())->andReturn($payload);
|
||||
$this->blacklist->shouldReceive('has')->with($payload)->andReturn(true);
|
||||
|
||||
$payload = $this->manager->decode($token);
|
||||
$this->manager->decode($token);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
@@ -108,7 +115,7 @@ class JWTManagerTest extends \PHPUnit_Framework_TestCase
|
||||
new Expiration(123 - 3600),
|
||||
new NotBefore(123),
|
||||
new IssuedAt(123),
|
||||
new JwtId('foo')
|
||||
new JwtId('foo'),
|
||||
];
|
||||
$payload = new Payload($claims, $this->validator, true);
|
||||
$token = new Token('foo.bar.baz');
|
||||
@@ -137,7 +144,7 @@ class JWTManagerTest extends \PHPUnit_Framework_TestCase
|
||||
new Expiration(123 + 3600),
|
||||
new NotBefore(123),
|
||||
new IssuedAt(123),
|
||||
new JwtId('foo')
|
||||
new JwtId('foo'),
|
||||
];
|
||||
$payload = new Payload($claims, $this->validator);
|
||||
$token = new Token('foo.bar.baz');
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Test;
|
||||
|
||||
use Mockery;
|
||||
@@ -11,11 +20,11 @@ class GetUserFromTokenTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
$this->events = Mockery::mock('Illuminate\Events\Dispatcher');
|
||||
$this->events = Mockery::mock('Illuminate\Contracts\Events\Dispatcher');
|
||||
$this->auth = Mockery::mock('Tymon\JWTAuth\JWTAuth');
|
||||
|
||||
$this->request = Mockery::mock('Illuminate\Http\Request');
|
||||
$this->response = Mockery::mock('Illuminate\Routing\ResponseFactory');
|
||||
$this->response = Mockery::mock('Illuminate\Contracts\Routing\ResponseFactory');
|
||||
|
||||
$this->middleware = new GetUserFromToken($this->response, $this->events, $this->auth);
|
||||
|
||||
|
@@ -1,16 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Test\Providers\JWT;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Mockery;
|
||||
use Tymon\JWTAuth\Payload;
|
||||
use Tymon\JWTAuth\PayloadFactory;
|
||||
use Illuminate\Http\Request;
|
||||
use Tymon\JWTAuth\Claims\Issuer;
|
||||
use Tymon\JWTAuth\Claims\IssuedAt;
|
||||
use Tymon\JWTAuth\Claims\Expiration;
|
||||
use Tymon\JWTAuth\Claims\NotBefore;
|
||||
use Tymon\JWTAuth\Claims\Audience;
|
||||
use Tymon\JWTAuth\Claims\Subject;
|
||||
use Tymon\JWTAuth\Claims\JwtId;
|
||||
use Tymon\JWTAuth\Claims\Custom;
|
||||
@@ -19,6 +27,8 @@ class PayloadFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
Carbon::setTestNow(Carbon::createFromTimeStampUTC(123));
|
||||
|
||||
$this->claimFactory = Mockery::mock('Tymon\JWTAuth\Claims\Factory');
|
||||
$this->validator = Mockery::mock('Tymon\JWTAuth\Validators\PayloadValidator');
|
||||
$this->factory = new PayloadFactory($this->claimFactory, Request::create('/foo', 'GET'), $this->validator);
|
||||
@@ -34,13 +44,13 @@ class PayloadFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->validator->shouldReceive('setRefreshFlow->check');
|
||||
|
||||
$expTime = time() + 3600;
|
||||
$expTime = 123 + 3600;
|
||||
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('sub', 1)->andReturn(new Subject(1));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('iss', Mockery::any())->andReturn(new Issuer('/foo'));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('iat', 123)->andReturn(new IssuedAt(123));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('jti', 'foo')->andReturn(new JwtId('foo'));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('nbf', time())->andReturn(new NotBefore(time()));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('nbf', 123)->andReturn(new NotBefore(123));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('exp', $expTime)->andReturn(new Expiration($expTime));
|
||||
|
||||
$payload = $this->factory->make(['sub' => 1, 'jti' => 'foo', 'iat' => 123]);
|
||||
@@ -59,10 +69,10 @@ class PayloadFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('sub', 1)->andReturn(new Subject(1));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('iss', Mockery::any())->andReturn(new Issuer('/foo'));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('exp', time() + 3600)->andReturn(new Expiration(time() + 3600));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('iat', time())->andReturn(new IssuedAt(time()));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('exp', 123 + 3600)->andReturn(new Expiration(123 + 3600));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('iat', 123)->andReturn(new IssuedAt(123));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('jti', Mockery::any())->andReturn(new JwtId('foo'));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('nbf', time())->andReturn(new NotBefore(time()));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('nbf', 123)->andReturn(new NotBefore(123));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('foo', 'baz')->andReturn(new Custom('foo', 'baz'));
|
||||
|
||||
$payload = $this->factory->sub(1)->foo('baz')->make();
|
||||
@@ -81,10 +91,10 @@ class PayloadFactoryTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('sub', 1)->andReturn(new Subject(1));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('iss', Mockery::any())->andReturn(new Issuer('/foo'));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('exp', Mockery::any())->andReturn(new Expiration(time() + 3600));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('iat', Mockery::any())->andReturn(new IssuedAt(time()));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('exp', Mockery::any())->andReturn(new Expiration(123 + 3600));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('iat', Mockery::any())->andReturn(new IssuedAt(123));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('jti', Mockery::any())->andReturn(new JwtId('foo'));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('nbf', Mockery::any())->andReturn(new NotBefore(time()));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('nbf', Mockery::any())->andReturn(new NotBefore(123));
|
||||
$this->claimFactory->shouldReceive('get')->once()->with('foo', ['bar' => [0, 0, 0]])->andReturn(new Custom('foo', ['bar' => [0, 0, 0]]));
|
||||
|
||||
$payload = $this->factory->sub(1)->foo(['bar' => [0, 0, 0]])->make();
|
||||
|
23
vendor/tymon/jwt-auth/tests/PayloadTest.php
vendored
23
vendor/tymon/jwt-auth/tests/PayloadTest.php
vendored
@@ -1,10 +1,18 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Test\Providers\JWT;
|
||||
|
||||
use Tymon\JWTAuth\Providers\JWT\FirebaseAdapter;
|
||||
use Carbon\Carbon;
|
||||
use Tymon\JWTAuth\Payload;
|
||||
use Tymon\JWTAuth\PayloadFactory;
|
||||
use Mockery;
|
||||
use Tymon\JWTAuth\Claims\Issuer;
|
||||
use Tymon\JWTAuth\Claims\IssuedAt;
|
||||
@@ -13,19 +21,20 @@ use Tymon\JWTAuth\Claims\NotBefore;
|
||||
use Tymon\JWTAuth\Claims\Audience;
|
||||
use Tymon\JWTAuth\Claims\Subject;
|
||||
use Tymon\JWTAuth\Claims\JwtId;
|
||||
use Tymon\JWTAuth\Claims\Custom;
|
||||
|
||||
class PayloadTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
Carbon::setTestNow(Carbon::createFromTimeStampUTC(123));
|
||||
|
||||
$claims = [
|
||||
new Subject(1),
|
||||
new Issuer('http://example.com'),
|
||||
new Expiration(time() + 3600),
|
||||
new NotBefore(time()),
|
||||
new IssuedAt(time()),
|
||||
new JwtId('foo')
|
||||
new Expiration(123 + 3600),
|
||||
new NotBefore(123),
|
||||
new IssuedAt(123),
|
||||
new JwtId('foo'),
|
||||
];
|
||||
|
||||
$this->validator = Mockery::mock('Tymon\JWTAuth\Validators\PayloadValidator');
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Test\Providers\Auth;
|
||||
|
||||
use Mockery;
|
||||
@@ -35,10 +44,18 @@ class IlluminateAuthAdapterTest extends \PHPUnit_Framework_TestCase
|
||||
/** @test */
|
||||
public function it_should_return_false_if_user_is_not_found()
|
||||
{
|
||||
$this->authManager->shouldReceive('onceUsingId')->once()->with(123)->andThrow(new \Exception);
|
||||
$this->authManager->shouldReceive('onceUsingId')->once()->with(123)->andReturn(false);
|
||||
$this->assertFalse($this->auth->byId(123));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_should_bubble_exceptions_from_auth()
|
||||
{
|
||||
$this->authManager->shouldReceive('onceUsingId')->once()->with(123)->andThrow(new \Exception('Some auth failure'));
|
||||
$this->setExpectedException('Exception', 'Some auth failure');
|
||||
$this->auth->byId(123);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_should_return_the_currently_authenticated_user()
|
||||
{
|
||||
|
@@ -1,9 +1,17 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Test\Providers\JWT;
|
||||
|
||||
use Mockery;
|
||||
use Illuminate\Http\Request;
|
||||
use Tymon\JWTAuth\Test\Stubs\JWTProviderStub;
|
||||
|
||||
class JWTProviderTest extends \PHPUnit_Framework_TestCase
|
||||
|
@@ -1,15 +1,26 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Test\Providers\JWT;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Mockery;
|
||||
use Illuminate\Http\Request;
|
||||
use Tymon\JWTAuth\Providers\JWT\NamshiAdapter;
|
||||
|
||||
class NamshiAdapterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
Carbon::setTestNow(Carbon::createFromTimeStampUTC(123));
|
||||
|
||||
$this->jws = Mockery::mock('Namshi\JOSE\JWS');
|
||||
$this->provider = new NamshiAdapter('secret', 'HS256', $this->jws);
|
||||
}
|
||||
@@ -22,7 +33,7 @@ class NamshiAdapterTest extends \PHPUnit_Framework_TestCase
|
||||
/** @test */
|
||||
public function it_should_return_the_token_when_passing_a_valid_subject_to_encode()
|
||||
{
|
||||
$payload = ['sub' => 1, 'exp' => time(), 'iat' => time(), 'iss' => '/foo'];
|
||||
$payload = ['sub' => 1, 'exp' => 123, 'iat' => 123, 'iss' => '/foo'];
|
||||
|
||||
$this->jws->shouldReceive('setPayload')->once()->with($payload)->andReturn(Mockery::self());
|
||||
$this->jws->shouldReceive('sign')->once()->with('secret')->andReturn(Mockery::self());
|
||||
@@ -40,8 +51,8 @@ class NamshiAdapterTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->jws->shouldReceive('sign')->andThrow(new \Exception);
|
||||
|
||||
$payload = ['sub' => 1, 'exp' => time(), 'iat' => time(), 'iss' => '/foo'];
|
||||
$token = $this->provider->encode($payload);
|
||||
$payload = ['sub' => 1, 'exp' => 123, 'iat' => 123, 'iss' => '/foo'];
|
||||
$this->provider->encode($payload);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Test\Providers\Storage;
|
||||
|
||||
use Mockery;
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Test\Providers\User;
|
||||
|
||||
use Mockery;
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Test\Stubs;
|
||||
|
||||
use Tymon\JWTAuth\Providers\JWT\JWTProvider;
|
||||
|
9
vendor/tymon/jwt-auth/tests/TokenTest.php
vendored
9
vendor/tymon/jwt-auth/tests/TokenTest.php
vendored
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Test\Providers\JWT;
|
||||
|
||||
use Tymon\JWTAuth\Token;
|
||||
|
@@ -1,14 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Test;
|
||||
|
||||
use Mockery;
|
||||
use Carbon\Carbon;
|
||||
use Tymon\JWTAuth\Validators\PayloadValidator;
|
||||
|
||||
class PayloadValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
Carbon::setTestNow(Carbon::createFromTimeStampUTC(123));
|
||||
$this->validator = new PayloadValidator();
|
||||
}
|
||||
|
||||
@@ -17,11 +27,11 @@ class PayloadValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$payload = [
|
||||
'iss' => 'http://example.com',
|
||||
'iat' => time(),
|
||||
'nbf' => time(),
|
||||
'exp' => time() + 3600,
|
||||
'iat' => 100,
|
||||
'nbf' => 100,
|
||||
'exp' => 100 + 3600,
|
||||
'sub' => 1,
|
||||
'jti' => 'foo'
|
||||
'jti' => 'foo',
|
||||
];
|
||||
|
||||
$this->assertTrue($this->validator->isValid($payload));
|
||||
@@ -34,11 +44,11 @@ class PayloadValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$payload = [
|
||||
'iss' => 'http://example.com',
|
||||
'iat' => time() - 3660,
|
||||
'nbf' => time() - 3660,
|
||||
'exp' => time() - 1440,
|
||||
'iat' => 20,
|
||||
'nbf' => 20,
|
||||
'exp' => 120,
|
||||
'sub' => 1,
|
||||
'jti' => 'foo'
|
||||
'jti' => 'foo',
|
||||
];
|
||||
|
||||
$this->validator->check($payload);
|
||||
@@ -51,11 +61,11 @@ class PayloadValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$payload = [
|
||||
'iss' => 'http://example.com',
|
||||
'iat' => time() - 3660,
|
||||
'nbf' => time() + 3660,
|
||||
'exp' => time() + 1440,
|
||||
'iat' => 100,
|
||||
'nbf' => 150,
|
||||
'exp' => 150 + 3600,
|
||||
'sub' => 1,
|
||||
'jti' => 'foo'
|
||||
'jti' => 'foo',
|
||||
];
|
||||
|
||||
$this->validator->check($payload);
|
||||
@@ -68,11 +78,11 @@ class PayloadValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$payload = [
|
||||
'iss' => 'http://example.com',
|
||||
'iat' => time() + 3660,
|
||||
'nbf' => time() - 3660,
|
||||
'exp' => time() + 1440,
|
||||
'iat' => 150,
|
||||
'nbf' => 100,
|
||||
'exp' => 150 + 3600,
|
||||
'sub' => 1,
|
||||
'jti' => 'foo'
|
||||
'jti' => 'foo',
|
||||
];
|
||||
|
||||
$this->validator->check($payload);
|
||||
@@ -85,7 +95,7 @@ class PayloadValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$payload = [
|
||||
'iss' => 'http://example.com',
|
||||
'sub' => 1
|
||||
'sub' => 1,
|
||||
];
|
||||
|
||||
$this->validator->check($payload);
|
||||
@@ -98,10 +108,10 @@ class PayloadValidatorTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$payload = [
|
||||
'iss' => 'http://example.com',
|
||||
'iat' => time() - 3660,
|
||||
'iat' => 100,
|
||||
'exp' => 'foo',
|
||||
'sub' => 1,
|
||||
'jti' => 'foo'
|
||||
'jti' => 'foo',
|
||||
];
|
||||
|
||||
$this->validator->check($payload);
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Test;
|
||||
|
||||
use Tymon\JWTAuth\Validators\TokenValidator;
|
||||
|
Reference in New Issue
Block a user