Simplified IpAddressMiddlewareFactory and decoupled from Core module

This commit is contained in:
Alejandro Celaya
2019-08-11 10:22:19 +02:00
parent 5fa4fa0225
commit 0323e0d17d
8 changed files with 17 additions and 41 deletions

View File

@@ -6,7 +6,6 @@ namespace ShlinkioTest\Shlink\Common\Middleware;
use PHPUnit\Framework\TestCase;
use ReflectionObject;
use Shlinkio\Shlink\Common\Middleware\IpAddressMiddlewareFactory;
use Shlinkio\Shlink\Core\Model\Visitor;
use Zend\ServiceManager\ServiceManager;
class IpAddressMiddlewareFactoryTest extends TestCase
@@ -26,7 +25,7 @@ class IpAddressMiddlewareFactoryTest extends TestCase
{
$instance = ($this->factory)(new ServiceManager(['services' => [
'config' => $config,
]]), '');
]]));
$ref = new ReflectionObject($instance);
$checkProxyHeaders = $ref->getProperty('checkProxyHeaders');
@@ -40,7 +39,7 @@ class IpAddressMiddlewareFactoryTest extends TestCase
$this->assertTrue($checkProxyHeaders->getValue($instance));
$this->assertEquals([], $trustedProxies->getValue($instance));
$this->assertEquals(Visitor::REMOTE_ADDRESS_ATTR, $attributeName->getValue($instance));
$this->assertEquals(IpAddressMiddlewareFactory::REQUEST_ATTR, $attributeName->getValue($instance));
$this->assertEquals($expectedHeadersToInspect, $headersToInspect->getValue($instance));
}