Skip to content

Commit 159348f

Browse files
committed
test: cover TSA handler DNS/network/firewall guidance
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent c2bdc27 commit 159348f

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/php/Unit/Handler/SignEngine/JSignPdfHandlerTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use OCA\Libresign\DataObjects\VisibleElementAssoc;
1313
use OCA\Libresign\Db\FileElement;
1414
use OCA\Libresign\Enum\DocMdpLevel;
15+
use OCA\Libresign\Exception\LibresignException;
1516
use OCA\Libresign\Handler\CertificateEngine\CertificateEngineFactory;
1617
use OCA\Libresign\Handler\SignEngine\JSignPdfHandler;
1718
use OCA\Libresign\Helper\JavaHelper;
@@ -732,4 +733,26 @@ public static function providerGetSignatureText(): array {
732733
['GRAPHIC_ONLY', 'a$a', '""'],
733734
];
734735
}
736+
737+
public function testCheckTsaErrorInvalidTsaMentionsDnsNetworkFirewall(): void {
738+
$jSignPdfHandler = $this->getInstance();
739+
740+
$this->expectException(LibresignException::class);
741+
$this->expectExceptionMessage('Timestamp Authority (TSA) service is unavailable. Check DNS/network/firewall connectivity from this server: https://invalid-tsa.example.com/tsr');
742+
743+
self::invokePrivate($jSignPdfHandler, 'checkTsaError', [
744+
"Invalid TSA 'https://invalid-tsa.example.com/tsr'",
745+
]);
746+
}
747+
748+
public function testCheckTsaErrorUnknownHostMentionsDnsNetworkFirewall(): void {
749+
$jSignPdfHandler = $this->getInstance();
750+
751+
$this->expectException(LibresignException::class);
752+
$this->expectExceptionMessage("Timestamp Authority (TSA) service error.\nCheck TSA endpoint and DNS/network/firewall connectivity from this server.");
753+
754+
self::invokePrivate($jSignPdfHandler, 'checkTsaError', [
755+
'TSAClientBouncyCastle: java.net.UnknownHostException: invalid-tsa.example.com',
756+
]);
757+
}
735758
}

0 commit comments

Comments
 (0)