|
15 | 15 | use Symfony\Component\HttpFoundation\Request;
|
16 | 16 | use Symfony\Component\HttpFoundation\Response;
|
17 | 17 | use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
| 18 | +use Symfony\Component\Security\Guard\AbstractGuardAuthenticator; |
18 | 19 | use Symfony\Component\Security\Guard\AuthenticatorInterface;
|
19 | 20 | use Symfony\Component\Security\Guard\Firewall\GuardAuthenticationListener;
|
20 | 21 | use Symfony\Component\Security\Guard\GuardAuthenticatorInterface;
|
@@ -388,6 +389,37 @@ public function testReturnNullFromGetCredentials()
|
388 | 389 | $listener->handle($this->event);
|
389 | 390 | }
|
390 | 391 |
|
| 392 | + /** |
| 393 | + * @group legacy |
| 394 | + * @expectedDeprecation Returning null from "%s::getCredentials()" is deprecated since version 3.4 and will throw an \UnexpectedValueException in 4.0. Return false from "%s::supports()" instead. |
| 395 | + */ |
| 396 | + public function testReturnNullFromGetCredentialsTriggersForAbstractGuardAuthenticatorInstances() |
| 397 | + { |
| 398 | + $authenticator = $this->getMockBuilder(AbstractGuardAuthenticator::class)->getMock(); |
| 399 | + $providerKey = 'my_firewall4'; |
| 400 | + |
| 401 | + $authenticator |
| 402 | + ->expects($this->once()) |
| 403 | + ->method('supports') |
| 404 | + ->will($this->returnValue(true)); |
| 405 | + |
| 406 | + // this will raise exception |
| 407 | + $authenticator |
| 408 | + ->expects($this->once()) |
| 409 | + ->method('getCredentials') |
| 410 | + ->will($this->returnValue(null)); |
| 411 | + |
| 412 | + $listener = new GuardAuthenticationListener( |
| 413 | + $this->guardAuthenticatorHandler, |
| 414 | + $this->authenticationManager, |
| 415 | + $providerKey, |
| 416 | + array($authenticator), |
| 417 | + $this->logger |
| 418 | + ); |
| 419 | + |
| 420 | + $listener->handle($this->event); |
| 421 | + } |
| 422 | + |
391 | 423 | protected function setUp()
|
392 | 424 | {
|
393 | 425 | $this->authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager')
|
|
0 commit comments