|
17 | 17 | use OCA\Libresign\Db\SignRequestMapper; |
18 | 18 | use OCA\Libresign\Db\UserElement; |
19 | 19 | use OCA\Libresign\Db\UserElementMapper; |
| 20 | +use OCA\Libresign\Enum\CRLReason; |
20 | 21 | use OCA\Libresign\Handler\CertificateEngine\CertificateEngineFactory; |
21 | 22 | use OCA\Libresign\Handler\SignEngine\Pkcs12Handler; |
22 | 23 | use OCA\Libresign\Helper\FileUploadHelper; |
23 | 24 | use OCA\Libresign\Helper\ValidateHelper; |
24 | 25 | use OCA\Libresign\Service\AccountService; |
| 26 | +use OCA\Libresign\Service\Crl\CrlService; |
25 | 27 | use OCA\Libresign\Service\FolderService; |
26 | 28 | use OCA\Libresign\Service\IdDocsService; |
27 | 29 | use OCA\Libresign\Service\IdentifyMethod\IIdentifyMethod; |
@@ -81,6 +83,7 @@ final class AccountServiceTest extends \OCA\Libresign\Tests\Unit\TestCase { |
81 | 83 | private RequestSignatureService&MockObject $requestSignatureService; |
82 | 84 | private Pkcs12Handler&MockObject $pkcs12Handler; |
83 | 85 | private FileUploadHelper&MockObject $uploadHelper; |
| 86 | + private CrlService&MockObject $crlService; |
84 | 87 |
|
85 | 88 | public function setUp(): void { |
86 | 89 | parent::setUp(); |
@@ -115,6 +118,7 @@ public function setUp(): void { |
115 | 118 | $this->clientService = $this->createMock(ClientService::class); |
116 | 119 | $this->timeFactory = $this->createMock(TimeFactory::class); |
117 | 120 | $this->uploadHelper = $this->createMock(FileUploadHelper::class); |
| 121 | + $this->crlService = $this->createMock(CrlService::class); |
118 | 122 | } |
119 | 123 |
|
120 | 124 | private function getService(): AccountService { |
@@ -146,10 +150,32 @@ private function getService(): AccountService { |
146 | 150 | $this->folderService, |
147 | 151 | $this->clientService, |
148 | 152 | $this->timeFactory, |
149 | | - $this->uploadHelper |
| 153 | + $this->uploadHelper, |
| 154 | + $this->crlService |
150 | 155 | ); |
151 | 156 | } |
152 | 157 |
|
| 158 | + public function testDeletePfxRevokesCertificatesWithReasonAndDeletesPfx(): void { |
| 159 | + $user = $this->createMock(IUser::class); |
| 160 | + $user->method('getUID')->willReturn('admin'); |
| 161 | + |
| 162 | + $this->crlService->expects($this->once()) |
| 163 | + ->method('revokeUserCertificates') |
| 164 | + ->with( |
| 165 | + 'admin', |
| 166 | + CRLReason::CESSATION_OF_OPERATION, |
| 167 | + 'Certificate deleted by account owner.', |
| 168 | + 'admin' |
| 169 | + ) |
| 170 | + ->willReturn(1); |
| 171 | + |
| 172 | + $this->pkcs12Handler->expects($this->once()) |
| 173 | + ->method('deletePfx') |
| 174 | + ->with('admin'); |
| 175 | + |
| 176 | + $this->getService()->deletePfx($user); |
| 177 | + } |
| 178 | + |
153 | 179 | #[DataProvider('provideValidateCertificateDataCases')] |
154 | 180 | public function testValidateCertificateDataUsingDataProvider($arguments, $expectedErrorMessage):void { |
155 | 181 | if (is_callable($arguments)) { |
|
0 commit comments