Repository navigation
test: align PageController and validation page tests with the sanitized validation payload - #9064
maia-andre wants to merge 2 commits into
Conversation
20d806a 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 <andrefnkmm@gmail.com>
…store 37d92dd 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 <andrefnkmm@gmail.com>
|
@vitormattos @YvesCesar could one of you take a look when you have a moment? Since the validation-page security fix, |
YvesCesar
left a comment
There was a problem hiding this comment.
Thanks @maia-andre !
I wrote a review. Could you take a look at it?
| }), | ||
| }) | ||
| expect(wrapper.vm.legalInformation).toBe('Requester legal copy') | ||
| expect(policiesStore.setPolicies).not.toHaveBeenCalled() |
There was a problem hiding this comment.
The view Validation.vue no longer imports store/policies (neither do its child components, and the spec uses shallowMount), so setPolicies can never be called here. This assertion always passes and doesn't protect anything from 37d92dd.
Please remove:
- this assertion and the
usePoliciesStorelookup at the top of the test (lines 1078-1079); - the
vi.mock('../../store/policies', ...)block at line 187, which is only used by this test.
The legalInformation assertion is enough to cover the new behavior.
📝 Summary
Since the validation page security fixes landed on
main(20d806a, 37d92dd), every pull request againstmainfails the same two checks, whatever it changes:PageControllerTestcases fail withArgumentCountError: PageController::__construct(): Argument #10 ($validationEffectivePolicyService) not passed.Validation.spec.ts > handleValidationSuccess > updates the policies store when requester effective policies are returnedstill expectssetPolicies, which the page no longer calls.This PR only updates those tests to the new contract. No production code changes.
PageControllerTestpasses a realValidationEffectivePolicyService(the class isfinal) built around thePolicyServicemock each test already configures. The public validation case now also asserts the policy payload the page receives (['policies' => []]when there is no legal information), instead of only checking that the key exists.Validation.spec.tschecks that the legal information returned with the validation is shown and that the global policy store is not touched, which is the intent of 37d92dd.🧪 How to test
Validation evidence
PageControllerTest11/11 (was 11 errors onmain, e.g. the PHPUnit jobs of test(appstore): cover the release Nextcloud setup and validate the unsigned package #9063);Validation.spec.ts100/100 (was 1 failure)eslinton the spec,php -lon the test✅ Checklist
🤖 AI (if applicable)