From 608a45408a7999b3a1e16d61ea4a6c9105de2321 Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Sun, 6 Nov 2022 20:44:30 +0100 Subject: [PATCH] Release 1.29 (#3622) --- src/Constants.php | 4 ++-- src/Controller/InvoiceController.php | 8 ++++++-- tests/Security/ApiAuthenticatorTest.php | 15 +++++++++++---- tests/Security/TokenAuthenticatorTest.php | 3 +++ .../{about.zh-Hant.xlf => about.zh_Hant.xlf} | 0 ...{messages.zh-Hant.xlf => messages.zh_Hant.xlf} | 0 6 files changed, 22 insertions(+), 8 deletions(-) rename translations/{about.zh-Hant.xlf => about.zh_Hant.xlf} (100%) rename translations/{messages.zh-Hant.xlf => messages.zh_Hant.xlf} (100%) diff --git a/src/Constants.php b/src/Constants.php index dd0e4079..64e33451 100644 --- a/src/Constants.php +++ b/src/Constants.php @@ -17,11 +17,11 @@ class Constants /** * The current release version */ - public const VERSION = '1.28.1'; + public const VERSION = '1.29.0'; /** * The current release: major * 10000 + minor * 100 + patch */ - public const VERSION_ID = 12801; + public const VERSION_ID = 12900; /** * The current release status, either "stable" or "dev" */ diff --git a/src/Controller/InvoiceController.php b/src/Controller/InvoiceController.php index 5a91bd03..a8b8ad2a 100644 --- a/src/Controller/InvoiceController.php +++ b/src/Controller/InvoiceController.php @@ -525,13 +525,17 @@ final class InvoiceController extends AbstractController foreach ($documentRepository->findBuiltIn() as $doc) { if ($doc->getId() === $id) { - throw new \Exception('Document is built-in and cannot be deleted'); + $this->flashError('Document is built-in and cannot be deleted.'); + + return $this->redirectToRoute('admin_invoice_document_upload'); } } foreach ($this->templateRepository->findAll() as $template) { if ($template->getRenderer() === $id) { - throw new \Exception('Document is used and cannot be deleted'); + $this->flashError('Document is used and cannot be deleted.'); + + return $this->redirectToRoute('admin_invoice_document_upload'); } } diff --git a/tests/Security/ApiAuthenticatorTest.php b/tests/Security/ApiAuthenticatorTest.php index 1564af12..ad8a6e5e 100644 --- a/tests/Security/ApiAuthenticatorTest.php +++ b/tests/Security/ApiAuthenticatorTest.php @@ -9,6 +9,7 @@ namespace App\Tests\Security; +use App\Security\ApiAuthenticator; use App\Security\TokenAuthenticator; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; @@ -22,7 +23,8 @@ class ApiAuthenticatorTest extends TestCase public function testRememberMe() { $factory = $this->createMock(EncoderFactoryInterface::class); - $sut = new TokenAuthenticator($factory); + $token = new TokenAuthenticator($factory); + $sut = new ApiAuthenticator($token); self::assertFalse($sut->supportsRememberMe()); } @@ -30,25 +32,30 @@ class ApiAuthenticatorTest extends TestCase public function testSupports() { $factory = $this->createMock(EncoderFactoryInterface::class); - $sut = new TokenAuthenticator($factory); + $token = new TokenAuthenticator($factory); + $sut = new ApiAuthenticator($token); $request = new Request([], [], [], [], [], ['REQUEST_URI' => 'dfghj/api/doc/dfghj']); self::assertFalse($sut->supports($request)); $request = new Request([], [], [], [], [], ['REQUEST_URI' => '/api/fooo']); - self::assertFalse($sut->supports($request)); + self::assertTrue($sut->supports($request)); $request = new Request([], [], [], [], [], ['REQUEST_URI' => '/api/fooo', 'HTTP_X-AUTH-SESSION' => true]); self::assertFalse($sut->supports($request)); $request = new Request([], [], [], [], [], ['REQUEST_URI' => '/api/fooo', 'HTTP_X-AUTH-USER' => 'foo', 'HTTP_X-AUTH-TOKEN' => 'bar']); self::assertTrue($sut->supports($request)); + + $request = new Request([], [], [], [], [], ['REQUEST_URI' => '/api/fooo', 'HTTP_X-AUTH-USER' => 'foo', 'HTTP_X-AUTH-TOKEN' => 'bar', 'HTTP_X-AUTH-SESSION' => true]); + self::assertFalse($sut->supports($request)); } public function testGetCredentials() { $factory = $this->createMock(EncoderFactoryInterface::class); - $sut = new TokenAuthenticator($factory); + $token = new TokenAuthenticator($factory); + $sut = new ApiAuthenticator($token); $request = new Request([], [], [], [], [], ['REQUEST_URI' => '/api/fooo', 'HTTP_X-AUTH-SESSION' => true]); self::assertEquals(['user' => null, 'token' => null], $sut->getCredentials($request)); diff --git a/tests/Security/TokenAuthenticatorTest.php b/tests/Security/TokenAuthenticatorTest.php index 43829094..986d86c8 100644 --- a/tests/Security/TokenAuthenticatorTest.php +++ b/tests/Security/TokenAuthenticatorTest.php @@ -43,6 +43,9 @@ class TokenAuthenticatorTest extends TestCase $request = new Request([], [], [], [], [], ['REQUEST_URI' => '/api/fooo', 'HTTP_X-AUTH-USER' => 'foo', 'HTTP_X-AUTH-TOKEN' => 'bar']); self::assertTrue($sut->supports($request)); + + $request = new Request([], [], [], [], [], ['REQUEST_URI' => '/api/fooo', 'HTTP_X-AUTH-USER' => 'foo', 'HTTP_X-AUTH-TOKEN' => 'bar', 'HTTP_X-AUTH-SESSION' => true]); + self::assertTrue($sut->supports($request)); } public function testGetCredentials() diff --git a/translations/about.zh-Hant.xlf b/translations/about.zh_Hant.xlf similarity index 100% rename from translations/about.zh-Hant.xlf rename to translations/about.zh_Hant.xlf diff --git a/translations/messages.zh-Hant.xlf b/translations/messages.zh_Hant.xlf similarity index 100% rename from translations/messages.zh-Hant.xlf rename to translations/messages.zh_Hant.xlf