Working state but no uploads
This commit is contained in:
55
tests/Shared/RequestContextTest.php
Normal file
55
tests/Shared/RequestContextTest.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Shared;
|
||||
|
||||
use App\Shared\Http\RequestContext;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
#[\PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations]
|
||||
final class RequestContextTest extends TestCase
|
||||
{
|
||||
public function testIsHttpsReturnsTrueWhenNativeHttpsFlagIsEnabled(): void
|
||||
{
|
||||
self::assertTrue(RequestContext::isHttps([
|
||||
'HTTPS' => 'on',
|
||||
]));
|
||||
}
|
||||
|
||||
public function testIsHttpsReturnsTrueWhenTrustedProxyForwardsHttps(): void
|
||||
{
|
||||
self::assertTrue(RequestContext::isHttps([
|
||||
'REMOTE_ADDR' => '127.0.0.1',
|
||||
'HTTP_X_FORWARDED_PROTO' => 'https, http',
|
||||
], ['127.0.0.1']));
|
||||
}
|
||||
|
||||
public function testIsHttpsIgnoresForwardedProtoWhenProxyIsNotTrusted(): void
|
||||
{
|
||||
self::assertFalse(RequestContext::isHttps([
|
||||
'REMOTE_ADDR' => '10.0.0.5',
|
||||
'HTTP_X_FORWARDED_PROTO' => 'https',
|
||||
], ['127.0.0.1']));
|
||||
}
|
||||
|
||||
public function testTrustedProxiesFromEnvironmentTrimsValues(): void
|
||||
{
|
||||
self::assertSame(['127.0.0.1', '::1'], RequestContext::trustedProxiesFromEnvironment([
|
||||
'TRUSTED_PROXIES' => ' 127.0.0.1 , ::1 ',
|
||||
]));
|
||||
}
|
||||
|
||||
public function testTrustedProxiesFromEnvironmentFallsBackToProcessEnvWhenDotenvValueIsBlank(): void
|
||||
{
|
||||
putenv('TRUSTED_PROXIES=*');
|
||||
|
||||
try {
|
||||
self::assertSame(['*'], RequestContext::trustedProxiesFromEnvironment([
|
||||
'TRUSTED_PROXIES' => '',
|
||||
]));
|
||||
} finally {
|
||||
putenv('TRUSTED_PROXIES');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user