|
12 | 12 | namespace Symfony\Component\Security\Core\Tests\Authentication\Provider;
|
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase;
|
15 |
| -use Symfony\Component\Security\Core\Exception\DisabledException; |
16 | 15 | use Symfony\Component\Security\Core\Authentication\Provider\SimpleAuthenticationProvider;
|
| 16 | +use Symfony\Component\Security\Core\Exception\DisabledException; |
17 | 17 | use Symfony\Component\Security\Core\Exception\LockedException;
|
18 | 18 | use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
| 19 | +use Symfony\Component\Security\Core\User\UserChecker; |
19 | 20 |
|
20 | 21 | class SimpleAuthenticationProviderTest extends TestCase
|
21 | 22 | {
|
@@ -121,6 +122,20 @@ public function testUsernameNotFound()
|
121 | 122 | $this->getProvider($authenticator, $userProvider)->authenticate($token);
|
122 | 123 | }
|
123 | 124 |
|
| 125 | + public function testAuthenticateSkipsUserChecksForNonUserInterfaceObjects() |
| 126 | + { |
| 127 | + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); |
| 128 | + $token->expects($this->any()) |
| 129 | + ->method('getUser') |
| 130 | + ->will($this->returnValue('string-user')); |
| 131 | + $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); |
| 132 | + $authenticator->expects($this->once()) |
| 133 | + ->method('authenticateToken') |
| 134 | + ->will($this->returnValue($token)); |
| 135 | + |
| 136 | + $this->assertSame($token, $this->getProvider($authenticator, null, new UserChecker())->authenticate($token)); |
| 137 | + } |
| 138 | + |
124 | 139 | protected function getProvider($simpleAuthenticator = null, $userProvider = null, $userChecker = null, $key = 'test')
|
125 | 140 | {
|
126 | 141 | if (null === $userChecker) {
|
|
0 commit comments