@@ -57,7 +57,7 @@ func TestCustomOrganizationRole(t *testing.T) {
5757 ctx := testutil .Context (t , testutil .WaitMedium )
5858
5959 //nolint:gocritic // owner is required for this
60- role , err := owner .PatchOrganizationRole (ctx , first . OrganizationID , templateAdminCustom (first .OrganizationID ))
60+ role , err := owner .PatchOrganizationRole (ctx , templateAdminCustom (first .OrganizationID ))
6161 require .NoError (t , err , "upsert role" )
6262
6363 // Assign the custom template admin role
@@ -111,7 +111,7 @@ func TestCustomOrganizationRole(t *testing.T) {
111111 ctx := testutil .Context (t , testutil .WaitMedium )
112112
113113 //nolint:gocritic // owner is required for this
114- role , err := owner .PatchOrganizationRole (ctx , first . OrganizationID , templateAdminCustom (first .OrganizationID ))
114+ role , err := owner .PatchOrganizationRole (ctx , templateAdminCustom (first .OrganizationID ))
115115 require .NoError (t , err , "upsert role" )
116116
117117 // Remove the license to block enterprise functionality
@@ -124,7 +124,7 @@ func TestCustomOrganizationRole(t *testing.T) {
124124 }
125125
126126 // Verify functionality is lost
127- _ , err = owner .PatchOrganizationRole (ctx , first . OrganizationID , templateAdminCustom (first .OrganizationID ))
127+ _ , err = owner .PatchOrganizationRole (ctx , templateAdminCustom (first .OrganizationID ))
128128 require .ErrorContains (t , err , "roles are not enabled" )
129129
130130 // Assign the custom template admin role
@@ -152,7 +152,7 @@ func TestCustomOrganizationRole(t *testing.T) {
152152
153153 ctx := testutil .Context (t , testutil .WaitMedium )
154154 //nolint:gocritic // owner is required for this
155- role , err := owner .PatchOrganizationRole (ctx , first . OrganizationID , templateAdminCustom (first .OrganizationID ))
155+ role , err := owner .PatchOrganizationRole (ctx , templateAdminCustom (first .OrganizationID ))
156156 require .NoError (t , err , "upsert role" )
157157
158158 // Assign the custom template admin role
@@ -169,7 +169,7 @@ func TestCustomOrganizationRole(t *testing.T) {
169169 newRole .SitePermissions = nil
170170 newRole .OrganizationPermissions = nil
171171 newRole .UserPermissions = nil
172- _ , err = owner .PatchOrganizationRole (ctx , first . OrganizationID , newRole )
172+ _ , err = owner .PatchOrganizationRole (ctx , newRole )
173173 require .NoError (t , err , "upsert role with override" )
174174
175175 // The role should no longer have template perms
@@ -203,7 +203,7 @@ func TestCustomOrganizationRole(t *testing.T) {
203203 ctx := testutil .Context (t , testutil .WaitMedium )
204204
205205 //nolint:gocritic // owner is required for this
206- _ , err := owner .PatchOrganizationRole (ctx , first . OrganizationID , codersdk.Role {
206+ _ , err := owner .PatchOrganizationRole (ctx , codersdk.Role {
207207 Name : "Bad_Name" , // No underscores allowed
208208 DisplayName : "Testing Purposes" ,
209209 OrganizationID : first .OrganizationID .String (),
@@ -232,38 +232,17 @@ func TestCustomOrganizationRole(t *testing.T) {
232232 ctx := testutil .Context (t , testutil .WaitMedium )
233233
234234 //nolint:gocritic // owner is required for this
235- _ , err := owner .PatchOrganizationRole (ctx , first . OrganizationID , codersdk.Role {
235+ _ , err := owner .PatchOrganizationRole (ctx , codersdk.Role {
236236 Name : "owner" , // Reserved
237237 DisplayName : "Testing Purposes" ,
238+ OrganizationID : first .OrganizationID .String (),
238239 SitePermissions : nil ,
239240 OrganizationPermissions : nil ,
240241 UserPermissions : nil ,
241242 })
242243 require .ErrorContains (t , err , "Reserved" )
243244 })
244245
245- t .Run ("MismatchedOrganizations" , func (t * testing.T ) {
246- t .Parallel ()
247- dv := coderdtest .DeploymentValues (t )
248- dv .Experiments = []string {string (codersdk .ExperimentCustomRoles )}
249- owner , first := coderdenttest .New (t , & coderdenttest.Options {
250- Options : & coderdtest.Options {
251- DeploymentValues : dv ,
252- },
253- LicenseOptions : & coderdenttest.LicenseOptions {
254- Features : license.Features {
255- codersdk .FeatureCustomRoles : 1 ,
256- },
257- },
258- })
259-
260- ctx := testutil .Context (t , testutil .WaitMedium )
261-
262- //nolint:gocritic // owner is required for this
263- _ , err := owner .PatchOrganizationRole (ctx , first .OrganizationID , templateAdminCustom (uuid .New ()))
264- require .ErrorContains (t , err , "does not match" )
265- })
266-
267246 // Attempt to add site & user permissions, which is not allowed
268247 t .Run ("ExcessPermissions" , func (t * testing.T ) {
269248 t .Parallel ()
@@ -291,7 +270,7 @@ func TestCustomOrganizationRole(t *testing.T) {
291270 }
292271
293272 //nolint:gocritic // owner is required for this
294- _ , err := owner .PatchOrganizationRole (ctx , first . OrganizationID , siteRole )
273+ _ , err := owner .PatchOrganizationRole (ctx , siteRole )
295274 require .ErrorContains (t , err , "site wide permissions" )
296275
297276 userRole := templateAdminCustom (first .OrganizationID )
@@ -303,11 +282,11 @@ func TestCustomOrganizationRole(t *testing.T) {
303282 }
304283
305284 //nolint:gocritic // owner is required for this
306- _ , err = owner .PatchOrganizationRole (ctx , first . OrganizationID , userRole )
285+ _ , err = owner .PatchOrganizationRole (ctx , userRole )
307286 require .ErrorContains (t , err , "not allowed to assign user permissions" )
308287 })
309288
310- t .Run ("InvalidUUID " , func (t * testing.T ) {
289+ t .Run ("NotFound " , func (t * testing.T ) {
311290 t .Parallel ()
312291 dv := coderdtest .DeploymentValues (t )
313292 dv .Experiments = []string {string (codersdk .ExperimentCustomRoles )}
@@ -328,8 +307,8 @@ func TestCustomOrganizationRole(t *testing.T) {
328307 newRole .OrganizationID = "0000" // This is not a valid uuid
329308
330309 //nolint:gocritic // owner is required for this
331- _ , err := owner .PatchOrganizationRole (ctx , first . OrganizationID , newRole )
332- require .ErrorContains (t , err , "Invalid request " )
310+ _ , err := owner .PatchOrganizationRole (ctx , newRole )
311+ require .ErrorContains (t , err , "Resource not found " )
333312 })
334313}
335314
0 commit comments