@@ -96,6 +96,10 @@ func TestAuthorizeAllEndpoints(t *testing.T) {
96
96
require .NoError (t , err , "upload file" )
97
97
workspaceResources , err := client .WorkspaceResourcesByBuild (ctx , workspace .LatestBuild .ID )
98
98
require .NoError (t , err , "workspace resources" )
99
+ templateVersionDryRun , err := client .CreateTemplateVersionDryRun (ctx , version .ID , codersdk.CreateTemplateVersionDryRunRequest {
100
+ ParameterValues : []codersdk.CreateParameterRequest {},
101
+ })
102
+ require .NoError (t , err , "template version dry-run" )
99
103
100
104
// Always fail auth from this point forward
101
105
authorizer .AlwaysReturn = rbac .ForbiddenWithInternal (xerrors .New ("fake implementation" ), nil , nil )
@@ -262,6 +266,27 @@ func TestAuthorizeAllEndpoints(t *testing.T) {
262
266
AssertAction : rbac .ActionRead ,
263
267
AssertObject : rbac .ResourceTemplate .InOrg (template .OrganizationID ).WithID (template .ID .String ()),
264
268
},
269
+ "POST:/api/v2/templateversions/{templateversion}/dry-run" : {
270
+ // The first check is to read the template
271
+ AssertAction : rbac .ActionRead ,
272
+ AssertObject : rbac .ResourceTemplate .InOrg (version .OrganizationID ).WithID (template .ID .String ()),
273
+ },
274
+ "GET:/api/v2/templateversions/{templateversion}/dry-run/{templateversiondryrun}" : {
275
+ AssertAction : rbac .ActionRead ,
276
+ AssertObject : rbac .ResourceTemplate .InOrg (version .OrganizationID ).WithID (template .ID .String ()),
277
+ },
278
+ "GET:/api/v2/templateversions/{templateversion}/dry-run/{templateversiondryrun}/resources" : {
279
+ AssertAction : rbac .ActionRead ,
280
+ AssertObject : rbac .ResourceTemplate .InOrg (version .OrganizationID ).WithID (template .ID .String ()),
281
+ },
282
+ "GET:/api/v2/templateversions/{templateversion}/dry-run/{templateversiondryrun}/logs" : {
283
+ AssertAction : rbac .ActionRead ,
284
+ AssertObject : rbac .ResourceTemplate .InOrg (version .OrganizationID ).WithID (template .ID .String ()),
285
+ },
286
+ "PATCH:/api/v2/templateversions/{templateversion}/dry-run/{templateversiondryrun}/cancel" : {
287
+ AssertAction : rbac .ActionRead ,
288
+ AssertObject : rbac .ResourceTemplate .InOrg (version .OrganizationID ).WithID (template .ID .String ()),
289
+ },
265
290
"GET:/api/v2/provisionerdaemons" : {
266
291
StatusCode : http .StatusOK ,
267
292
AssertObject : rbac .ResourceProvisionerDaemon .WithID (provisionerds [0 ].ID .String ()),
@@ -350,6 +375,7 @@ func TestAuthorizeAllEndpoints(t *testing.T) {
350
375
route = strings .ReplaceAll (route , "{hash}" , file .Hash )
351
376
route = strings .ReplaceAll (route , "{workspaceresource}" , workspaceResources [0 ].ID .String ())
352
377
route = strings .ReplaceAll (route , "{templateversion}" , version .ID .String ())
378
+ route = strings .ReplaceAll (route , "{templateversiondryrun}" , templateVersionDryRun .ID .String ())
353
379
route = strings .ReplaceAll (route , "{templatename}" , template .Name )
354
380
// Only checking org scoped params here
355
381
route = strings .ReplaceAll (route , "{scope}" , string (organizationParam .Scope ))
0 commit comments