| @@ 114-132 (lines=19) @@ | ||
| 111 | /** |
|
| 112 | * testCreateClaimWithMalformedException method |
|
| 113 | */ |
|
| 114 | public function testCreateClaimWithMalformedException() |
|
| 115 | { |
|
| 116 | $now = Carbon::now()->timestamp; |
|
| 117 | ||
| 118 | Config::shouldReceive('get') |
|
| 119 | ->once() |
|
| 120 | ->with('jwt.leeway') |
|
| 121 | ->andReturn(0); |
|
| 122 | ||
| 123 | $this->setExpectedException(\WWON\JwtGuard\Exceptions\MalformedException::class); |
|
| 124 | ||
| 125 | $claim = new Claim([ |
|
| 126 | 'iss' => 'http://www.test.com', |
|
| 127 | 'iat' => $now, |
|
| 128 | 'exp' => $now - 6000, |
|
| 129 | 'nat' => $now - 6000, |
|
| 130 | 'jti' => 'asdjhasiudhasud' |
|
| 131 | ]); |
|
| 132 | } |
|
| 133 | ||
| 134 | /** |
|
| 135 | * testCreateClaimWithInaccessibleException method |
|
| @@ 137-157 (lines=21) @@ | ||
| 134 | /** |
|
| 135 | * testCreateClaimWithInaccessibleException method |
|
| 136 | */ |
|
| 137 | public function testCreateClaimWithInaccessibleException() |
|
| 138 | { |
|
| 139 | $now = Carbon::now()->timestamp; |
|
| 140 | ||
| 141 | Config::shouldReceive('get') |
|
| 142 | ->once() |
|
| 143 | ->with('jwt.leeway') |
|
| 144 | ->andReturn(0); |
|
| 145 | ||
| 146 | $this->setExpectedException(\WWON\JwtGuard\Exceptions\InaccessibleException::class); |
|
| 147 | ||
| 148 | $claim = new Claim([ |
|
| 149 | 'iss' => 'http://www.test.com', |
|
| 150 | 'iat' => $now - 6000, |
|
| 151 | 'exp' => $now + 6000, |
|
| 152 | 'nat' => $now - 10, |
|
| 153 | 'jti' => 'asdjhasiudhasud' |
|
| 154 | ]); |
|
| 155 | ||
| 156 | $claim->validateAccessible(); |
|
| 157 | } |
|
| 158 | ||
| 159 | /** |
|
| 160 | * testCreateClaimWithTokenExpiredException method |
|
| @@ 162-180 (lines=19) @@ | ||
| 159 | /** |
|
| 160 | * testCreateClaimWithTokenExpiredException method |
|
| 161 | */ |
|
| 162 | public function testCreateClaimWithTokenExpiredException() |
|
| 163 | { |
|
| 164 | $now = Carbon::now()->timestamp; |
|
| 165 | ||
| 166 | Config::shouldReceive('get') |
|
| 167 | ->once() |
|
| 168 | ->with('jwt.leeway') |
|
| 169 | ->andReturn(0); |
|
| 170 | ||
| 171 | $this->setExpectedException(\WWON\JwtGuard\Exceptions\TokenExpiredException::class); |
|
| 172 | ||
| 173 | $claim = new Claim([ |
|
| 174 | 'iss' => 'http://www.test.com', |
|
| 175 | 'iat' => $now - 6000, |
|
| 176 | 'exp' => $now - 1000, |
|
| 177 | 'nat' => $now - 1000, |
|
| 178 | 'jti' => 'asdjhasiudhasud' |
|
| 179 | ]); |
|
| 180 | } |
|
| 181 | ||
| 182 | } |
|