1
1
import json
2
- from django .utils import timezone
3
2
from django .urls import reverse
4
3
from rest_framework import status
5
4
from core .models import SepData
@@ -18,21 +17,22 @@ class Sep_DataTestCase(BaseTestCase):
18
17
19
18
def test_get_sep_data_admin_and_ip (self ):
20
19
"""
21
- Ensure we can get a list of visits as admin and internal provider
20
+ Ensure even high permission users cannot access all sep data objects at once.
22
21
"""
23
22
header1 = self .auth_headers_for_user ("admin" )
24
23
url = reverse ("sepdata-list" )
25
24
res1 = self .client .get (url , format = "json" , follow = True , ** header1 )
25
+ expected_content = {'detail' : 'Sep data must be queried by visit id.' }
26
26
27
- self .assertEqual (res1 .status_code , status .HTTP_200_OK )
28
- self .assertEqual (SepData . objects . count (), len ( json .loads (res1 .content ) ))
27
+ self .assertEqual (res1 .status_code , status .HTTP_403_FORBIDDEN )
28
+ self .assertEqual (expected_content , json .loads (res1 .content ))
29
29
30
30
header2 = self .auth_headers_for_user ("internal_provider" )
31
31
url = reverse ("sepdata-list" )
32
32
res2 = self .client .get (url , format = "json" , follow = True , ** header2 )
33
33
34
- self .assertEqual (res2 .status_code , status .HTTP_200_OK )
35
- self .assertEqual (SepData . objects . count (), len ( json .loads (res2 .content ) ))
34
+ self .assertEqual (res2 .status_code , status .HTTP_403_FORBIDDEN )
35
+ self .assertEqual (expected_content , json .loads (res2 .content ))
36
36
37
37
def test_get_sep_auth_denial_unauthorized (self ):
38
38
"""
0 commit comments