diff --git a/lib/Handler/SignEngine/JSignPdf/HashAlgorithmResolver.php b/lib/Handler/SignEngine/JSignPdf/HashAlgorithmResolver.php new file mode 100644 index 0000000000..f6c60bdfa6 --- /dev/null +++ b/lib/Handler/SignEngine/JSignPdf/HashAlgorithmResolver.php @@ -0,0 +1,86 @@ +getConfiguredAlgorithm(); + /** + * Need to respect the follow code: + * https://github.com/intoolswetrust/jsignpdf/blob/JSignPdf_2_2_2/jsignpdf/src/main/java/net/sf/jsignpdf/types/HashAlgorithm.java#L46-L47 + */ + if ($pdfVersion === null) { + return $this->validate($configuredAlgorithm); + } + + return $this->forPdfVersion($pdfVersion, $configuredAlgorithm); + } + + /** + * PDFs older than 1.6 have to be upgraded before JSignPdf accepts SHA-256. + */ + public function requiresPdfVersionUpgradeForSha256(float $pdfVersion): bool { + if ($pdfVersion >= self::MIN_PDF_VERSION_SHA256) { + return false; + } + + return $this->getConfiguredAlgorithm() === self::DEFAULT_ALGORITHM; + } + + private function forPdfVersion(float $pdfVersion, string $configuredAlgorithm): string { + // Legacy compatibility: JSignPdf still requires SHA1 for very old PDFs (< 1.6). + // The policy still exposes SHA1 for supported legacy workflows, and the runtime + // must continue enforcing this fallback for ancient PDFs that JSignPdf cannot sign otherwise. + if ($pdfVersion < self::MIN_PDF_VERSION_SHA256) { + return 'SHA1'; + } + if ($pdfVersion < self::MIN_PDF_VERSION_SHA1_REJECT) { + return self::DEFAULT_ALGORITHM; + } + if ($configuredAlgorithm === 'SHA1') { + return self::DEFAULT_ALGORITHM; + } + + return $this->validate($configuredAlgorithm); + } + + private function validate(string $algorithm): string { + return in_array($algorithm, self::SUPPORTED_ALGORITHMS, true) ? $algorithm : self::DEFAULT_ALGORITHM; + } + + private function getConfiguredAlgorithm(): string { + return $this->appConfig->getValueString(Application::APP_ID, 'signature_hash_algorithm', self::DEFAULT_ALGORITHM); + } +} diff --git a/lib/Handler/SignEngine/JSignPdfHandler.php b/lib/Handler/SignEngine/JSignPdf/JSignPdfHandler.php similarity index 92% rename from lib/Handler/SignEngine/JSignPdfHandler.php rename to lib/Handler/SignEngine/JSignPdf/JSignPdfHandler.php index 37e027cc7d..41479ca293 100644 --- a/lib/Handler/SignEngine/JSignPdfHandler.php +++ b/lib/Handler/SignEngine/JSignPdf/JSignPdfHandler.php @@ -6,13 +6,14 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace OCA\Libresign\Handler\SignEngine; +namespace OCA\Libresign\Handler\SignEngine\JSignPdf; use Imagick; use ImagickPixel; use OCA\Libresign\AppInfo\Application; use OCA\Libresign\Exception\LibresignException; use OCA\Libresign\Handler\CertificateEngine\CertificateEngineFactory; +use OCA\Libresign\Handler\SignEngine\Pkcs12Handler; use OCA\Libresign\Helper\JavaHelper; use OCA\Libresign\Service\DocMdp\ConfigService as DocMdpConfigService; use OCA\Libresign\Service\SignatureBackgroundService; @@ -28,9 +29,7 @@ class JSignPdfHandler extends Pkcs12Handler { private const MIN_PDF_VERSION = 1.2; private const TARGET_OLD_PDF_VERSION = '1.3'; - private const MIN_PDF_VERSION_SHA256 = 1.6; private const TARGET_PDF_VERSION_SHA256 = '1.6'; - private const MIN_PDF_VERSION_SHA1_REJECT = 1.7; private const SIGNATURE_DEFAULT_FONT_SIZE = 10.0; private const PAGE_FIRST = 1; private const SCALE_FACTOR_MIN = 5; @@ -50,6 +49,7 @@ public function __construct( protected CertificateEngineFactory $certificateEngineFactory, protected JavaHelper $javaHelper, private DocMdpConfigService $docMdpConfigService, + private HashAlgorithmResolver $hashAlgorithmResolver, ) { } @@ -146,21 +146,6 @@ private function createEmptyFile(string $path): void { fclose($file); } - private function getHashAlgorithm(string $pdfContent): string { - $configuredAlgorithm = $this->appConfig->getValueString(Application::APP_ID, 'signature_hash_algorithm', 'SHA256'); - /** - * Need to respect the follow code: - * https://github.com/intoolswetrust/jsignpdf/blob/JSignPdf_2_2_2/jsignpdf/src/main/java/net/sf/jsignpdf/types/HashAlgorithm.java#L46-L47 - */ - $pdfVersion = $this->extractPdfVersion($pdfContent); - - if ($pdfVersion === null) { - return $this->validateHashAlgorithm($configuredAlgorithm); - } - - return $this->getHashAlgorithmForPdfVersion($pdfVersion, $configuredAlgorithm); - } - private function extractPdfVersion(string $content): ?float { if (!preg_match('/^%PDF-(?\d+(\.\d+)?)/', $content, $match)) { return null; @@ -168,24 +153,6 @@ private function extractPdfVersion(string $content): ?float { return (float)$match['version']; } - private function getHashAlgorithmForPdfVersion(float $pdfVersion, string $configuredAlgorithm): string { - if ($pdfVersion < 1.6) { - return 'SHA1'; - } - if ($pdfVersion < self::MIN_PDF_VERSION_SHA1_REJECT) { - return 'SHA256'; - } - if ($pdfVersion >= self::MIN_PDF_VERSION_SHA1_REJECT && $configuredAlgorithm === 'SHA1') { - return 'SHA256'; - } - return $this->validateHashAlgorithm($configuredAlgorithm); - } - - private function validateHashAlgorithm(string $algorithm): string { - $supportedAlgorithms = ['SHA1', 'SHA256', 'SHA384', 'SHA512', 'RIPEMD160']; - return in_array($algorithm, $supportedAlgorithms) ? $algorithm : 'SHA256'; - } - /** * Normalizes very old PDFs (1.0/1.1) to 1.3. * Rationale: JSignPDF enum PdfVersion only defines 1.2+; for 1.0/1.1, @@ -205,7 +172,7 @@ private function normalizePdfVersion(string $content): string { // Convert PDFs < 1.6 to 1.6 if using SHA-256 (the default hash algorithm) // This prevents "The chosen hash algorithm (SHA-256) requires a newer PDF version" error - if ($this->requiresPdfVersionUpgradeForSha256($version)) { + if ($this->hashAlgorithmResolver->requiresPdfVersionUpgradeForSha256($version)) { return $this->replacePdfVersion($content, self::TARGET_PDF_VERSION_SHA256); } @@ -216,14 +183,6 @@ private function isVeryOldPdfVersion(float $version): bool { return $version > 0 && $version < self::MIN_PDF_VERSION; } - private function requiresPdfVersionUpgradeForSha256(float $version): bool { - if ($version >= self::MIN_PDF_VERSION_SHA256) { - return false; - } - $hashAlgorithm = $this->appConfig->getValueString(Application::APP_ID, 'signature_hash_algorithm', 'SHA256'); - return $hashAlgorithm === 'SHA256'; - } - private function replacePdfVersion(string $content, string $newVersion): string { return (string)preg_replace('/^%PDF-\d+(\.\d+)?/', '%PDF-' . $newVersion, $content, 1); } @@ -248,7 +207,7 @@ public function sign(): File { #[\Override] public function getSignedContent(): string { $normalizedPdf = $this->normalizePdfVersion($this->getInputFile()->getContent()); - $hashAlgorithm = $this->getHashAlgorithm($normalizedPdf); + $hashAlgorithm = $this->hashAlgorithmResolver->forSignature($this->extractPdfVersion($normalizedPdf)); $param = $this->getJSignParam(); $param->setCertificate($this->getCertificate()) ->setPdf($normalizedPdf) diff --git a/lib/Handler/SignEngine/Pkcs12Handler.php b/lib/Handler/SignEngine/Pkcs12Handler.php index 3b00dddc7c..46d1a8396d 100644 --- a/lib/Handler/SignEngine/Pkcs12Handler.php +++ b/lib/Handler/SignEngine/Pkcs12Handler.php @@ -14,6 +14,7 @@ use OCA\Libresign\Handler\CertificateEngine\OrderCertificatesTrait; use OCA\Libresign\Handler\DocMdpHandler; use OCA\Libresign\Handler\FooterHandler; +use OCA\Libresign\Handler\SignEngine\JSignPdf\JSignPdfHandler; use OCA\Libresign\Service\CaIdentifierService; use OCA\Libresign\Service\Crl\CrlService; use OCA\Libresign\Service\FolderService; @@ -30,6 +31,11 @@ class Pkcs12Handler extends SignEngineHandler { use OrderCertificatesTrait; protected string $certificate = ''; + /** @var array> */ + private const ENGINE_HANDLERS = [ + 'jSignPdfHandler' => JSignPdfHandler::class, + 'phpNativeHandler' => PhpNativeHandler::class, + ]; private ?JSignPdfHandler $jSignPdfHandler = null; private ?PhpNativeHandler $phpNativeHandler = null; private string $rootCertificatePem = ''; @@ -358,11 +364,13 @@ private function enrichLeafWithNativeData( private function getHandler(): SignEngineHandler { $sign_engine = $this->appConfig->getValueString(Application::APP_ID, 'signature_engine', 'JSignPdf'); $property = lcfirst($sign_engine) . 'Handler'; - if (!property_exists($this, $property)) { + // Resolved through a class map instead of a name built at runtime, so + // moving a handler to another namespace cannot break this silently. + if (!isset(self::ENGINE_HANDLERS[$property])) { // TRANSLATORS API/config error when LibreSign's signature_engine setting names a backend that is not available (for example a mistyped JSignPdf/native engine). throw new LibresignException($this->l10n->t('Invalid Sign engine.'), 400); } - $classHandler = 'OCA\\Libresign\\Handler\\SignEngine\\' . ucfirst($property); + $classHandler = self::ENGINE_HANDLERS[$property]; if (!$this->$property instanceof $classHandler) { $this->$property = \OCP\Server::get($classHandler); } diff --git a/lib/SetupCheck/JSignPdfSetupCheck.php b/lib/SetupCheck/JSignPdfSetupCheck.php index baeef16287..5037e63a06 100644 --- a/lib/SetupCheck/JSignPdfSetupCheck.php +++ b/lib/SetupCheck/JSignPdfSetupCheck.php @@ -9,7 +9,7 @@ namespace OCA\Libresign\SetupCheck; use OCA\Libresign\AppInfo\Application; -use OCA\Libresign\Handler\SignEngine\JSignPdfHandler; +use OCA\Libresign\Handler\SignEngine\JSignPdf\JSignPdfHandler; use OCA\Libresign\Helper\JavaHelper; use OCA\Libresign\Service\Install\InstallService; use OCA\Libresign\Service\Install\SignSetupService; diff --git a/tests/php/Unit/Handler/SignEngine/JSignPdf/HashAlgorithmResolverTest.php b/tests/php/Unit/Handler/SignEngine/JSignPdf/HashAlgorithmResolverTest.php new file mode 100644 index 0000000000..1dbe7683bd --- /dev/null +++ b/tests/php/Unit/Handler/SignEngine/JSignPdf/HashAlgorithmResolverTest.php @@ -0,0 +1,83 @@ +appConfig = $this->createMock(IAppConfig::class); + } + + private function getInstance(string $configuredAlgorithm): HashAlgorithmResolver { + $this->appConfig + ->method('getValueString') + ->with(Application::APP_ID, 'signature_hash_algorithm', 'SHA256') + ->willReturn($configuredAlgorithm); + + return new HashAlgorithmResolver($this->appConfig); + } + + #[DataProvider('providerSignatureHashAlgorithm')] + public function testForSignature(string $configuredAlgorithm, ?float $pdfVersion, string $expected): void { + $resolver = $this->getInstance($configuredAlgorithm); + + $this->assertSame($expected, $resolver->forSignature($pdfVersion)); + } + + public static function providerSignatureHashAlgorithm(): array { + return [ + // Unknown PDF version: only the configured algorithm decides. + 'unknown version keeps a supported algorithm' => ['SHA384', null, 'SHA384'], + 'unknown version keeps RIPEMD160' => ['RIPEMD160', null, 'RIPEMD160'], + 'unknown version falls back on an empty algorithm' => ['', null, 'SHA256'], + 'unknown version falls back on an unsupported algorithm' => ['XYZ', null, 'SHA256'], + // JSignPdf only accepts SHA1 in PDFs older than 1.6. + 'PDF 1.0 is signed with SHA1' => ['SHA256', 1.0, 'SHA1'], + 'PDF 1.5 is signed with SHA1' => ['SHA512', 1.5, 'SHA1'], + // Between 1.6 and 1.7 JSignPdf only accepts SHA256. + 'PDF 1.6 is signed with SHA256' => ['SHA384', 1.6, 'SHA256'], + 'PDF 1.6 ignores an unsupported algorithm' => ['XYZ', 1.6, 'SHA256'], + // From 1.7 on the configured algorithm is used, except SHA1. + 'PDF 1.7 keeps the configured SHA384' => ['SHA384', 1.7, 'SHA384'], + 'PDF 1.7 keeps the configured SHA512' => ['SHA512', 1.7, 'SHA512'], + 'PDF 1.7 keeps the configured RIPEMD160' => ['RIPEMD160', 1.7, 'RIPEMD160'], + 'PDF 1.7 replaces SHA1 with SHA256' => ['SHA1', 1.7, 'SHA256'], + 'PDF 2.0 replaces SHA1 with SHA256' => ['SHA1', 2.0, 'SHA256'], + 'PDF 2.0 falls back on an unsupported algorithm' => ['XYZ', 2.0, 'SHA256'], + 'PDF 2.0 keeps the configured SHA512' => ['SHA512', 2.0, 'SHA512'], + ]; + } + + #[DataProvider('providerPdfVersionUpgrade')] + public function testRequiresPdfVersionUpgradeForSha256(string $configuredAlgorithm, float $pdfVersion, bool $expected): void { + $resolver = $this->getInstance($configuredAlgorithm); + + $this->assertSame($expected, $resolver->requiresPdfVersionUpgradeForSha256($pdfVersion)); + } + + public static function providerPdfVersionUpgrade(): array { + return [ + 'SHA256 in a PDF 1.2 needs the upgrade' => ['SHA256', 1.2, true], + 'SHA256 in a PDF 1.5 needs the upgrade' => ['SHA256', 1.5, true], + 'SHA256 in a PDF 1.6 does not need the upgrade' => ['SHA256', 1.6, false], + 'SHA256 in a PDF 1.7 does not need the upgrade' => ['SHA256', 1.7, false], + 'SHA1 in a PDF 1.5 does not need the upgrade' => ['SHA1', 1.5, false], + 'SHA512 in a PDF 1.5 does not need the upgrade' => ['SHA512', 1.5, false], + ]; + } +} diff --git a/tests/php/Unit/Handler/SignEngine/JSignPdfHandlerTest.php b/tests/php/Unit/Handler/SignEngine/JSignPdf/JSignPdfHandlerTest.php similarity index 94% rename from tests/php/Unit/Handler/SignEngine/JSignPdfHandlerTest.php rename to tests/php/Unit/Handler/SignEngine/JSignPdf/JSignPdfHandlerTest.php index 5a0d4fa00d..f6f1643b30 100644 --- a/tests/php/Unit/Handler/SignEngine/JSignPdfHandlerTest.php +++ b/tests/php/Unit/Handler/SignEngine/JSignPdf/JSignPdfHandlerTest.php @@ -6,7 +6,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace OCA\Libresign\Tests\Unit\Handler\SignEngine; +namespace OCA\Libresign\Tests\Unit\Handler\SignEngine\JSignPdf; use OCA\Libresign\AppInfo\Application; use OCA\Libresign\DataObjects\VisibleElementAssoc; @@ -14,7 +14,8 @@ use OCA\Libresign\Enum\DocMdpLevel; use OCA\Libresign\Exception\LibresignException; use OCA\Libresign\Handler\CertificateEngine\CertificateEngineFactory; -use OCA\Libresign\Handler\SignEngine\JSignPdfHandler; +use OCA\Libresign\Handler\SignEngine\JSignPdf\HashAlgorithmResolver; +use OCA\Libresign\Handler\SignEngine\JSignPdf\JSignPdfHandler; use OCA\Libresign\Helper\JavaHelper; use OCA\Libresign\Service\DocMdp\ConfigService as DocMdpConfigService; use OCA\Libresign\Service\SignatureBackgroundService; @@ -93,6 +94,7 @@ private function getInstance(array $methods = []): JSignPdfHandler|MockObject { // Create mock factory if initialization failed in setUpBeforeClass $certificateEngineFactory = self::$certificateEngineFactory ?? $this->createMock(CertificateEngineFactory::class); + $hashAlgorithmResolver = new HashAlgorithmResolver($this->appConfig); if (empty($methods)) { return new JSignPdfHandler( @@ -104,6 +106,7 @@ private function getInstance(array $methods = []): JSignPdfHandler|MockObject { $certificateEngineFactory, $this->javaHelper, $this->createMock(DocMdpConfigService::class), + $hashAlgorithmResolver, ); } return $this->getMockBuilder(JSignPdfHandler::class) @@ -116,6 +119,7 @@ private function getInstance(array $methods = []): JSignPdfHandler|MockObject { $certificateEngineFactory, $this->javaHelper, $this->createMock(DocMdpConfigService::class), + $hashAlgorithmResolver, ]) ->onlyMethods($methods) ->getMock(); @@ -127,40 +131,6 @@ private function setDocMdpConfigService(JSignPdfHandler $handler, DocMdpConfigSe $reflection->setValue($handler, $docMdpConfigService); } - #[DataProvider('providerGetHashAlgorithm')] - public function testGetHashAlgorithm(string $setting, string $content, string $expected): void { - if (self::$certificateEngineFactory === null || empty(self::$certificateContent)) { - $this->markTestSkipped('Certificate initialization failed'); - } - - $this->appConfig->setValueString('libresign', 'signature_hash_algorithm', $setting); - $instance = $this->getInstance(['getInputFile']); - $file = $this->createMock(\OCP\Files\File::class); - $file->method('getContent')->willReturn($content); - $instance->method('getInputFile')->willReturn($file); - $actual = self::invokePrivate($instance, 'getHashAlgorithm', [$content]); - $this->assertEquals($expected, $actual); - } - - public static function providerGetHashAlgorithm(): array { - return [ - 'empty setting, PDF 1.6' => ['', '%PDF-1.6', 'SHA256'], - 'invalid PDF header' => ['', 'random data', 'SHA256'], - 'invalid setting, fallback to SHA256 on PDF 1.7' => ['XYZ', '%PDF-1.7', 'SHA256'], - 'null-like setting, PDF 1.5' => ['0', '%PDF-1.5', 'SHA1'], - 'default with PDF 1.0' => ['', '%PDF-1', 'SHA1'], - 'SHA1 with PDF 1.5' => ['', '%PDF-1.5', 'SHA1'], - 'SHA1 with PDF 1.6' => ['', '%PDF-1.6', 'SHA256'], - 'SHA1 with PDF 1.7' => ['', '%PDF-1.7', 'SHA256'], - 'SHA1 with PDF 2.0' => ['', '%PDF-2.0', 'SHA256'], - 'SHA384, PDF 1.6 (fallback)' => ['SHA384', '%PDF-1.6', 'SHA256'], - 'SHA384, PDF 1.7' => ['SHA384', '%PDF-1.7', 'SHA384'], - 'SHA512, PDF 1.6' => ['SHA512', '%PDF-1.6', 'SHA256'], - 'RIPEMD160, PDF 1.6 (unsupported)' => ['RIPEMD160', '%PDF-1.6', 'SHA256'], - 'RIPEMD160, PDF 1.7 (supported)' => ['RIPEMD160', '%PDF-1.7', 'RIPEMD160'], - ]; - } - #[DataProvider('providerExtractPdfVersion')] public function testExtractPdfVersion(string $content, ?float $expected): void { if (self::$certificateEngineFactory === null || empty(self::$certificateContent)) { @@ -274,7 +244,7 @@ public function testSignAffectedParams( ); $this->signatureBackgroundService->method('getImagePath')->willReturn( - realpath(__DIR__ . '/../../../../../img/LibreSign.png') + realpath(__DIR__ . '/../../../../../../img/LibreSign.png') ); $this->appConfig->setValueFloat('libresign', 'template_font_size', $templateFontSize); @@ -341,7 +311,7 @@ public static function providerSignAffectedParams(): array { 'lly' => 0, 'urx' => 0, 'ury' => 0, - ], realpath(__DIR__ . '/../../../../../img/app-dark.png'))], + ], realpath(__DIR__ . '/../../../../../../img/app-dark.png'))], 'signatureWidth' => 100, 'signatureHeight' => 100, 'template' => '', @@ -359,7 +329,7 @@ public static function providerSignAffectedParams(): array { 'lly' => 20, 'urx' => 30, 'ury' => 40, - ], realpath(__DIR__ . '/../../../../../img/app-dark.png'))], + ], realpath(__DIR__ . '/../../../../../../img/app-dark.png'))], 'signatureWidth' => 20, 'signatureHeight' => 20, 'template' => '', @@ -377,7 +347,7 @@ public static function providerSignAffectedParams(): array { 'lly' => 20, 'urx' => 30, 'ury' => 40, - ], realpath(__DIR__ . '/../../../../../img/app-dark.png'))], + ], realpath(__DIR__ . '/../../../../../../img/app-dark.png'))], 'signatureWidth' => 20, 'signatureHeight' => 20, 'template' => 'aaaaa', @@ -395,7 +365,7 @@ public static function providerSignAffectedParams(): array { 'lly' => 20, 'urx' => 30, 'ury' => 40, - ], realpath(__DIR__ . '/../../../../../img/app-dark.png'))], + ], realpath(__DIR__ . '/../../../../../../img/app-dark.png'))], 'signatureWidth' => 20, 'signatureHeight' => 20, 'template' => 'aaaaa', @@ -413,7 +383,7 @@ public static function providerSignAffectedParams(): array { 'lly' => 20, 'urx' => 30, 'ury' => 40, - ], realpath(__DIR__ . '/../../../../../img/app-dark.png'))], + ], realpath(__DIR__ . '/../../../../../../img/app-dark.png'))], 'signatureWidth' => 20, 'signatureHeight' => 20, 'template' => 'aaaaa', @@ -431,7 +401,7 @@ public static function providerSignAffectedParams(): array { 'lly' => 20, 'urx' => 30, 'ury' => 40, - ], realpath(__DIR__ . '/../../../../../img/app-dark.png'))], + ], realpath(__DIR__ . '/../../../../../../img/app-dark.png'))], 'signatureWidth' => 20, 'signatureHeight' => 20, 'template' => 'a"b $c \'d e', @@ -449,7 +419,7 @@ public static function providerSignAffectedParams(): array { 'lly' => 20, 'urx' => 30, 'ury' => 40, - ], realpath(__DIR__ . '/../../../../../img/app-dark.png'))], + ], realpath(__DIR__ . '/../../../../../../img/app-dark.png'))], 'signatureWidth' => 20, 'signatureHeight' => 20, 'template' => '', @@ -467,7 +437,7 @@ public static function providerSignAffectedParams(): array { 'lly' => 20, 'urx' => 30, 'ury' => 40, - ], realpath(__DIR__ . '/../../../../../img/app-dark.png'))], + ], realpath(__DIR__ . '/../../../../../../img/app-dark.png'))], 'signatureWidth' => 20, 'signatureHeight' => 20, 'template' => 'aaaaa', @@ -485,7 +455,7 @@ public static function providerSignAffectedParams(): array { 'lly' => 100, 'urx' => 351, 'ury' => 200, - ], realpath(__DIR__ . '/../../../../../img/app-dark.png'))], + ], realpath(__DIR__ . '/../../../../../../img/app-dark.png'))], 'signatureWidth' => 350, 'signatureHeight' => 100, 'template' => 'aaaaa', @@ -503,7 +473,7 @@ public static function providerSignAffectedParams(): array { 'lly' => 20, 'urx' => 30, 'ury' => 40, - ], realpath(__DIR__ . '/../../../../../img/app-dark.png'))], + ], realpath(__DIR__ . '/../../../../../../img/app-dark.png'))], 'signatureWidth' => 20, 'signatureHeight' => 20, 'template' => 'aaaaa', @@ -560,7 +530,7 @@ public static function providerSignAffectedParams(): array { 'lly' => 20, 'urx' => 30, 'ury' => 40, - ], realpath(__DIR__ . '/../../../../../img/app-dark.png'))], + ], realpath(__DIR__ . '/../../../../../../img/app-dark.png'))], 'signatureWidth' => 20, 'signatureHeight' => 20, 'template' => '', @@ -578,7 +548,7 @@ public static function providerSignAffectedParams(): array { 'lly' => 20, 'urx' => 30, 'ury' => 40, - ], realpath(__DIR__ . '/../../../../../img/app-dark.png'))], + ], realpath(__DIR__ . '/../../../../../../img/app-dark.png'))], 'signatureWidth' => 0, 'signatureHeight' => 0, 'template' => '', @@ -602,7 +572,7 @@ public function testDocMdpAppliedOnlyOnFirstVisibleElement(): void { $this->signatureBackgroundService->method('getSignatureBackgroundType')->willReturn('deleted'); $this->signatureBackgroundService->method('getImagePath')->willReturn( - realpath(__DIR__ . '/../../../../../img/LibreSign.png') + realpath(__DIR__ . '/../../../../../../img/LibreSign.png') ); $this->appConfig->setValueFloat('libresign', 'template_font_size', 10); @@ -637,14 +607,14 @@ public function testDocMdpAppliedOnlyOnFirstVisibleElement(): void { 'lly' => 10, 'urx' => 110, 'ury' => 60, - ], realpath(__DIR__ . '/../../../../../img/app-dark.png')), + ], realpath(__DIR__ . '/../../../../../../img/app-dark.png')), self::getElement([ 'page' => 1, 'llx' => 120, 'lly' => 10, 'urx' => 220, 'ury' => 60, - ], realpath(__DIR__ . '/../../../../../img/app-dark.png')), + ], realpath(__DIR__ . '/../../../../../../img/app-dark.png')), ]); $jSignPdfHandler->setJSignPdf($mock); $jSignPdfHandler->setInputFile($inputFile); @@ -669,7 +639,7 @@ public function testDocMdpSkippedWhenSignatureExists(): void { $this->signatureBackgroundService->method('getSignatureBackgroundType')->willReturn('deleted'); $this->signatureBackgroundService->method('getImagePath')->willReturn( - realpath(__DIR__ . '/../../../../../img/LibreSign.png') + realpath(__DIR__ . '/../../../../../../img/LibreSign.png') ); $this->appConfig->setValueFloat('libresign', 'template_font_size', 10); @@ -704,7 +674,7 @@ public function testDocMdpSkippedWhenSignatureExists(): void { 'lly' => 10, 'urx' => 110, 'ury' => 60, - ], realpath(__DIR__ . '/../../../../../img/app-dark.png')), + ], realpath(__DIR__ . '/../../../../../../img/app-dark.png')), ]); $jSignPdfHandler->setJSignPdf($mock); $jSignPdfHandler->setInputFile($inputFile); diff --git a/tests/php/Unit/SetupCheck/JSignPdfSetupCheckTest.php b/tests/php/Unit/SetupCheck/JSignPdfSetupCheckTest.php index 9e56a4fdf3..efbdf37c6b 100644 --- a/tests/php/Unit/SetupCheck/JSignPdfSetupCheckTest.php +++ b/tests/php/Unit/SetupCheck/JSignPdfSetupCheckTest.php @@ -22,7 +22,7 @@ function is_dir(string $filename): bool { namespace OCA\Libresign\Tests\Unit\SetupCheck; -use OCA\Libresign\Handler\SignEngine\JSignPdfHandler; +use OCA\Libresign\Handler\SignEngine\JSignPdf\JSignPdfHandler; use OCA\Libresign\Helper\JavaHelper; use OCA\Libresign\Service\Install\InstallService; use OCA\Libresign\Service\Install\JSignPdfRelease;