mirror of
https://github.com/barkeser2002/offline-db.git
synced 2026-09-25 05:20:06 +03:00
- Added IsAuthenticated permission_class to the my_rooms custom action in RoomViewSet to prevent unauthenticated access. - Added a test case `test_my_rooms_unauthenticated` to verify the fix. - Updated .jules/sentinel.md with the security learning. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
14 lines
509 B
Python
14 lines
509 B
Python
import pytest
|
|
from django.test import Client
|
|
from django.urls import reverse
|
|
|
|
@pytest.mark.django_db
|
|
def test_my_rooms_unauthenticated():
|
|
client = Client()
|
|
# The action URL is typically named `basename-action-name`
|
|
# Default router basename for RoomViewSet is `room`
|
|
url = reverse('room-my-rooms')
|
|
# Use follow=True or explicitly request the trailing slash URL
|
|
response = client.get(url, follow=True)
|
|
assert response.status_code == 401, f"Expected 401, got {response.status_code}"
|