* * 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:----lj3dw1zlwYxDLM/ynq77V+9fPya/t1QoT5jn3aSpnXpG+kSyvXUrTJ89cPVwF+BkzGNeNoW1A12RLKIZ9RjlZl8ioZzFJY7yHaOVxLokkHnba28hWwS7YAOWGE3o55vKqudGW34tGMc5VRL51ZcHhZ50mKn9KlQ7pMU7AZtyqpj7PUtApaTSvQLW0G2xs720VDDGR8RKJCfNeR/84UniBTMCmGN3Kat/9Vv4Af5nH8hQbX0eUSKOlwGcv3KrZT+NQz0RCoZGLwdQXNlUZ+somatth+ujJiATaY1pYOnlmUdB/3z0KKw5br95BMCG8Gnif1+rEAFuA15lfN+K+SHFTaciZnxdccofDek4/HtRXOoVvlvMPl57ZA2I4ImI6qRJ4BZHtRAnNHeZ7BM/Z81cPaPY4LP0ztBj10o+Ej+6iQAp2tNXsAaO4VS2it7LOknbYnJ819F3WkI36xKEQUIb9Gi8WEqX0bKS57IcCFYKApdxGtjuTMzAj3t7teYxL/U+6DiURKTk7RMuY+33jQD4c+v8uDX5DT5QuQQ/7hdVD/LcTVA9+vTxZ0sBkMXAwITpB+F4Hqvvhl06rx53sVk9ca6P2TIMnx4KCIWb8EgbX1QqPo+JFUzrOYk/JRXAiO6USBbhpbf2xmjCb8l1d0UlHYSue5lA6OJpWYzCCkku5BQ=----ATTACHMENT:----Mjk5OTU1NDI2MDg1NzIzMyAyMDIzMDI5NjE0MTU0MDE1IDU1MzMyMDU1MTczMzQyNw==