mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Do not use ServerRequestFactory::fromGlobals in tests
This commit is contained in:
@@ -10,7 +10,7 @@ use Shlinkio\Shlink\Rest\Authentication\Plugin\ApiKeyHeaderPlugin;
|
||||
use Shlinkio\Shlink\Rest\Exception\VerifyAuthenticationException;
|
||||
use Shlinkio\Shlink\Rest\Service\ApiKeyServiceInterface;
|
||||
use Zend\Diactoros\Response;
|
||||
use Zend\Diactoros\ServerRequestFactory;
|
||||
use Zend\Diactoros\ServerRequest;
|
||||
|
||||
class ApiKeyHeaderPluginTest extends TestCase
|
||||
{
|
||||
@@ -68,6 +68,6 @@ class ApiKeyHeaderPluginTest extends TestCase
|
||||
|
||||
private function createRequest(string $apiKey): ServerRequestInterface
|
||||
{
|
||||
return ServerRequestFactory::fromGlobals()->withHeader(ApiKeyHeaderPlugin::HEADER_NAME, $apiKey);
|
||||
return (new ServerRequest())->withHeader(ApiKeyHeaderPlugin::HEADER_NAME, $apiKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ use Shlinkio\Shlink\Rest\Authentication\JWTServiceInterface;
|
||||
use Shlinkio\Shlink\Rest\Authentication\Plugin\AuthorizationHeaderPlugin;
|
||||
use Shlinkio\Shlink\Rest\Exception\VerifyAuthenticationException;
|
||||
use Zend\Diactoros\Response;
|
||||
use Zend\Diactoros\ServerRequestFactory;
|
||||
use Zend\Diactoros\ServerRequest;
|
||||
use function sprintf;
|
||||
|
||||
class AuthorizationHeaderPluginTest extends TestCase
|
||||
@@ -31,7 +31,7 @@ class AuthorizationHeaderPluginTest extends TestCase
|
||||
public function verifyAnAuthorizationWithoutBearerTypeThrowsException()
|
||||
{
|
||||
$authToken = 'ABC-abc';
|
||||
$request = ServerRequestFactory::fromGlobals()->withHeader(
|
||||
$request = (new ServerRequest())->withHeader(
|
||||
AuthorizationHeaderPlugin::HEADER_NAME,
|
||||
$authToken
|
||||
);
|
||||
@@ -51,7 +51,7 @@ class AuthorizationHeaderPluginTest extends TestCase
|
||||
public function verifyAnAuthorizationWithWrongTypeThrowsException()
|
||||
{
|
||||
$authToken = 'Basic ABC-abc';
|
||||
$request = ServerRequestFactory::fromGlobals()->withHeader(
|
||||
$request = (new ServerRequest())->withHeader(
|
||||
AuthorizationHeaderPlugin::HEADER_NAME,
|
||||
$authToken
|
||||
);
|
||||
@@ -70,7 +70,7 @@ class AuthorizationHeaderPluginTest extends TestCase
|
||||
public function verifyAnExpiredTokenThrowsException()
|
||||
{
|
||||
$authToken = 'Bearer ABC-abc';
|
||||
$request = ServerRequestFactory::fromGlobals()->withHeader(
|
||||
$request = (new ServerRequest())->withHeader(
|
||||
AuthorizationHeaderPlugin::HEADER_NAME,
|
||||
$authToken
|
||||
);
|
||||
@@ -94,7 +94,7 @@ class AuthorizationHeaderPluginTest extends TestCase
|
||||
public function verifyValidTokenDoesNotThrowException()
|
||||
{
|
||||
$authToken = 'Bearer ABC-abc';
|
||||
$request = ServerRequestFactory::fromGlobals()->withHeader(
|
||||
$request = (new ServerRequest())->withHeader(
|
||||
AuthorizationHeaderPlugin::HEADER_NAME,
|
||||
$authToken
|
||||
);
|
||||
@@ -111,7 +111,7 @@ class AuthorizationHeaderPluginTest extends TestCase
|
||||
public function updateReturnsAnUpdatedResponseWithNewJwt()
|
||||
{
|
||||
$authToken = 'Bearer ABC-abc';
|
||||
$request = ServerRequestFactory::fromGlobals()->withHeader(
|
||||
$request = (new ServerRequest())->withHeader(
|
||||
AuthorizationHeaderPlugin::HEADER_NAME,
|
||||
$authToken
|
||||
);
|
||||
|
||||
@@ -11,7 +11,7 @@ use Shlinkio\Shlink\Rest\Authentication\Plugin\AuthenticationPluginInterface;
|
||||
use Shlinkio\Shlink\Rest\Authentication\Plugin\AuthorizationHeaderPlugin;
|
||||
use Shlinkio\Shlink\Rest\Authentication\RequestToHttpAuthPlugin;
|
||||
use Shlinkio\Shlink\Rest\Exception\NoAuthenticationException;
|
||||
use Zend\Diactoros\ServerRequestFactory;
|
||||
use Zend\Diactoros\ServerRequest;
|
||||
use function implode;
|
||||
use function sprintf;
|
||||
|
||||
@@ -33,7 +33,7 @@ class RequestToAuthPluginTest extends TestCase
|
||||
*/
|
||||
public function exceptionIsFoundWhenNoneOfTheSupportedMethodsIsFound()
|
||||
{
|
||||
$request = ServerRequestFactory::fromGlobals();
|
||||
$request = new ServerRequest();
|
||||
|
||||
$this->expectException(NoAuthenticationException::class);
|
||||
$this->expectExceptionMessage(sprintf(
|
||||
@@ -50,7 +50,7 @@ class RequestToAuthPluginTest extends TestCase
|
||||
*/
|
||||
public function properPluginIsFetchedWhenAnyAuthTypeIsFound(array $headers, string $expectedHeader)
|
||||
{
|
||||
$request = ServerRequestFactory::fromGlobals();
|
||||
$request = new ServerRequest();
|
||||
foreach ($headers as $header => $value) {
|
||||
$request = $request->withHeader($header, $value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user