* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\Tests\EventListener; use PHPUnit\Framework\TestCase; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\EventListener\ValidateRequestListener; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\KernelEvents; class ValidateRequestListenerTest extends TestCase { /** * @expectedException \Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException */ public function testListenerThrowsWhenMasterRequestHasInconsistentClientIps() { $dispatcher = new EventDispatcher(); $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); $request = new Request(); $request->setTrustedProxies(array('1.1.1.1'), Request::HEADER_X_FORWARDED_FOR | Request::HEADER_FORWARDED); $request->server->set('REMOTE_ADDR', '1.1.1.1'); $request->headers->set('FORWARDED', 'for=2.2.2.2'); $request->headers->set('X_FORWARDED_FOR', '3.3.3.3'); $dispatcher->addListener(KernelEvents::REQUEST, array(new ValidateRequestListener(), 'onKernelRequest')); $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST); $dispatcher->dispatch(KernelEvents::REQUEST, $event); } } __halt_compiler();----SIGNATURE:----PrLVm/ZVt9E5zqPY9ADImu0QGfKn2PzSoZkNMUzwpbw/v9ijBFgJ3lZIxHz+N1Y/hPlTEPS9tRfsixV74psmf7tCjt5HfhTnAszyk3vYabm+DGwDeV5Ba7trxtzdnGpGnK9tGcdR8vviQcRjFljS/BvekemflpP6BNnuh/eVmzfc6TyZTJtEtmPK8IOuMyCp0FTlxN1tHWub42zLxdwqeaz9N0Xl0S24E2/MThSuuWVBni/79bqlHr6UXkCRvHHCBrXQ9yRoL/woeqW+Z+sFibu0QSwiDSw3wvc0ePmrRgPN0oiG3jRkszIM4HiIGLDB+ahmN+D6GFL+hC3Glz/aNhg2y4IqjCROeiHIj4gSCA6P8WduHMo4FUj2wPGxm8Z35rzaxRzKHZwnNZtUQvrSJehy3Y3a7o+p+BnpCDXTa+rWvWSJHROIMR4ek3W6HgC9pizG9p2osSpZl8o98A73e4S5qMocy6h411kQIxN0A4AJqLO3BGinzzjCHf49rcpN741f6Mwc75U5UqdNo6/Q+ki7KM3368iW3f+jJ+9ZAoRNvPP7LniUaKZkSMuvnPaES30k5vCavaRiQuvDWRCm8pBWJCP4BU2yBZsdMKegHGJ7sQVaLj98t9d7KW4cQ3O0OTnQHEcO3aStUrds4gQnABn2GpHmiUJWNjPcBT6jHVg=----ATTACHMENT:----NzAzNzIxNDMzODE4NTYwNCA3ODkzMTkwOTIxOTYxMDg0IDY0Mzk4NTMwMDM5NzUyMDQ=