mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Extend ViewTestCases to get and list objects as a non-authenticated user
This commit is contained in:
@ -164,6 +164,13 @@ class ViewTestCases:
|
|||||||
response = self.client.get(instance.get_absolute_url())
|
response = self.client.get(instance.get_absolute_url())
|
||||||
self.assertHttpStatus(response, 200)
|
self.assertHttpStatus(response, 200)
|
||||||
|
|
||||||
|
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
|
||||||
|
def test_list_objects_anonymous(self):
|
||||||
|
# Make the request as an unauthenticated user
|
||||||
|
self.client.logout()
|
||||||
|
response = self.client.get(self.model.objects.first().get_absolute_url())
|
||||||
|
self.assertHttpStatus(response, 200)
|
||||||
|
|
||||||
class CreateObjectViewTestCase(ModelViewTestCase):
|
class CreateObjectViewTestCase(ModelViewTestCase):
|
||||||
"""
|
"""
|
||||||
Create a single new instance.
|
Create a single new instance.
|
||||||
@ -287,6 +294,13 @@ class ViewTestCases:
|
|||||||
self.assertHttpStatus(response, 200)
|
self.assertHttpStatus(response, 200)
|
||||||
self.assertEqual(response.get('Content-Type'), 'text/csv')
|
self.assertEqual(response.get('Content-Type'), 'text/csv')
|
||||||
|
|
||||||
|
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
|
||||||
|
def test_list_objects_anonymous(self):
|
||||||
|
# Make the request as an unauthenticated user
|
||||||
|
self.client.logout()
|
||||||
|
response = self.client.get(self._get_url('list'))
|
||||||
|
self.assertHttpStatus(response, 200)
|
||||||
|
|
||||||
class BulkCreateObjectsViewTestCase(ModelViewTestCase):
|
class BulkCreateObjectsViewTestCase(ModelViewTestCase):
|
||||||
"""
|
"""
|
||||||
Create multiple instances using a single form. Expects the creation of three new instances by default.
|
Create multiple instances using a single form. Expects the creation of three new instances by default.
|
||||||
|
Reference in New Issue
Block a user