mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-11 04:19:25 +00:00
fix: profile picture deletion by board members
This commit is contained in:
committed by
Bartuccio Antoine
parent
3d138d404f
commit
c6657bffd2
@ -356,82 +356,6 @@ class TestUserTools:
|
||||
assert response.status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class TestUserPicture:
|
||||
def test_anonymous_user_unauthorized(self, client):
|
||||
"""An anonymous user shouldn't have access to an user's photo page."""
|
||||
response = client.get(
|
||||
reverse(
|
||||
"core:user_pictures",
|
||||
kwargs={"user_id": User.objects.get(username="sli").pk},
|
||||
)
|
||||
)
|
||||
assert response.status_code == 403
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("username", "status"),
|
||||
[
|
||||
("guy", 403),
|
||||
("root", 200),
|
||||
("skia", 200),
|
||||
("sli", 200),
|
||||
],
|
||||
)
|
||||
def test_page_is_working(self, client, username, status):
|
||||
"""Only user that subscribed (or admins) should be able to see the page."""
|
||||
# Test for simple user
|
||||
client.force_login(User.objects.get(username=username))
|
||||
response = client.get(
|
||||
reverse(
|
||||
"core:user_pictures",
|
||||
kwargs={"user_id": User.objects.get(username="sli").pk},
|
||||
)
|
||||
)
|
||||
assert response.status_code == status
|
||||
|
||||
|
||||
# TODO: many tests on the pages:
|
||||
# - renaming a page
|
||||
# - changing a page's parent --> check that page's children's full_name
|
||||
# - changing the different groups of the page
|
||||
|
||||
|
||||
class TestFileHandling(TestCase):
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
cls.subscriber = User.objects.get(username="subscriber")
|
||||
|
||||
def setUp(self):
|
||||
self.client.login(username="subscriber", password="plop")
|
||||
|
||||
def test_create_folder_home(self):
|
||||
response = self.client.post(
|
||||
reverse("core:file_detail", kwargs={"file_id": self.subscriber.home.id}),
|
||||
{"folder_name": "GUY_folder_test"},
|
||||
)
|
||||
assert response.status_code == 302
|
||||
response = self.client.get(
|
||||
reverse("core:file_detail", kwargs={"file_id": self.subscriber.home.id})
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert "GUY_folder_test</a>" in str(response.content)
|
||||
|
||||
def test_upload_file_home(self):
|
||||
with open("/bin/ls", "rb") as f:
|
||||
response = self.client.post(
|
||||
reverse(
|
||||
"core:file_detail", kwargs={"file_id": self.subscriber.home.id}
|
||||
),
|
||||
{"file_field": f},
|
||||
)
|
||||
assert response.status_code == 302
|
||||
response = self.client.get(
|
||||
reverse("core:file_detail", kwargs={"file_id": self.subscriber.home.id})
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert "ls</a>" in str(response.content)
|
||||
|
||||
|
||||
class TestUserIsInGroup(TestCase):
|
||||
"""Test that the User.is_in_group() and AnonymousUser.is_in_group()
|
||||
work as intended.
|
||||
|
Reference in New Issue
Block a user