From 1847c32ff3afaf7c6a0c9b68d5c3b041ecf78024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maia?= Date: Thu, 8 Oct 2026 21:56:09 -0300 Subject: [PATCH 1/3] test(page): pass the validation policy service to PageController MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 20d806ade added ValidationEffectivePolicyService to the PageController constructor, and every PageControllerTest case has failed with an ArgumentCountError since then. The service is final, so the tests build it around the PolicyService mock they already configure. The public validation case now also checks the payload it hands to the page: the requester policies are resolved without the user scope, and with no legal information the page receives an empty policy list. Signed-off-by: André Maia --- tests/php/Integration/Controller/PageControllerTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/php/Integration/Controller/PageControllerTest.php b/tests/php/Integration/Controller/PageControllerTest.php index 05981412ae..5db8075701 100644 --- a/tests/php/Integration/Controller/PageControllerTest.php +++ b/tests/php/Integration/Controller/PageControllerTest.php @@ -20,6 +20,7 @@ use OCA\Libresign\Service\IdentifyMethodService; use OCA\Libresign\Service\Policy\PolicyAuthorizationService; use OCA\Libresign\Service\Policy\PolicyService; +use OCA\Libresign\Service\Policy\ValidationEffectivePolicyService; use OCA\Libresign\Service\RequestSignatureService; use OCA\Libresign\Service\SessionService; use OCA\Libresign\Service\SignerElementsService; @@ -150,6 +151,7 @@ public function setUp(): void { signFileService: $this->signFileService, requestSignatureService: \OCP\Server::get(RequestSignatureService::class), policyService: $this->policyService, + validationEffectivePolicyService: new ValidationEffectivePolicyService($this->policyService), policyAuthorizationService: $this->policyAuthorizationService, signerElementsService: $this->signerElementsService, l10n: $this->createMock(IL10N::class), @@ -343,6 +345,7 @@ public function testValidationFilePublicBootstrapsRequesterPoliciesWithoutUserSc signFileService: $signFileService, requestSignatureService: \OCP\Server::get(RequestSignatureService::class), policyService: $policyService, + validationEffectivePolicyService: new ValidationEffectivePolicyService($policyService), policyAuthorizationService: $this->policyAuthorizationService, signerElementsService: $this->signerElementsService, l10n: $this->createMock(IL10N::class), @@ -362,7 +365,7 @@ public function testValidationFilePublicBootstrapsRequesterPoliciesWithoutUserSc $response = $controller->validationFilePublic('validation-file-uuid'); - self::assertArrayHasKey('effective_policies', $capturedInitialState); + self::assertSame(['policies' => []], $capturedInitialState['effective_policies'] ?? null); self::assertSame('external', $response->getTemplateName()); self::assertSame(TemplateResponse::RENDER_AS_BASE, $response->getRenderAs()); } From 37cde7bc42f894cde2cad4cfebc267fa38e1d56d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maia?= Date: Thu, 8 Oct 2026 21:56:09 -0300 Subject: [PATCH 2/3] test(validation): expect the legal information instead of the policy store MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 37d92ddbf stopped the validation page from writing the requester's effective policies into the global policy store; it keeps only the legal information from the payload. The test still expected setPolicies to be called. It now checks that the legal information returned with the validation is shown and that the policy store is left untouched. Signed-off-by: André Maia --- src/tests/views/Validation.spec.ts | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/tests/views/Validation.spec.ts b/src/tests/views/Validation.spec.ts index 5283ab48ad..e1986dec03 100644 --- a/src/tests/views/Validation.spec.ts +++ b/src/tests/views/Validation.spec.ts @@ -1074,7 +1074,7 @@ describe('Validation.vue - Business Logic', () => { expect(filesStore.addFile).not.toHaveBeenCalled() }) - it('updates the policies store when requester effective policies are returned', async () => { + it('shows the requester legal information returned with the validation', async () => { const { usePoliciesStore } = await import('../../store/policies') const policiesStore = usePoliciesStore() @@ -1085,25 +1085,13 @@ describe('Validation.vue - Business Logic', () => { legal_information: { policyKey: 'legal_information', effectiveValue: 'Requester legal copy', - sourceScope: 'user_policy', - visible: true, - editableByCurrentActor: false, - allowedValues: [], - canSaveAsUserDefault: false, - canUseAsRequestOverride: false, - preferenceWasCleared: false, - blockedBy: null, }, }, }, }) - expect(policiesStore.setPolicies).toHaveBeenCalledWith({ - legal_information: expect.objectContaining({ - effectiveValue: 'Requester legal copy', - sourceScope: 'user_policy', - }), - }) + expect(wrapper.vm.legalInformation).toBe('Requester legal copy') + expect(policiesStore.setPolicies).not.toHaveBeenCalled() }) }) From ff4d8444c3307b6c9ae28852b7e7ca5e3c468f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maia?= Date: Sat, 17 Oct 2026 18:37:31 -0300 Subject: [PATCH 3/3] test(validation): drop the unreachable policies store assertion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: André Maia --- src/tests/views/Validation.spec.ts | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/tests/views/Validation.spec.ts b/src/tests/views/Validation.spec.ts index e1986dec03..352c1f73a1 100644 --- a/src/tests/views/Validation.spec.ts +++ b/src/tests/views/Validation.spec.ts @@ -184,17 +184,6 @@ vi.mock('../../store/files.js', () => { } }) -vi.mock('../../store/policies', () => { - const policiesStore = { - setPolicies: vi.fn(), - getEffectiveValue: vi.fn(() => ''), - } - - return { - usePoliciesStore: vi.fn(() => policiesStore), - } -}) - // Mock utils vi.mock('../../utils/viewer.js', () => ({ openDocument: vi.fn(), @@ -1074,10 +1063,7 @@ describe('Validation.vue - Business Logic', () => { expect(filesStore.addFile).not.toHaveBeenCalled() }) - it('shows the requester legal information returned with the validation', async () => { - const { usePoliciesStore } = await import('../../store/policies') - const policiesStore = usePoliciesStore() - + it('shows the requester legal information returned with the validation', () => { wrapper.vm.handleValidationSuccess({ ...createLoadedValidationDocument({ status: SIGNED_STATUS }), effective_policies: { @@ -1091,7 +1077,6 @@ describe('Validation.vue - Business Logic', () => { }) expect(wrapper.vm.legalInformation).toBe('Requester legal copy') - expect(policiesStore.setPolicies).not.toHaveBeenCalled() }) })