@@ -27,6 +27,7 @@ func AGPLRoutes(a *AuthTester) (map[string]string, map[string]RouteCheck) {
27
27
workspaceRBACObj := rbac .ResourceWorkspace .InOrg (a .Organization .ID ).WithOwner (a .Workspace .OwnerID .String ())
28
28
workspaceExecObj := rbac .ResourceWorkspaceExecution .InOrg (a .Organization .ID ).WithOwner (a .Workspace .OwnerID .String ())
29
29
applicationConnectObj := rbac .ResourceWorkspaceApplicationConnect .InOrg (a .Organization .ID ).WithOwner (a .Workspace .OwnerID .String ())
30
+ groupObj := rbac .ResourceGroup .InOrg (a .Organization .ID )
30
31
31
32
// skipRoutes allows skipping routes from being checked.
32
33
skipRoutes := map [string ]string {
@@ -243,16 +244,29 @@ func AGPLRoutes(a *AuthTester) (map[string]string, map[string]RouteCheck) {
243
244
"GET:/api/v2/users" : {StatusCode : http .StatusOK , AssertObject : rbac .ResourceUser },
244
245
"GET:/api/v2/applications/auth-redirect" : {AssertAction : rbac .ActionCreate , AssertObject : rbac .ResourceAPIKey },
245
246
247
+ "DELETE:/api/v2/groups/{group}" : {
248
+ AssertAction : rbac .ActionDelete ,
249
+ AssertObject : groupObj ,
250
+ },
251
+ "PATCH:/api/v2/groups/{group}" : {
252
+ AssertAction : rbac .ActionUpdate ,
253
+ AssertObject : groupObj ,
254
+ },
255
+ "GET:/api/v2/groups/{group}" : {
256
+ AssertAction : rbac .ActionRead ,
257
+ AssertObject : groupObj ,
258
+ },
259
+ "GET:/api/v2/organizations/{organization}/groups/" : {
260
+ StatusCode : http .StatusOK ,
261
+ AssertAction : rbac .ActionRead ,
262
+ AssertObject : groupObj ,
263
+ },
264
+
246
265
// These endpoints need payloads to get to the auth part. Payloads will be required
247
266
"PUT:/api/v2/users/{user}/roles" : {StatusCode : http .StatusBadRequest , NoAuthorize : true },
248
267
"PUT:/api/v2/organizations/{organization}/members/{user}/roles" : {NoAuthorize : true },
249
268
"POST:/api/v2/workspaces/{workspace}/builds" : {StatusCode : http .StatusBadRequest , NoAuthorize : true },
250
269
"POST:/api/v2/organizations/{organization}/templateversions" : {StatusCode : http .StatusBadRequest , NoAuthorize : true },
251
-
252
- // TODO: @emyrk @jonayers Fix this unit test by using a valid group
253
- "DELETE:/api/v2/groups/{group}" : {StatusCode : http .StatusBadRequest , NoAuthorize : true },
254
- "PATCH:/api/v2/groups/{group}" : {StatusCode : http .StatusBadRequest , NoAuthorize : true },
255
- "GET:/api/v2/groups/{group}" : {StatusCode : http .StatusBadRequest , NoAuthorize : true },
256
270
}
257
271
258
272
// Routes like proxy routes support all HTTP methods. A helper func to expand
@@ -360,6 +374,10 @@ func NewAuthTester(ctx context.Context, t *testing.T, client *codersdk.Client, a
360
374
ParameterValues : []codersdk.CreateParameterRequest {},
361
375
})
362
376
require .NoError (t , err , "template version dry-run" )
377
+ group , err := client .CreateGroup (ctx , admin .OrganizationID , codersdk.CreateGroupRequest {
378
+ Name : "testgroup" ,
379
+ })
380
+ require .NoError (t , err , "create group" )
363
381
364
382
templateParam , err := client .CreateParameter (ctx , codersdk .ParameterTemplate , template .ID , codersdk.CreateParameterRequest {
365
383
Name : "test-param" ,
@@ -385,6 +403,7 @@ func NewAuthTester(ctx context.Context, t *testing.T, client *codersdk.Client, a
385
403
"{jobID}" : templateVersionDryRun .ID .String (),
386
404
"{templatename}" : template .Name ,
387
405
"{workspace_and_agent}" : workspace .Name + "." + workspaceResources [0 ].Agents [0 ].Name ,
406
+ "{group}" : group .ID .String (),
388
407
// Only checking template scoped params here
389
408
"parameters/{scope}/{id}" : fmt .Sprintf ("parameters/%s/%s" ,
390
409
string (templateParam .Scope ), templateParam .ScopeID .String ()),
0 commit comments