| @@ 78-96 (lines=19) @@ | ||
| 75 | /** |
|
| 76 | * testCreateClaimWithMalformedException method |
|
| 77 | */ |
|
| 78 | public function testCreateClaimWithMalformedException() |
|
| 79 | { |
|
| 80 | $now = Carbon::now()->timestamp; |
|
| 81 | ||
| 82 | Config::shouldReceive('get') |
|
| 83 | ->once() |
|
| 84 | ->with('jwt.leeway') |
|
| 85 | ->andReturn(0); |
|
| 86 | ||
| 87 | $this->setExpectedException(\WWON\JwtGuard\Exceptions\MalformedException::class); |
|
| 88 | ||
| 89 | $claim = new Claim([ |
|
| 90 | 'iss' => 'http://www.test.com', |
|
| 91 | 'iat' => $now, |
|
| 92 | 'exp' => $now - 6000, |
|
| 93 | 'nat' => $now - 6000, |
|
| 94 | 'jti' => 'asdjhasiudhasud' |
|
| 95 | ]); |
|
| 96 | } |
|
| 97 | ||
| 98 | /** |
|
| 99 | * testCreateClaimWithInaccessibleException method |
|
| @@ 101-119 (lines=19) @@ | ||
| 98 | /** |
|
| 99 | * testCreateClaimWithInaccessibleException method |
|
| 100 | */ |
|
| 101 | public function testCreateClaimWithInaccessibleException() |
|
| 102 | { |
|
| 103 | $now = Carbon::now()->timestamp; |
|
| 104 | ||
| 105 | Config::shouldReceive('get') |
|
| 106 | ->once() |
|
| 107 | ->with('jwt.leeway') |
|
| 108 | ->andReturn(0); |
|
| 109 | ||
| 110 | $this->setExpectedException(\WWON\JwtGuard\Exceptions\InaccessibleException::class); |
|
| 111 | ||
| 112 | $claim = new Claim([ |
|
| 113 | 'iss' => 'http://www.test.com', |
|
| 114 | 'iat' => $now - 6000, |
|
| 115 | 'exp' => $now + 6000, |
|
| 116 | 'nat' => $now - 10, |
|
| 117 | 'jti' => 'asdjhasiudhasud' |
|
| 118 | ]); |
|
| 119 | } |
|
| 120 | ||
| 121 | /** |
|
| 122 | * testCreateClaimWithTokenExpiredException method |
|
| @@ 124-142 (lines=19) @@ | ||
| 121 | /** |
|
| 122 | * testCreateClaimWithTokenExpiredException method |
|
| 123 | */ |
|
| 124 | public function testCreateClaimWithTokenExpiredException() |
|
| 125 | { |
|
| 126 | $now = Carbon::now()->timestamp; |
|
| 127 | ||
| 128 | Config::shouldReceive('get') |
|
| 129 | ->once() |
|
| 130 | ->with('jwt.leeway') |
|
| 131 | ->andReturn(0); |
|
| 132 | ||
| 133 | $this->setExpectedException(\WWON\JwtGuard\Exceptions\TokenExpiredException::class); |
|
| 134 | ||
| 135 | $claim = new Claim([ |
|
| 136 | 'iss' => 'http://www.test.com', |
|
| 137 | 'iat' => $now - 6000, |
|
| 138 | 'exp' => $now - 1000, |
|
| 139 | 'nat' => $now - 1000, |
|
| 140 | 'jti' => 'asdjhasiudhasud' |
|
| 141 | ]); |
|
| 142 | } |
|
| 143 | ||
| 144 | } |
|