mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-12 01:54:41 +08:00
Refactored and fixed unit tests
This commit is contained in:
@@ -10,7 +10,6 @@ use Psr\Log\LoggerInterface;
|
||||
use Shlinkio\Shlink\Rest\Authentication\JWTServiceInterface;
|
||||
use Shlinkio\Shlink\Rest\Service\ApiKeyService;
|
||||
use Shlinkio\Shlink\Rest\Service\ApiKeyServiceInterface;
|
||||
use Shlinkio\Shlink\Rest\Util\RestUtils;
|
||||
use Zend\Diactoros\Response\JsonResponse;
|
||||
|
||||
/** @deprecated */
|
||||
|
||||
@@ -9,7 +9,6 @@ use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Shlinkio\Shlink\Core\Service\ShortUrlServiceInterface;
|
||||
use Shlinkio\Shlink\Rest\Action\AbstractRestAction;
|
||||
use Shlinkio\Shlink\Rest\Util\RestUtils;
|
||||
use Zend\Diactoros\Response\JsonResponse;
|
||||
|
||||
class EditShortUrlTagsAction extends AbstractRestAction
|
||||
|
||||
@@ -16,7 +16,7 @@ class MissingAuthenticationException extends RuntimeException implements Problem
|
||||
use CommonProblemDetailsExceptionTrait;
|
||||
|
||||
private const TITLE = 'Invalid authorization';
|
||||
public const TYPE = 'INVALID_AUTHORIZATION';
|
||||
private const TYPE = 'INVALID_AUTHORIZATION';
|
||||
|
||||
public static function fromExpectedTypes(array $expectedTypes): self
|
||||
{
|
||||
|
||||
@@ -14,17 +14,10 @@ class VerifyAuthenticationException extends RuntimeException implements ProblemD
|
||||
{
|
||||
use CommonProblemDetailsExceptionTrait;
|
||||
|
||||
/** @var string */
|
||||
private $errorCode;
|
||||
/** @var string */
|
||||
private $publicMessage;
|
||||
|
||||
public static function forInvalidApiKey(): self
|
||||
{
|
||||
$e = new self('Provided API key does not exist or is invalid.');
|
||||
|
||||
$e->publicMessage = $e->getMessage();
|
||||
$e->errorCode = 'INVALID_API_KEY';
|
||||
$e->detail = $e->getMessage();
|
||||
$e->title = 'Invalid API key';
|
||||
$e->type = 'INVALID_API_KEY';
|
||||
@@ -41,8 +34,6 @@ class VerifyAuthenticationException extends RuntimeException implements ProblemD
|
||||
. 'token on every new request on the Authorization header'
|
||||
);
|
||||
|
||||
$e->publicMessage = $e->getMessage();
|
||||
$e->errorCode = 'INVALID_AUTH_TOKEN';
|
||||
$e->detail = $e->getMessage();
|
||||
$e->title = 'Invalid auth token';
|
||||
$e->type = 'INVALID_AUTH_TOKEN';
|
||||
@@ -56,8 +47,6 @@ class VerifyAuthenticationException extends RuntimeException implements ProblemD
|
||||
{
|
||||
$e = new self('You need to provide the Bearer type in the Authorization header.');
|
||||
|
||||
$e->publicMessage = $e->getMessage();
|
||||
$e->errorCode = 'INVALID_AUTHORIZATION';
|
||||
$e->detail = $e->getMessage();
|
||||
$e->title = 'Invalid authorization';
|
||||
$e->type = 'INVALID_AUTHORIZATION';
|
||||
@@ -71,8 +60,6 @@ class VerifyAuthenticationException extends RuntimeException implements ProblemD
|
||||
{
|
||||
$e = new self(sprintf('Provided authorization type %s is not supported. Use Bearer instead.', $providedType));
|
||||
|
||||
$e->publicMessage = $e->getMessage();
|
||||
$e->errorCode = 'INVALID_AUTHORIZATION';
|
||||
$e->detail = $e->getMessage();
|
||||
$e->title = 'Invalid authorization';
|
||||
$e->type = 'INVALID_AUTHORIZATION';
|
||||
@@ -80,14 +67,4 @@ class VerifyAuthenticationException extends RuntimeException implements ProblemD
|
||||
|
||||
return $e;
|
||||
}
|
||||
|
||||
public function getErrorCode(): string
|
||||
{
|
||||
return $this->errorCode;
|
||||
}
|
||||
|
||||
public function getPublicMessage(): string
|
||||
{
|
||||
return $this->publicMessage;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Rest\Util;
|
||||
|
||||
use Shlinkio\Shlink\Rest\Exception as Rest;
|
||||
|
||||
/** @deprecated */
|
||||
class RestUtils
|
||||
{
|
||||
public const INVALID_AUTHORIZATION_ERROR = Rest\MissingAuthenticationException::TYPE;
|
||||
}
|
||||
Reference in New Issue
Block a user