update 1.0.8.0
Commits for version update
This commit is contained in:
42
vendor/symfony/http-kernel/Tests/EventListener/ValidateRequestListenerTest.php
vendored
Normal file
42
vendor/symfony/http-kernel/Tests/EventListener/ValidateRequestListenerTest.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* 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 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 \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException
|
||||
*/
|
||||
public function testListenerThrowsWhenMasterRequestHasInconsistentClientIps()
|
||||
{
|
||||
$dispatcher = new EventDispatcher();
|
||||
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
||||
|
||||
$request = new Request();
|
||||
$request->setTrustedProxies(array('1.1.1.1'));
|
||||
$request->server->set('REMOTE_ADDR', '1.1.1.1');
|
||||
$request->headers->set('FORWARDED', '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);
|
||||
}
|
||||
}
|
@@ -3,7 +3,6 @@
|
||||
namespace Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\HttpKernel\Bundle;
|
||||
|
||||
/**
|
||||
* This command has a required parameter on the constructor and will be ignored by the default Bundle implementation.
|
||||
|
@@ -197,6 +197,19 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, $trustedHeaderName);
|
||||
}
|
||||
|
||||
public function testHeadersPossiblyResultingIn304AreNotAssignedToSubrequest()
|
||||
{
|
||||
$expectedSubRequest = Request::create('/');
|
||||
if (Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) {
|
||||
$expectedSubRequest->headers->set('x-forwarded-for', array('127.0.0.1'));
|
||||
$expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
|
||||
}
|
||||
|
||||
$strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest));
|
||||
$request = Request::create('/', 'GET', array(), array(), array(), array('HTTP_IF_MODIFIED_SINCE' => 'Fri, 01 Jan 2016 00:00:00 GMT', 'HTTP_IF_NONE_MATCH' => '*'));
|
||||
$strategy->render('/', $request);
|
||||
}
|
||||
}
|
||||
|
||||
class Bar
|
||||
|
@@ -181,6 +181,31 @@ class HttpCacheTest extends HttpCacheTestCase
|
||||
$this->assertEquals(304, $this->response->getStatusCode());
|
||||
}
|
||||
|
||||
public function testIncrementsMaxAgeWhenNoDateIsSpecifiedEventWhenUsingETag()
|
||||
{
|
||||
$this->setNextResponse(
|
||||
200,
|
||||
array(
|
||||
'ETag' => '1234',
|
||||
'Cache-Control' => 'public, s-maxage=60',
|
||||
)
|
||||
);
|
||||
|
||||
$this->request('GET', '/');
|
||||
$this->assertHttpKernelIsCalled();
|
||||
$this->assertEquals(200, $this->response->getStatusCode());
|
||||
$this->assertTraceContains('miss');
|
||||
$this->assertTraceContains('store');
|
||||
|
||||
sleep(2);
|
||||
|
||||
$this->request('GET', '/');
|
||||
$this->assertHttpKernelIsNotCalled();
|
||||
$this->assertEquals(200, $this->response->getStatusCode());
|
||||
$this->assertTraceContains('fresh');
|
||||
$this->assertEquals(2, $this->response->headers->get('Age'));
|
||||
}
|
||||
|
||||
public function testValidatesPrivateResponsesCachedOnTheClient()
|
||||
{
|
||||
$this->setNextResponse(200, array(), '', function ($request, $response) {
|
||||
|
@@ -50,6 +50,9 @@ class HttpCacheTestCase extends \PHPUnit_Framework_TestCase
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
if ($this->cache) {
|
||||
$this->cache->getStore()->cleanup();
|
||||
}
|
||||
$this->kernel = null;
|
||||
$this->cache = null;
|
||||
$this->caches = null;
|
||||
|
@@ -19,6 +19,10 @@ class StoreTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $request;
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* @var Store
|
||||
*/
|
||||
protected $store;
|
||||
|
||||
protected function setUp()
|
||||
|
@@ -260,6 +260,27 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
|
||||
$kernel->handle($request, HttpKernelInterface::MASTER_REQUEST);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\HttpKernel\Exception\BadRequestHttpException
|
||||
*/
|
||||
public function testInconsistentClientIpsOnMasterRequests()
|
||||
{
|
||||
$dispatcher = new EventDispatcher();
|
||||
$dispatcher->addListener(KernelEvents::REQUEST, function ($event) {
|
||||
$event->getRequest()->getClientIp();
|
||||
});
|
||||
|
||||
$kernel = new HttpKernel($dispatcher, $this->getResolver());
|
||||
|
||||
$request = new Request();
|
||||
$request->setTrustedProxies(array('1.1.1.1'));
|
||||
$request->server->set('REMOTE_ADDR', '1.1.1.1');
|
||||
$request->headers->set('FORWARDED', '2.2.2.2');
|
||||
$request->headers->set('X_FORWARDED_FOR', '3.3.3.3');
|
||||
|
||||
$kernel->handle($request, $kernel::MASTER_REQUEST, false);
|
||||
}
|
||||
|
||||
protected function getResolver($controller = null)
|
||||
{
|
||||
if (null === $controller) {
|
||||
|
Reference in New Issue
Block a user