mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-20 20:46:53 +00:00
Fix: limit manually run OCR templates to those the requester can view
A user editing someone else's document could run the owner's private templates and see their names. Manual runs now use templates both can view.
This commit is contained in:
1 parent
0c90c57e3e
commit
4788ac602b
10 files changed
+170
-27
No files matched your search
@@ -654,6 +654,24 @@ class TestTemplateVisibility(DirectoriesMixin, TestCase):
|
||||
[self.mine, self.unowned, self.private],
|
||||
)
|
||||
|
||||
def test_requester_limits_the_owners_templates(self):
|
||||
"""
|
||||
GIVEN:
|
||||
- Templates owned by the document owner, unowned, private to
|
||||
another user, and owned by the owner but shared with the requester
|
||||
WHEN:
|
||||
- Templates are selected for a manual run by the requester
|
||||
THEN:
|
||||
- Only templates both the owner and the requester can view are used
|
||||
"""
|
||||
shared = self.template("Shared", owner=self.owner)
|
||||
grant_object(self.other, shared, "view_ocrtemplate")
|
||||
|
||||
self.assertCountEqual(
|
||||
get_templates_for_document(self.document, requester=self.other),
|
||||
[self.unowned, shared],
|
||||
)
|
||||
|
||||
def test_inactive_owner_has_no_templates(self):
|
||||
self.owner.is_active = False
|
||||
self.assertEqual(get_templates_for_document(self.document), [])
|
||||
|
||||
Reference in new issue
Block a user