Skip to content

Commit 1ebb445

Browse files
committed
test(handler): stub CrlRevocationChecker::validate() in OpenSslHandlerTest
Same root cause as AEngineHandlerTest: the CrlRevocationChecker mock returned null, causing 7 tests to trigger "Undefined array key 'status'" warnings in AEngineHandler::addCrlValidationInfo(). Stubbing validate() to return ['status' => CrlValidationStatus::VALID] satisfies the return-type contract and eliminates the warnings. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent a603f09 commit 1ebb445

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

tests/php/Unit/Handler/CertificateEngine/OpenSslHandlerTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
use OCA\Libresign\Db\CrlMapper;
13+
use OCA\Libresign\Enum\CrlValidationStatus;
1314
use OCA\Libresign\Exception\EmptyCertificateException;
1415
use OCA\Libresign\Exception\InvalidPasswordException;
1516
use OCA\Libresign\Exception\LibresignException;
@@ -26,6 +27,7 @@
2627
use OCP\ITempManager;
2728
use OCP\IURLGenerator;
2829
use PHPUnit\Framework\Attributes\DataProvider;
30+
use PHPUnit\Framework\MockObject\MockObject;
2931
use Psr\Log\LoggerInterface;
3032

3133
final class OpenSslHandlerTest extends \OCA\Libresign\Tests\Unit\TestCase {
@@ -41,7 +43,7 @@ final class OpenSslHandlerTest extends \OCA\Libresign\Tests\Unit\TestCase {
4143
private CrlMapper $crlMapper;
4244
private LoggerInterface $logger;
4345
private SubjectAlternativeNameService $subjectAlternativeNameService;
44-
private CrlRevocationChecker $crlRevocationChecker;
46+
private CrlRevocationChecker&MockObject $crlRevocationChecker;
4547
public function setUp(): void {
4648
$this->config = \OCP\Server::get(IConfig::class);
4749
$this->appConfig = $this->getMockAppConfigWithReset();
@@ -56,6 +58,7 @@ public function setUp(): void {
5658
$this->logger = \OCP\Server::get(LoggerInterface::class);
5759
$this->subjectAlternativeNameService = \OCP\Server::get(SubjectAlternativeNameService::class);
5860
$this->crlRevocationChecker = $this->createMock(CrlRevocationChecker::class);
61+
$this->crlRevocationChecker->method('validate')->willReturn(['status' => CrlValidationStatus::VALID]);
5962
$this->caIdentifierService->generateCaId('openssl');
6063
}
6164

0 commit comments

Comments
 (0)