@@ -96,8 +96,9 @@ def test_disabled_field_ignores_posted_value(self):
9696class CICDInfrastructureAPITests (APITestCase ):
9797
9898 """
99- The /cicd_infrastructure endpoint uses UserHasConfigurationPermissionSuperuser
100- — superusers can do anything; non-superusers need the explicit Django permission.
99+ The /cicd_infrastructure endpoint uses UserHasCICDInfrastructurePermission
100+ — reads are open to any authenticated user; writes require the configuration
101+ permission (superuser/staff on OS, full RBAC under Pro).
101102 """
102103
103104 fixtures = ["dojo_testdata.json" ]
@@ -144,11 +145,25 @@ def test_create_allows_same_name_different_type(self):
144145 )
145146 self .assertEqual (r .status_code , 201 , r .content [:1000 ])
146147
147- def test_non_superuser_is_rejected (self ):
148+ def test_non_superuser_can_list (self ):
148149 # 'user1' (pk=2 in dojo_testdata.json) is a non-superuser with a token.
150+ # Reads are open to authenticated users.
149151 try :
150152 c = self ._client_for ("user1" )
151153 except Token .DoesNotExist :
152154 self .skipTest ("user1 token not present in dojo_testdata fixture." )
153155 r = c .get (reverse ("cicd_infrastructure-list" ))
154- self .assertIn (r .status_code , (401 , 403 ), f"expected 401/403, got { r .status_code } " )
156+ self .assertEqual (r .status_code , 200 , r .content [:1000 ])
157+
158+ def test_non_superuser_cannot_create (self ):
159+ try :
160+ c = self ._client_for ("user1" )
161+ except Token .DoesNotExist :
162+ self .skipTest ("user1 token not present in dojo_testdata fixture." )
163+ r = c .post (
164+ reverse ("cicd_infrastructure-list" ),
165+ {"name" : "NonSuperCreate" , "infrastructure_type" : "build_server" },
166+ format = "json" ,
167+ )
168+ self .assertEqual (r .status_code , 403 , r .content [:1000 ])
169+ self .assertFalse (CICDInfrastructure .objects .filter (name = "NonSuperCreate" ).exists ())
0 commit comments