@@ 144-154 (lines=11) @@ | ||
141 | "message" => "The given data was invalid.", "name" => "ValidationException", "status" => 422]); |
|
142 | } |
|
143 | ||
144 | public function testLogin() |
|
145 | { |
|
146 | $password = $this->newPassword(); |
|
147 | /** @var UserInterface $user */ |
|
148 | $user = entity(User::class)->create(['originalPassword' => $password]); |
|
149 | $this->json('POST', '/login', [ |
|
150 | 'email' => $user->getEmail(), |
|
151 | 'password' => $password |
|
152 | ])->seeJsonEquals(['id' => $user->getId()])->seeHeader('jwt-token'); |
|
153 | self::assertNotNull($this->response->headers->get('jwt-token')); |
|
154 | } |
|
155 | ||
156 | public function testMultipleValidationErrors() |
|
157 | { |
|
@@ 271-281 (lines=11) @@ | ||
268 | "message" => "The given data was invalid.", "name" => "ValidationException", "status" => 422]); |
|
269 | } |
|
270 | ||
271 | public function testWrongPassword() |
|
272 | { |
|
273 | $password = $this->newPassword(); |
|
274 | /** @var UserInterface $user */ |
|
275 | $user = entity(User::class)->create(['originalPassword' => $password]); |
|
276 | $this->json('POST', '/login', [ |
|
277 | 'email' => $user->getEmail(), |
|
278 | 'password' => $password . "wrong-password" |
|
279 | ])->seeStatusCode(401); |
|
280 | self::assertNull($this->response->headers->get('jwt-token')); |
|
281 | } |
|
282 | ||
283 | public function testWrongUsername() |
|
284 | { |
|
@@ 283-293 (lines=11) @@ | ||
280 | self::assertNull($this->response->headers->get('jwt-token')); |
|
281 | } |
|
282 | ||
283 | public function testWrongUsername() |
|
284 | { |
|
285 | $password = $this->newPassword(); |
|
286 | /** @var UserInterface $user */ |
|
287 | $user = entity(User::class)->create(['originalPassword' => $password]); |
|
288 | $this->json('POST', '/login', [ |
|
289 | 'email' => $user->getEmail() . "wrong-email", |
|
290 | 'password' => $password |
|
291 | ])->seeStatusCode(401); |
|
292 | self::assertNull($this->response->headers->get('jwt-token')); |
|
293 | } |
|
294 | //</editor-fold desc="Public Methods"> |
|
295 | } |
|
296 |