|
@@ 78-95 (lines=18) @@
|
| 75 |
|
$this->assertEquals($user, $guard->user()); |
| 76 |
|
} |
| 77 |
|
|
| 78 |
|
public function testValidate() |
| 79 |
|
{ |
| 80 |
|
$credentials = ['foo' => 'bar']; |
| 81 |
|
|
| 82 |
|
$user = m::mock(\Illuminate\Contracts\Auth\Authenticatable::class); |
| 83 |
|
$provider = m::mock(Illuminate\Contracts\Auth\UserProvider::class); |
| 84 |
|
$provider->shouldReceive('retrieveByCredentials')->once()->with($credentials)->andReturn($user); |
| 85 |
|
$provider->shouldReceive('validateCredentials')->once()->with($user, $credentials)->andReturn(true); |
| 86 |
|
|
| 87 |
|
$blacklist = m::mock(Framgia\Jwt\Blacklist::class); |
| 88 |
|
$signer = m::mock(Framgia\Jwt\Contracts\Signer::class); |
| 89 |
|
|
| 90 |
|
$request = Illuminate\Http\Request::create('/'); |
| 91 |
|
|
| 92 |
|
$guard = new Framgia\Jwt\Guard($provider, $request, $blacklist, $signer); |
| 93 |
|
|
| 94 |
|
$this->assertTrue($guard->validate($credentials)); |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
public function testValidateFailsWithFakeCredentials() |
| 98 |
|
{ |
|
@@ 114-131 (lines=18) @@
|
| 111 |
|
$this->assertFalse($guard->validate($credentials)); |
| 112 |
|
} |
| 113 |
|
|
| 114 |
|
public function testAttempt() |
| 115 |
|
{ |
| 116 |
|
$credentials = ['foo' => 'bar']; |
| 117 |
|
|
| 118 |
|
$user = m::mock(\Illuminate\Contracts\Auth\Authenticatable::class); |
| 119 |
|
$provider = m::mock(Illuminate\Contracts\Auth\UserProvider::class); |
| 120 |
|
$provider->shouldReceive('retrieveByCredentials')->once()->with($credentials)->andReturn($user); |
| 121 |
|
$provider->shouldReceive('validateCredentials')->once()->with($user, $credentials)->andReturn(true); |
| 122 |
|
|
| 123 |
|
$blacklist = m::mock(Framgia\Jwt\Blacklist::class); |
| 124 |
|
$signer = m::mock(Framgia\Jwt\Contracts\Signer::class); |
| 125 |
|
|
| 126 |
|
$request = Illuminate\Http\Request::create('/'); |
| 127 |
|
|
| 128 |
|
$guard = new Framgia\Jwt\Guard($provider, $request, $blacklist, $signer); |
| 129 |
|
|
| 130 |
|
$this->assertTrue($guard->validate($credentials)); |
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
public function testUserReturnsNullWithoutToken() |
| 134 |
|
{ |