@@ -57,7 +57,7 @@ func TestCustomOrganizationRole(t *testing.T) {
57
57
ctx := testutil .Context (t , testutil .WaitMedium )
58
58
59
59
//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 ))
61
61
require .NoError (t , err , "upsert role" )
62
62
63
63
// Assign the custom template admin role
@@ -111,7 +111,7 @@ func TestCustomOrganizationRole(t *testing.T) {
111
111
ctx := testutil .Context (t , testutil .WaitMedium )
112
112
113
113
//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 ))
115
115
require .NoError (t , err , "upsert role" )
116
116
117
117
// Remove the license to block enterprise functionality
@@ -124,7 +124,7 @@ func TestCustomOrganizationRole(t *testing.T) {
124
124
}
125
125
126
126
// Verify functionality is lost
127
- _ , err = owner .PatchOrganizationRole (ctx , first . OrganizationID , templateAdminCustom (first .OrganizationID ))
127
+ _ , err = owner .PatchOrganizationRole (ctx , templateAdminCustom (first .OrganizationID ))
128
128
require .ErrorContains (t , err , "roles are not enabled" )
129
129
130
130
// Assign the custom template admin role
@@ -152,7 +152,7 @@ func TestCustomOrganizationRole(t *testing.T) {
152
152
153
153
ctx := testutil .Context (t , testutil .WaitMedium )
154
154
//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 ))
156
156
require .NoError (t , err , "upsert role" )
157
157
158
158
// Assign the custom template admin role
@@ -169,7 +169,7 @@ func TestCustomOrganizationRole(t *testing.T) {
169
169
newRole .SitePermissions = nil
170
170
newRole .OrganizationPermissions = nil
171
171
newRole .UserPermissions = nil
172
- _ , err = owner .PatchOrganizationRole (ctx , first . OrganizationID , newRole )
172
+ _ , err = owner .PatchOrganizationRole (ctx , newRole )
173
173
require .NoError (t , err , "upsert role with override" )
174
174
175
175
// The role should no longer have template perms
@@ -203,7 +203,7 @@ func TestCustomOrganizationRole(t *testing.T) {
203
203
ctx := testutil .Context (t , testutil .WaitMedium )
204
204
205
205
//nolint:gocritic // owner is required for this
206
- _ , err := owner .PatchOrganizationRole (ctx , first . OrganizationID , codersdk.Role {
206
+ _ , err := owner .PatchOrganizationRole (ctx , codersdk.Role {
207
207
Name : "Bad_Name" , // No underscores allowed
208
208
DisplayName : "Testing Purposes" ,
209
209
OrganizationID : first .OrganizationID .String (),
@@ -232,38 +232,17 @@ func TestCustomOrganizationRole(t *testing.T) {
232
232
ctx := testutil .Context (t , testutil .WaitMedium )
233
233
234
234
//nolint:gocritic // owner is required for this
235
- _ , err := owner .PatchOrganizationRole (ctx , first . OrganizationID , codersdk.Role {
235
+ _ , err := owner .PatchOrganizationRole (ctx , codersdk.Role {
236
236
Name : "owner" , // Reserved
237
237
DisplayName : "Testing Purposes" ,
238
+ OrganizationID : first .OrganizationID .String (),
238
239
SitePermissions : nil ,
239
240
OrganizationPermissions : nil ,
240
241
UserPermissions : nil ,
241
242
})
242
243
require .ErrorContains (t , err , "Reserved" )
243
244
})
244
245
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
-
267
246
// Attempt to add site & user permissions, which is not allowed
268
247
t .Run ("ExcessPermissions" , func (t * testing.T ) {
269
248
t .Parallel ()
@@ -291,7 +270,7 @@ func TestCustomOrganizationRole(t *testing.T) {
291
270
}
292
271
293
272
//nolint:gocritic // owner is required for this
294
- _ , err := owner .PatchOrganizationRole (ctx , first . OrganizationID , siteRole )
273
+ _ , err := owner .PatchOrganizationRole (ctx , siteRole )
295
274
require .ErrorContains (t , err , "site wide permissions" )
296
275
297
276
userRole := templateAdminCustom (first .OrganizationID )
@@ -303,11 +282,11 @@ func TestCustomOrganizationRole(t *testing.T) {
303
282
}
304
283
305
284
//nolint:gocritic // owner is required for this
306
- _ , err = owner .PatchOrganizationRole (ctx , first . OrganizationID , userRole )
285
+ _ , err = owner .PatchOrganizationRole (ctx , userRole )
307
286
require .ErrorContains (t , err , "not allowed to assign user permissions" )
308
287
})
309
288
310
- t .Run ("InvalidUUID " , func (t * testing.T ) {
289
+ t .Run ("NotFound " , func (t * testing.T ) {
311
290
t .Parallel ()
312
291
dv := coderdtest .DeploymentValues (t )
313
292
dv .Experiments = []string {string (codersdk .ExperimentCustomRoles )}
@@ -328,8 +307,8 @@ func TestCustomOrganizationRole(t *testing.T) {
328
307
newRole .OrganizationID = "0000" // This is not a valid uuid
329
308
330
309
//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 " )
333
312
})
334
313
}
335
314
0 commit comments