Skip to content

Commit aefcbef

Browse files
committed
refactor: inject PolicyService into certificate engine handlers
Signed-off-by: Vitor Mattos <[email protected]>
1 parent 9e34152 commit aefcbef

4 files changed

Lines changed: 16 additions & 0 deletions

File tree

lib/Handler/CertificateEngine/CfsslHandler.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use OCA\Libresign\Service\CertificatePolicyService;
2323
use OCA\Libresign\Service\Crl\CrlRevocationChecker;
2424
use OCA\Libresign\Service\Install\InstallService;
25+
use OCA\Libresign\Service\Policy\PolicyService;
2526
use OCA\Libresign\Service\Process\ProcessManager;
2627
use OCA\Libresign\Vendor\Symfony\Component\Process\Process;
2728
use OCP\Files\AppData\IAppDataFactory;
@@ -58,6 +59,7 @@ public function __construct(
5859
protected CertificatePolicyService $certificatePolicyService,
5960
protected IURLGenerator $urlGenerator,
6061
protected CaIdentifierService $caIdentifierService,
62+
protected PolicyService $policyService,
6163
protected CrlMapper $crlMapper,
6264
protected LoggerInterface $logger,
6365
CrlRevocationChecker $crlRevocationChecker,
@@ -72,6 +74,7 @@ public function __construct(
7274
$certificatePolicyService,
7375
$urlGenerator,
7476
$caIdentifierService,
77+
$policyService,
7578
$logger,
7679
$crlRevocationChecker,
7780
);

lib/Handler/CertificateEngine/OpenSslHandler.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use OCA\Libresign\Service\CaIdentifierService;
1616
use OCA\Libresign\Service\CertificatePolicyService;
1717
use OCA\Libresign\Service\Crl\CrlRevocationChecker;
18+
use OCA\Libresign\Service\Policy\PolicyService;
1819
use OCA\Libresign\Service\SerialNumberService;
1920
use OCA\Libresign\Service\SubjectAlternativeNameService;
2021
use OCP\Files\AppData\IAppDataFactory;
@@ -46,6 +47,7 @@ public function __construct(
4647
protected IURLGenerator $urlGenerator,
4748
protected SerialNumberService $serialNumberService,
4849
protected CaIdentifierService $caIdentifierService,
50+
protected PolicyService $policyService,
4951
protected LoggerInterface $logger,
5052
protected CrlMapper $crlMapper,
5153
protected SubjectAlternativeNameService $subjectAlternativeNameService,
@@ -60,6 +62,7 @@ public function __construct(
6062
$certificatePolicyService,
6163
$urlGenerator,
6264
$caIdentifierService,
65+
$policyService,
6366
$logger,
6467
$crlRevocationChecker,
6568
);

tests/php/Unit/Handler/CertificateEngine/CfsslHandlerTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use OCA\Libresign\Service\CertificatePolicyService;
1616
use OCA\Libresign\Service\Crl\CrlRevocationChecker;
1717
use OCA\Libresign\Service\Install\InstallService;
18+
use OCA\Libresign\Service\Policy\PolicyService;
1819
use OCA\Libresign\Service\Process\ProcessManager;
1920
use OCA\Libresign\Tests\Unit\TestCase;
2021
use OCA\Libresign\Vendor\Symfony\Component\Process\Process;
@@ -234,6 +235,7 @@ private function getConstructorArgs(?string $binary = null): array {
234235
$certificatePolicyService = \OCP\Server::get(CertificatePolicyService::class);
235236
$urlGenerator = \OCP\Server::get(IURLGenerator::class);
236237
$caIdentifierService = \OCP\Server::get(CaIdentifierService::class);
238+
$policyService = \OCP\Server::get(PolicyService::class);
237239
$crlMapper = \OCP\Server::get(CrlMapper::class);
238240
$logger = \OCP\Server::get(LoggerInterface::class);
239241
$crlRevocationChecker = $this->createMock(CrlRevocationChecker::class);
@@ -251,6 +253,7 @@ private function getConstructorArgs(?string $binary = null): array {
251253
$certificatePolicyService,
252254
$urlGenerator,
253255
$caIdentifierService,
256+
$policyService,
254257
$crlMapper,
255258
$logger,
256259
$crlRevocationChecker,

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use OCA\Libresign\Service\CaIdentifierService;
1919
use OCA\Libresign\Service\CertificatePolicyService;
2020
use OCA\Libresign\Service\Crl\CrlRevocationChecker;
21+
use OCA\Libresign\Service\Policy\PolicyService;
2122
use OCA\Libresign\Service\SerialNumberService;
2223
use OCA\Libresign\Service\SubjectAlternativeNameService;
2324
use OCP\Files\AppData\IAppDataFactory;
@@ -40,6 +41,7 @@ final class OpenSslHandlerTest extends \OCA\Libresign\Tests\Unit\TestCase {
4041
private SerialNumberService $serialNumberService;
4142
private IURLGenerator $urlGenerator;
4243
private CaIdentifierService $caIdentifierService;
44+
private PolicyService $policyService;
4345
private CrlMapper $crlMapper;
4446
private LoggerInterface $logger;
4547
private SubjectAlternativeNameService $subjectAlternativeNameService;
@@ -56,6 +58,7 @@ public function setUp(): void {
5658
$this->serialNumberService = \OCP\Server::get(SerialNumberService::class);
5759
$this->urlGenerator = \OCP\Server::get(IURLGenerator::class);
5860
$this->caIdentifierService = \OCP\Server::get(CaIdentifierService::class);
61+
$this->policyService = \OCP\Server::get(PolicyService::class);
5962
$this->crlMapper = \OCP\Server::get(CrlMapper::class);
6063
$this->logger = \OCP\Server::get(LoggerInterface::class);
6164
$this->subjectAlternativeNameService = \OCP\Server::get(SubjectAlternativeNameService::class);
@@ -75,6 +78,7 @@ private function getInstance() {
7578
$this->urlGenerator,
7679
$this->serialNumberService,
7780
$this->caIdentifierService,
81+
$this->policyService,
7882
$this->logger,
7983
$this->crlMapper,
8084
$this->subjectAlternativeNameService,
@@ -109,6 +113,7 @@ public function testRootCertificateCsrFailureThrowsLibresignException(): void {
109113
$this->urlGenerator,
110114
$this->serialNumberService,
111115
$this->caIdentifierService,
116+
$this->policyService,
112117
$this->logger,
113118
$this->crlMapper,
114119
$this->subjectAlternativeNameService,
@@ -136,6 +141,7 @@ public function testRootCertificateSignFailureThrowsLibresignException(): void {
136141
$this->urlGenerator,
137142
$this->serialNumberService,
138143
$this->caIdentifierService,
144+
$this->policyService,
139145
$this->logger,
140146
$this->crlMapper,
141147
$this->subjectAlternativeNameService,
@@ -163,6 +169,7 @@ public function testRootCertificateCsrUsesGeneratedConfig(): void {
163169
$this->urlGenerator,
164170
$this->serialNumberService,
165171
$this->caIdentifierService,
172+
$this->policyService,
166173
$this->logger,
167174
$this->crlMapper,
168175
$this->subjectAlternativeNameService,

0 commit comments

Comments
 (0)