@@ -120,9 +120,9 @@ def test_index_no_parameters(client, user, mock_arborist_requests, is_rbac_confi
120120 assert data_all_by_md .status_code == 403 , f"Expected status code 403, got { data_all_by_md .status_code } "
121121
122122
123- def test_drs_no_parameters (client , user , mock_arborist_requests , is_rbac_configured ):
123+ def test_multiple_endpoints (client , user , mock_arborist_requests , is_rbac_configured ):
124124 """
125- Test that the index endpoint without parameters returns expected projects .
125+ Test multiple endpoints, ensure rbac .
126126 """
127127 if not is_rbac_configured :
128128 pytest .skip ("RBAC is not configured, skipping test." )
@@ -204,6 +204,53 @@ def test_drs_no_parameters(client, user, mock_arborist_requests, is_rbac_configu
204204 assert len (data_all_list [
205205 "drs_objects" ]) == 0 , f"Should have access to 0 records, got { len (data_all_list ['drs_objects' ])} records: { data_all_list } "
206206
207+ # start other-checks
208+
209+ print (f"DEBUG >>>>>> User should not have access to /index/urls" , file = sys .stderr )
210+ urls = client .get ("/index/urls" , headers = user )
211+ assert urls .status_code == 404 , f"Expected status code 404, got { urls .status_code } "
212+ urls = urls .json
213+ assert 'error' in urls , f"Expected 'error' in response, got { urls } "
214+ assert urls ['error' ] == 'no record found' , f"Expected 'no record found', got { urls ['error' ]} "
215+
216+ print (f"DEBUG >>>>>> User should not have access to /index/{ res2_did } " , file = sys .stderr )
217+ data_2 = client .get (f"/index/{ res2_did } " , headers = user )
218+ assert data_2 .status_code == 403 , f"Expected status code 403, got { data_2 .status_code } "
219+ data_2 = data_2 .json
220+ assert 'error' in data_2 , f"Expected 'error' in response, got { data_2 } "
221+ assert data_2 ['error' ] == 'User is not authorized for any resources' , f"Expected 'User is not authorized for any resources', got { data_2 ['error' ]} "
222+
223+ print (f"DEBUG >>>>>> User should not have access to /index/ga4gh/dos/v1/dataobjects/{ res2_did } " , file = sys .stderr )
224+ dataobjects = client .get (f"/index/ga4gh/dos/v1/dataobjects/{ res2_did } " , headers = user )
225+ assert dataobjects .status_code == 404 , f"Expected status code 404, got { dataobjects .status_code } "
226+ dataobjects = dataobjects .json
227+ assert 'error' in dataobjects , f"Expected 'error' in response, got { dataobjects } "
228+ assert dataobjects ['error' ] == 'no record found' , f"Expected 'no record found', got { dataobjects ['error' ]} "
229+
230+ print (f"DEBUG >>>>>> User should not have access to index/bundle" , file = sys .stderr )
231+ bundles = client .get (f"/index/bundle" , headers = user )
232+ assert bundles .status_code == 404 , f"Expected status code 404, got { bundles .status_code } "
233+ bundles = bundles .json
234+ assert 'error' in bundles , f"Expected 'error' in response, got { bundles } "
235+ assert bundles ['error' ] == 'no record found' , f"Expected 'no record found', got { bundles ['error' ]} "
236+
237+ print (f"DEBUG >>>>>> User should not have access to index/index/{ res2_did } /aliases" , file = sys .stderr )
238+ aliases = client .get (f"index/index/{ res2_did } /aliases" , headers = user )
239+ assert aliases .status_code == 404 , f"Expected status code 404, got { aliases .status_code } "
240+ aliases = aliases .json
241+ assert 'error' in aliases , f"Expected 'error' in response, got { aliases } "
242+ assert aliases ['error' ] == f"index/{ res2_did } " , f"Expected 'index/{ res2_did } ', got { aliases } "
243+
244+ print (f"DEBUG >>>>>> User should not have access to index/_stats" , file = sys .stderr )
245+ _stats = client .get (f"index/_stats" , headers = user )
246+ assert _stats .status_code == 404 , f"Expected status code 404, got { _stats .status_code } "
247+ _stats = _stats .json
248+ assert 'error' in _stats , f"Expected 'error' in response, got { _stats } "
249+ assert _stats ['error' ] == 'no record found' , f"Expected 'no record found', got { _stats } "
250+
251+ # end other-checks
252+
253+ print (f"DEBUG >>>>>> User should not have access to /ga4gh/drs/v1/objects/{ res2_did } " , file = sys .stderr )
207254 data_2 = client .get (f"/ga4gh/drs/v1/objects/{ res2_did } " , headers = user )
208255 assert data_2 .status_code == 403 , f"Expected status code 403, got { data_2 .status_code } "
209256
@@ -214,28 +261,29 @@ def test_drs_no_parameters(client, user, mock_arborist_requests, is_rbac_configu
214261 }
215262 )
216263
217- print ("DEBUG >>>>>> User should not have access to any records " , file = sys .stderr )
264+ print ("DEBUG >>>>>> User should not have access to any /ga4gh/drs/v1/objects " , file = sys .stderr )
218265 data_all_by_md = client .get ("/ga4gh/drs/v1/objects" , headers = user )
219266 assert data_all_by_md .status_code == 200 , f"Expected status code 200, got { data_all_by_md .status_code } "
220267 data_all_list = data_all_by_md .json
221268
222269 assert len (data_all_list [
223270 "drs_objects" ]) == 0 , f"Should have access to 0 records, got { len (data_all_list ['drs_objects' ])} records: { data_all_list } "
224271
272+ print (f"DEBUG >>>>>> User should not have access to /ga4gh/drs/v1/objects/{ res1_did } " , file = sys .stderr )
225273 data_1 = client .get (f"/ga4gh/drs/v1/objects/{ res1_did } " , headers = user )
226274 assert data_1 .status_code == 401 , f"Expected status code 401, got { data_1 .status_code } "
227275
276+ print (f"DEBUG >>>>>> User should not have access to /ga4gh/drs/v1/objects/{ res2_did } " , file = sys .stderr )
228277 data_2 = client .get (f"/ga4gh/drs/v1/objects/{ res2_did } " , headers = user )
229278 assert data_2 .status_code == 401 , f"Expected status code 401, got { data_2 .status_code } "
230279
231-
232280 # user has no access to anything
233281 mock_arborist_requests (
234282 resource_method_to_authorized = {
235283 }
236284 )
237285
238- print ("DEBUG >>>>>> User should not have access to anything " , file = sys .stderr )
286+ print ("DEBUG >>>>>> User should not have access to /ga4gh/drs/v1/objects " , file = sys .stderr )
239287 data_all_by_md = client .get ("/ga4gh/drs/v1/objects" , headers = user )
240288 assert data_all_by_md .status_code == 200 , f"Expected status code 200, got { data_all_by_md .status_code } "
241289 data_all_list = data_all_by_md .json
0 commit comments