Skip to content

Commit

Permalink
Add document view permissions test
Browse files Browse the repository at this point in the history
  • Loading branch information
frcroth committed Oct 15, 2023
1 parent d774ab9 commit eb626a9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions myhpi/tests/core/test_view_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,16 @@ def test_super_user_can_view_all_pages(self):
self.assertEqual(response.status_code, 200)
response = self.client.get(self.private_page.url, follow=True)
self.assertEqual(response.status_code, 200)

def test_document_view(self):
self.common_page.attachments.add(self.first_document)
self.common_page.save()
self.private_page.attachments.add(self.second_document)
self.private_page.save()

self.sign_in_as_student()
response = self.client.get(self.first_document.url, follow=True)
self.assertEqual(response.status_code, 200)

response = self.client.get(self.second_document.url, follow=True)
self.assertEqual(response.status_code, 403)

0 comments on commit eb626a9

Please sign in to comment.