mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-03 05:29:53 +09:00
update to laravel 5.7 and try getting autologin saved
This commit is contained in:
@@ -12,9 +12,9 @@
|
||||
namespace Symfony\Component\HttpKernel\Tests\HttpCache;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpKernel\HttpCache\Esi;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\HttpCache\Esi;
|
||||
|
||||
class EsiTest extends TestCase
|
||||
{
|
||||
@@ -231,10 +231,10 @@ class EsiTest extends TestCase
|
||||
->method('getRequest')
|
||||
->will($this->returnValue($request))
|
||||
;
|
||||
if (is_array($response)) {
|
||||
if (\is_array($response)) {
|
||||
$cache->expects($this->any())
|
||||
->method('handle')
|
||||
->will(call_user_func_array(array($this, 'onConsecutiveCalls'), $response))
|
||||
->will(\call_user_func_array(array($this, 'onConsecutiveCalls'), $response))
|
||||
;
|
||||
} else {
|
||||
$cache->expects($this->any())
|
||||
|
||||
@@ -11,9 +11,11 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Tests\HttpCache;
|
||||
|
||||
use Symfony\Component\HttpKernel\HttpCache\HttpCache;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\HttpCache\Esi;
|
||||
use Symfony\Component\HttpKernel\HttpCache\HttpCache;
|
||||
use Symfony\Component\HttpKernel\HttpCache\Store;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
|
||||
/**
|
||||
@@ -213,7 +215,7 @@ class HttpCacheTest extends HttpCacheTestCase
|
||||
if ($request->cookies->has('authenticated')) {
|
||||
$response->headers->set('Cache-Control', 'private, no-store');
|
||||
$response->setETag('"private tag"');
|
||||
if (in_array('"private tag"', $etags)) {
|
||||
if (\in_array('"private tag"', $etags)) {
|
||||
$response->setStatusCode(304);
|
||||
} else {
|
||||
$response->setStatusCode(200);
|
||||
@@ -223,7 +225,7 @@ class HttpCacheTest extends HttpCacheTestCase
|
||||
} else {
|
||||
$response->headers->set('Cache-Control', 'public');
|
||||
$response->setETag('"public tag"');
|
||||
if (in_array('"public tag"', $etags)) {
|
||||
if (\in_array('"public tag"', $etags)) {
|
||||
$response->setStatusCode(304);
|
||||
} else {
|
||||
$response->setStatusCode(200);
|
||||
@@ -564,7 +566,7 @@ class HttpCacheTest extends HttpCacheTestCase
|
||||
|
||||
public function testDegradationWhenCacheLocked()
|
||||
{
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('Skips on windows to avoid permissions issues.');
|
||||
}
|
||||
|
||||
@@ -992,7 +994,7 @@ class HttpCacheTest extends HttpCacheTestCase
|
||||
$this->assertHttpKernelIsNotCalled();
|
||||
$this->assertEquals(200, $this->response->getStatusCode());
|
||||
$this->assertEquals('', $this->response->getContent());
|
||||
$this->assertEquals(strlen('Hello World'), $this->response->headers->get('Content-Length'));
|
||||
$this->assertEquals(\strlen('Hello World'), $this->response->headers->get('Content-Length'));
|
||||
}
|
||||
|
||||
public function testSendsNoContentWhenFresh()
|
||||
@@ -1336,64 +1338,69 @@ class HttpCacheTest extends HttpCacheTestCase
|
||||
$this->setNextResponse();
|
||||
$this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1'));
|
||||
|
||||
$this->assertEquals('127.0.0.1', $this->kernel->getBackendRequest()->server->get('REMOTE_ADDR'));
|
||||
$this->kernel->assert(function ($backendRequest) {
|
||||
$this->assertSame('127.0.0.1', $backendRequest->server->get('REMOTE_ADDR'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTrustedProxyData
|
||||
*/
|
||||
public function testHttpCacheIsSetAsATrustedProxy(array $existing, array $expected)
|
||||
public function testHttpCacheIsSetAsATrustedProxy(array $existing)
|
||||
{
|
||||
Request::setTrustedProxies($existing, Request::HEADER_X_FORWARDED_ALL);
|
||||
|
||||
$this->setNextResponse();
|
||||
$this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1'));
|
||||
$this->assertSame($existing, Request::getTrustedProxies());
|
||||
|
||||
$this->assertEquals($expected, Request::getTrustedProxies());
|
||||
$existing = array_unique(array_merge($existing, array('127.0.0.1')));
|
||||
$this->kernel->assert(function ($backendRequest) use ($existing) {
|
||||
$this->assertSame($existing, Request::getTrustedProxies());
|
||||
$this->assertsame('10.0.0.1', $backendRequest->getClientIp());
|
||||
});
|
||||
|
||||
Request::setTrustedProxies(array(), -1);
|
||||
}
|
||||
|
||||
public function getTrustedProxyData()
|
||||
{
|
||||
return array(
|
||||
array(array(), array('127.0.0.1')),
|
||||
array(array('10.0.0.2'), array('10.0.0.2', '127.0.0.1')),
|
||||
array(array('10.0.0.2', '127.0.0.1'), array('10.0.0.2', '127.0.0.1')),
|
||||
array(array()),
|
||||
array(array('10.0.0.2')),
|
||||
array(array('10.0.0.2', '127.0.0.1')),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getXForwardedForData
|
||||
* @dataProvider getForwardedData
|
||||
*/
|
||||
public function testXForwarderForHeaderForForwardedRequests($xForwardedFor, $expected)
|
||||
public function testForwarderHeaderForForwardedRequests($forwarded, $expected)
|
||||
{
|
||||
$this->setNextResponse();
|
||||
$server = array('REMOTE_ADDR' => '10.0.0.1');
|
||||
if (false !== $xForwardedFor) {
|
||||
$server['HTTP_X_FORWARDED_FOR'] = $xForwardedFor;
|
||||
if (null !== $forwarded) {
|
||||
Request::setTrustedProxies($server, -1);
|
||||
$server['HTTP_FORWARDED'] = $forwarded;
|
||||
}
|
||||
$this->request('GET', '/', $server);
|
||||
|
||||
$this->assertEquals($expected, $this->kernel->getBackendRequest()->headers->get('X-Forwarded-For'));
|
||||
$this->kernel->assert(function ($backendRequest) use ($expected) {
|
||||
$this->assertSame($expected, $backendRequest->headers->get('Forwarded'));
|
||||
});
|
||||
|
||||
Request::setTrustedProxies(array(), -1);
|
||||
}
|
||||
|
||||
public function getXForwardedForData()
|
||||
public function getForwardedData()
|
||||
{
|
||||
return array(
|
||||
array(false, '10.0.0.1'),
|
||||
array('10.0.0.2', '10.0.0.2, 10.0.0.1'),
|
||||
array('10.0.0.2, 10.0.0.3', '10.0.0.2, 10.0.0.3, 10.0.0.1'),
|
||||
array(null, 'for="10.0.0.1";host="localhost";proto=http'),
|
||||
array('for=10.0.0.2', 'for="10.0.0.2";host="localhost";proto=http, for="10.0.0.1"'),
|
||||
array('for=10.0.0.2, for=10.0.0.3', 'for="10.0.0.2";host="localhost";proto=http, for="10.0.0.3", for="10.0.0.1"'),
|
||||
);
|
||||
}
|
||||
|
||||
public function testXForwarderForHeaderForPassRequests()
|
||||
{
|
||||
$this->setNextResponse();
|
||||
$server = array('REMOTE_ADDR' => '10.0.0.1');
|
||||
$this->request('POST', '/', $server);
|
||||
|
||||
$this->assertEquals('10.0.0.1', $this->kernel->getBackendRequest()->headers->get('X-Forwarded-For'));
|
||||
}
|
||||
|
||||
public function testEsiCacheRemoveValidationHeadersIfEmbeddedResponses()
|
||||
{
|
||||
$time = \DateTime::createFromFormat('U', time());
|
||||
@@ -1465,6 +1472,42 @@ class HttpCacheTest extends HttpCacheTestCase
|
||||
$this->assertHttpKernelIsNotCalled();
|
||||
$this->assertSame('get', $this->response->getContent());
|
||||
}
|
||||
|
||||
public function testUsesOriginalRequestForSurrogate()
|
||||
{
|
||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
|
||||
$store = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpCache\StoreInterface')->getMock();
|
||||
|
||||
$kernel
|
||||
->expects($this->exactly(2))
|
||||
->method('handle')
|
||||
->willReturnCallback(function (Request $request) {
|
||||
$this->assertSame('127.0.0.1', $request->server->get('REMOTE_ADDR'));
|
||||
|
||||
return new Response();
|
||||
});
|
||||
|
||||
$cache = new HttpCache($kernel,
|
||||
$store,
|
||||
new Esi()
|
||||
);
|
||||
|
||||
$request = Request::create('/');
|
||||
$request->server->set('REMOTE_ADDR', '10.0.0.1');
|
||||
|
||||
// Main request
|
||||
$cache->handle($request, HttpKernelInterface::MASTER_REQUEST);
|
||||
|
||||
// Main request was now modified by HttpCache
|
||||
// The surrogate will ask for the request using $this->cache->getRequest()
|
||||
// which MUST return the original request so the surrogate
|
||||
// can actually behave like a reverse proxy like e.g. Varnish would.
|
||||
$this->assertSame('10.0.0.1', $cache->getRequest()->getClientIp());
|
||||
$this->assertSame('10.0.0.1', $cache->getRequest()->server->get('REMOTE_ADDR'));
|
||||
|
||||
// Surrogate request
|
||||
$cache->handle($request, HttpKernelInterface::SUB_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
class TestKernel implements HttpKernelInterface
|
||||
|
||||
@@ -168,7 +168,7 @@ class HttpCacheTestCase extends TestCase
|
||||
|
||||
$fp = opendir($directory);
|
||||
while (false !== $file = readdir($fp)) {
|
||||
if (!in_array($file, array('.', '..'))) {
|
||||
if (!\in_array($file, array('.', '..'))) {
|
||||
if (is_link($directory.'/'.$file)) {
|
||||
unlink($directory.'/'.$file);
|
||||
} elseif (is_dir($directory.'/'.$file)) {
|
||||
|
||||
@@ -198,10 +198,10 @@ class SsiTest extends TestCase
|
||||
->method('getRequest')
|
||||
->will($this->returnValue($request))
|
||||
;
|
||||
if (is_array($response)) {
|
||||
if (\is_array($response)) {
|
||||
$cache->expects($this->any())
|
||||
->method('handle')
|
||||
->will(call_user_func_array(array($this, 'onConsecutiveCalls'), $response))
|
||||
->will(\call_user_func_array(array($this, 'onConsecutiveCalls'), $response))
|
||||
;
|
||||
} else {
|
||||
$cache->expects($this->any())
|
||||
|
||||
153
vendor/symfony/http-kernel/Tests/HttpCache/SubRequestHandlerTest.php
vendored
Normal file
153
vendor/symfony/http-kernel/Tests/HttpCache/SubRequestHandlerTest.php
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
<?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\HttpCache;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\HttpCache\SubRequestHandler;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
|
||||
class SubRequestHandlerTest extends TestCase
|
||||
{
|
||||
private static $globalState;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
self::$globalState = $this->getGlobalState();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
Request::setTrustedProxies(self::$globalState[0], self::$globalState[1]);
|
||||
}
|
||||
|
||||
public function testTrustedHeadersAreKept()
|
||||
{
|
||||
Request::setTrustedProxies(array('10.0.0.1'), -1);
|
||||
$globalState = $this->getGlobalState();
|
||||
|
||||
$request = Request::create('/');
|
||||
$request->server->set('REMOTE_ADDR', '10.0.0.1');
|
||||
$request->headers->set('X-Forwarded-For', '10.0.0.2');
|
||||
$request->headers->set('X-Forwarded-Host', 'Good');
|
||||
$request->headers->set('X-Forwarded-Port', '1234');
|
||||
$request->headers->set('X-Forwarded-Proto', 'https');
|
||||
|
||||
$kernel = new TestSubRequestHandlerKernel(function ($request, $type, $catch) {
|
||||
$this->assertSame('127.0.0.1', $request->server->get('REMOTE_ADDR'));
|
||||
$this->assertSame('10.0.0.2', $request->getClientIp());
|
||||
$this->assertSame('Good', $request->headers->get('X-Forwarded-Host'));
|
||||
$this->assertSame('1234', $request->headers->get('X-Forwarded-Port'));
|
||||
$this->assertSame('https', $request->headers->get('X-Forwarded-Proto'));
|
||||
});
|
||||
|
||||
SubRequestHandler::handle($kernel, $request, HttpKernelInterface::MASTER_REQUEST, true);
|
||||
|
||||
$this->assertSame($globalState, $this->getGlobalState());
|
||||
}
|
||||
|
||||
public function testUntrustedHeadersAreRemoved()
|
||||
{
|
||||
$request = Request::create('/');
|
||||
$request->server->set('REMOTE_ADDR', '10.0.0.1');
|
||||
$request->headers->set('X-Forwarded-For', '10.0.0.2');
|
||||
$request->headers->set('X-Forwarded-Host', 'Evil');
|
||||
$request->headers->set('X-Forwarded-Port', '1234');
|
||||
$request->headers->set('X-Forwarded-Proto', 'http');
|
||||
$request->headers->set('Forwarded', 'Evil2');
|
||||
|
||||
$kernel = new TestSubRequestHandlerKernel(function ($request, $type, $catch) {
|
||||
$this->assertSame('127.0.0.1', $request->server->get('REMOTE_ADDR'));
|
||||
$this->assertSame('10.0.0.1', $request->getClientIp());
|
||||
$this->assertFalse($request->headers->has('X-Forwarded-Host'));
|
||||
$this->assertFalse($request->headers->has('X-Forwarded-Port'));
|
||||
$this->assertFalse($request->headers->has('X-Forwarded-Proto'));
|
||||
$this->assertSame('for="10.0.0.1";host="localhost";proto=http', $request->headers->get('Forwarded'));
|
||||
});
|
||||
|
||||
SubRequestHandler::handle($kernel, $request, HttpKernelInterface::MASTER_REQUEST, true);
|
||||
|
||||
$this->assertSame(self::$globalState, $this->getGlobalState());
|
||||
}
|
||||
|
||||
public function testTrustedForwardedHeader()
|
||||
{
|
||||
Request::setTrustedProxies(array('10.0.0.1'), -1);
|
||||
$globalState = $this->getGlobalState();
|
||||
|
||||
$request = Request::create('/');
|
||||
$request->server->set('REMOTE_ADDR', '10.0.0.1');
|
||||
$request->headers->set('Forwarded', 'for="10.0.0.2";host="foo.bar:1234";proto=https');
|
||||
|
||||
$kernel = new TestSubRequestHandlerKernel(function ($request, $type, $catch) {
|
||||
$this->assertSame('127.0.0.1', $request->server->get('REMOTE_ADDR'));
|
||||
$this->assertSame('10.0.0.2', $request->getClientIp());
|
||||
$this->assertSame('foo.bar:1234', $request->getHttpHost());
|
||||
$this->assertSame('https', $request->getScheme());
|
||||
$this->assertSame(1234, $request->getPort());
|
||||
});
|
||||
|
||||
SubRequestHandler::handle($kernel, $request, HttpKernelInterface::MASTER_REQUEST, true);
|
||||
|
||||
$this->assertSame($globalState, $this->getGlobalState());
|
||||
}
|
||||
|
||||
public function testTrustedXForwardedForHeader()
|
||||
{
|
||||
Request::setTrustedProxies(array('10.0.0.1'), -1);
|
||||
$globalState = $this->getGlobalState();
|
||||
|
||||
$request = Request::create('/');
|
||||
$request->server->set('REMOTE_ADDR', '10.0.0.1');
|
||||
$request->headers->set('X-Forwarded-For', '10.0.0.2');
|
||||
$request->headers->set('X-Forwarded-Host', 'foo.bar');
|
||||
$request->headers->set('X-Forwarded-Proto', 'https');
|
||||
|
||||
$kernel = new TestSubRequestHandlerKernel(function ($request, $type, $catch) {
|
||||
$this->assertSame('127.0.0.1', $request->server->get('REMOTE_ADDR'));
|
||||
$this->assertSame('10.0.0.2', $request->getClientIp());
|
||||
$this->assertSame('foo.bar', $request->getHttpHost());
|
||||
$this->assertSame('https', $request->getScheme());
|
||||
});
|
||||
|
||||
SubRequestHandler::handle($kernel, $request, HttpKernelInterface::MASTER_REQUEST, true);
|
||||
|
||||
$this->assertSame($globalState, $this->getGlobalState());
|
||||
}
|
||||
|
||||
private function getGlobalState()
|
||||
{
|
||||
return array(
|
||||
Request::getTrustedProxies(),
|
||||
Request::getTrustedHeaderSet(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class TestSubRequestHandlerKernel implements HttpKernelInterface
|
||||
{
|
||||
private $assertCallback;
|
||||
|
||||
public function __construct(\Closure $assertCallback)
|
||||
{
|
||||
$this->assertCallback = $assertCallback;
|
||||
}
|
||||
|
||||
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
|
||||
{
|
||||
$assertCallback = $this->assertCallback;
|
||||
$assertCallback($request, $type, $catch);
|
||||
|
||||
return new Response();
|
||||
}
|
||||
}
|
||||
@@ -11,13 +11,13 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Tests\HttpCache;
|
||||
|
||||
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
|
||||
use Symfony\Component\HttpKernel\HttpKernel;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\HttpKernel\HttpKernel;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
|
||||
class TestHttpKernel extends HttpKernel implements ControllerResolverInterface, ArgumentResolverInterface
|
||||
{
|
||||
@@ -39,15 +39,25 @@ class TestHttpKernel extends HttpKernel implements ControllerResolverInterface,
|
||||
parent::__construct(new EventDispatcher(), $this, null, $this);
|
||||
}
|
||||
|
||||
public function getBackendRequest()
|
||||
public function assert(\Closure $callback)
|
||||
{
|
||||
return $this->backendRequest;
|
||||
$trustedConfig = array(Request::getTrustedProxies(), Request::getTrustedHeaderSet());
|
||||
|
||||
list($trustedProxies, $trustedHeaderSet, $backendRequest) = $this->backendRequest;
|
||||
Request::setTrustedProxies($trustedProxies, $trustedHeaderSet);
|
||||
|
||||
try {
|
||||
$callback($backendRequest);
|
||||
} finally {
|
||||
list($trustedProxies, $trustedHeaderSet) = $trustedConfig;
|
||||
Request::setTrustedProxies($trustedProxies, $trustedHeaderSet);
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = false)
|
||||
{
|
||||
$this->catch = $catch;
|
||||
$this->backendRequest = $request;
|
||||
$this->backendRequest = array(Request::getTrustedProxies(), Request::getTrustedHeaderSet(), $request);
|
||||
|
||||
return parent::handle($request, $type, $catch);
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Tests\HttpCache;
|
||||
|
||||
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
|
||||
use Symfony\Component\HttpKernel\HttpKernel;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\HttpKernel\HttpKernel;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
|
||||
class TestMultipleHttpKernel extends HttpKernel implements ControllerResolverInterface, ArgumentResolverInterface
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user