* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Http\Tests\Firewall; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Http\Firewall\RemoteUserAuthenticationListener; class RemoteUserAuthenticationListenerTest extends TestCase { public function testGetPreAuthenticatedData() { $serverVars = array( 'REMOTE_USER' => 'TheUser', ); $request = new Request(array(), array(), array(), array(), array(), $serverVars); $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $listener = new RemoteUserAuthenticationListener( $tokenStorage, $authenticationManager, 'TheProviderKey' ); $method = new \ReflectionMethod($listener, 'getPreAuthenticatedData'); $method->setAccessible(true); $result = $method->invokeArgs($listener, array($request)); $this->assertSame($result, array('TheUser', null)); } /** * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException */ public function testGetPreAuthenticatedDataNoUser() { $request = new Request(array(), array(), array(), array(), array(), array()); $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $listener = new RemoteUserAuthenticationListener( $tokenStorage, $authenticationManager, 'TheProviderKey' ); $method = new \ReflectionMethod($listener, 'getPreAuthenticatedData'); $method->setAccessible(true); $result = $method->invokeArgs($listener, array($request)); } public function testGetPreAuthenticatedDataWithDifferentKeys() { $userCredentials = array('TheUser', null); $request = new Request(array(), array(), array(), array(), array(), array( 'TheUserKey' => 'TheUser', )); $tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock(); $authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock(); $listener = new RemoteUserAuthenticationListener( $tokenStorage, $authenticationManager, 'TheProviderKey', 'TheUserKey' ); $method = new \ReflectionMethod($listener, 'getPreAuthenticatedData'); $method->setAccessible(true); $result = $method->invokeArgs($listener, array($request)); $this->assertSame($result, $userCredentials); } } __halt_compiler();----SIGNATURE:----gVGIiuxhkjPkb/960/BoIG2uSeTCpFKvP0caU17N3uBSZLQu4pK9A9oOfItKy8XKmKHqTDUrNK0OpY8oeAkPoBuK8DibrJFJm/epfiDMH3Oxsb+iJzbipliQCCqbQ1i/nUnitLDsp0uoJf6RyPwdwXabLJCu32h3DFWpTwASsINMgpoQSp7sjkUvwVvkWUOf0/WjgPCJMlDlvd+f2j1Eq6EZdDr04k+7P45knfRxVSAj6nR/wNxl1h2ylgEFZF4r7YnA85/QOyK0MQ3COokmQJG09iP7AOESOp7vSFgluRY8j5Ro3meAGdfIzJnqhmDhebFRpHCfQTQMdqb2C2lNnAzbD4e9FmDDImgyJIdyUJ2gkqWb3HqFQXM2uNMQYU6uCEI29KhSYY80fEzTcErFDcoyCvwaWWl4OrS6h2sF1R/XWnhEBtkDdkDCNsd4+LakiE3R4hitOi5dkX9pgFZp1VBvJa1zgRejqug8b3q4+2Fw7FifgzuSWc3ddmNUUHIkIlQR7KP5AxbpFLBen8yuAaUSJSvcdJz5LOCtDj0z94PGDp+lVjcBv0IyW/WhMFa4m426/TLjTpQ6TNYUG+1CE71IEnkTbXK+Mc+A1rwsmpsBSe+F35t89+OJfKhG6txfR5Y2wJcjStn7CIBXP5yNc9hbR8Z0/xFYxyux+J/t0BQ=----ATTACHMENT:----Mjc4MDA3MDgyNzcwNTUyNSAzMzg1MzgwMjExNjAxNTk3IDE2MjgyMDc2MDczNTMxODk=