mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-08 00:03:12 +08:00
Refactored and fixed unit tests
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user