Skip to content

Commit ec0efb9

Browse files
committed
test(policy): adapt account/admin tests for identification_documents resolution
Signed-off-by: Vitor Mattos <[email protected]>
1 parent ad8c323 commit ec0efb9

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

tests/php/Unit/Service/AccountServiceTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
use OCA\Libresign\Service\IdDocsService;
3030
use OCA\Libresign\Service\IdentifyMethod\IIdentifyMethod;
3131
use OCA\Libresign\Service\IdentifyMethodService;
32+
use OCA\Libresign\Service\Policy\Model\ResolvedPolicy;
33+
use OCA\Libresign\Service\Policy\PolicyService;
3234
use OCA\Libresign\Service\Policy\PolicyAuthorizationService;
3335
use OCA\Libresign\Service\Policy\RequestSignAuthorizationService;
3436
use OCA\Libresign\Service\RequestSignatureService;
@@ -82,6 +84,7 @@ final class AccountServiceTest extends \OCA\Libresign\Tests\Unit\TestCase {
8284
private IGroupManager&MockObject $groupManager;
8385
private ISubAdmin&MockObject $subAdmin;
8486
private PolicyAuthorizationService $policyAuthorizationService;
87+
private PolicyService&MockObject $policyService;
8588
private IdDocsService&MockObject $idDocsService;
8689
private SignerElementsService&MockObject $signerElementsService;
8790
private UserElementMapper&MockObject $userElementMapper;
@@ -122,6 +125,17 @@ public function setUp(): void {
122125
$this->groupManager = $this->createMock(IGroupManager::class);
123126
$this->subAdmin = $this->createMock(ISubAdmin::class);
124127
$this->policyAuthorizationService = new PolicyAuthorizationService($this->groupManager, $this->subAdmin);
128+
$this->policyService = $this->createMock(PolicyService::class);
129+
$this->policyService->method('resolveForUser')->willReturn(
130+
(new ResolvedPolicy())
131+
->setPolicyKey('identification_documents')
132+
->setEffectiveValue(false)
133+
);
134+
$this->policyService->method('resolve')->willReturn(
135+
(new ResolvedPolicy())
136+
->setPolicyKey('identification_documents')
137+
->setEffectiveValue(false)
138+
);
125139
$this->idDocsService = $this->createMock(IdDocsService::class);
126140
$this->signerElementsService = $this->createMock(SignerElementsService::class);
127141
$this->userElementMapper = $this->createMock(UserElementMapper::class);
@@ -157,6 +171,7 @@ private function getService(): AccountService {
157171
$this->pkcs12Handler,
158172
$this->groupManager,
159173
$this->policyAuthorizationService,
174+
$this->policyService,
160175
$this->idDocsService,
161176
$this->signerElementsService,
162177
$this->userElementMapper,

tests/php/Unit/Settings/AdminTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use OCA\Libresign\Service\DocMdp\ConfigService as DocMdpConfigService;
1717
use OCA\Libresign\Service\FooterService;
1818
use OCA\Libresign\Service\IdentifyMethodService;
19+
use OCA\Libresign\Service\Policy\Model\ResolvedPolicy;
1920
use OCA\Libresign\Service\Policy\PolicyService;
2021
use OCA\Libresign\Service\SignatureBackgroundService;
2122
use OCA\Libresign\Service\SignatureTextService;
@@ -84,6 +85,11 @@ private function stubGetFormDependencies(): void {
8485
$this->identifyMethodService->method('getIdentifyMethodsSettings')->willReturn([]);
8586
$this->docMdpConfigService->method('getConfig')->willReturn([]);
8687
$this->policyService->method('resolveKnownPolicies')->willReturn([]);
88+
$this->policyService->method('resolve')->willReturn(
89+
(new ResolvedPolicy())
90+
->setPolicyKey('identification_documents')
91+
->setEffectiveValue(false)
92+
);
8793

8894
$engine = $this->createMock(OpenSslHandler::class);
8995
$engine->method('getName')->willReturn('openssl');

0 commit comments

Comments
 (0)