@@ -269,6 +269,7 @@ def test_filter_assignment_list(admin_api_client, rando, inv_rd, view_inv_rd, or
269
269
@pytest .mark .parametrize (
270
270
'reverse_name,normal_case,unauth_case' ,
271
271
[
272
+ ('service-index-root' , 200 , 401 ),
272
273
('dabcontenttype-list' , 200 , 401 ), # could change unauthenticated case, depends on need
273
274
('dabpermission-list' , 200 , 401 ),
274
275
('resource-list' , 403 , 401 ),
@@ -289,6 +290,32 @@ def test_service_api_permissions(reverse_name, normal_case, unauth_case, admin_a
289
290
assert unauth_response .status_code == unauth_case , unauth_response .data
290
291
291
292
293
+ @pytest .mark .django_db
294
+ def test_role_types_and_permissions_payload_shape (user_api_client ):
295
+ """Minimal payload-shape checks for role types and permissions when accessed by normal user."""
296
+ # role types
297
+ url_ct = get_relative_url ('dabcontenttype-list' )
298
+ resp_ct = user_api_client .get (url_ct )
299
+ assert resp_ct .status_code == 200 , resp_ct .data
300
+ # Results should be paginated list; spot-check first item fields if present
301
+ if resp_ct .data .get ('count' , 0 ) and resp_ct .data .get ('results' ):
302
+ item = resp_ct .data ['results' ][0 ]
303
+ for key in ('api_slug' , 'service' , 'app_label' , 'model' , 'pk_field_type' ):
304
+ assert key in item
305
+ # parent_content_type is allowed to be null
306
+ assert 'parent_content_type' in item
307
+
308
+ # role permissions
309
+ url_perm = get_relative_url ('dabpermission-list' )
310
+ resp_perm = user_api_client .get (url_perm )
311
+ assert resp_perm .status_code == 200 , resp_perm .data
312
+ if resp_perm .data .get ('count' , 0 ) and resp_perm .data .get ('results' ):
313
+ item = resp_perm .data ['results' ][0 ]
314
+ for key in ('api_slug' , 'codename' , 'name' ):
315
+ assert key in item
316
+ assert 'content_type' in item # slug of related content type
317
+
318
+
292
319
@pytest .mark .django_db
293
320
class TestCreatedByAnsibleIdAllowNull :
294
321
"""Test that created_by_ansible_id field accepts null values and omissions"""
0 commit comments