@@ -100,8 +100,6 @@ func TestAuthorizeAllEndpoints(t *testing.T) {
100100
101101 "PUT:/api/v2/organizations/{organization}/members/{user}/roles" : {NoAuthorize : true },
102102 "GET:/api/v2/organizations/{organization}/provisionerdaemons" : {NoAuthorize : true },
103- "POST:/api/v2/organizations/{organization}/templates" : {NoAuthorize : true },
104- "GET:/api/v2/organizations/{organization}/templates" : {NoAuthorize : true },
105103 "GET:/api/v2/organizations/{organization}/templates/{templatename}" : {NoAuthorize : true },
106104 "POST:/api/v2/organizations/{organization}/templateversions" : {NoAuthorize : true },
107105 "POST:/api/v2/organizations/{organization}/workspaces" : {NoAuthorize : true },
@@ -110,8 +108,6 @@ func TestAuthorizeAllEndpoints(t *testing.T) {
110108 "GET:/api/v2/parameters/{scope}/{id}" : {NoAuthorize : true },
111109 "DELETE:/api/v2/parameters/{scope}/{id}/{name}" : {NoAuthorize : true },
112110
113- "DELETE:/api/v2/templates/{template}" : {NoAuthorize : true },
114- "GET:/api/v2/templates/{template}" : {NoAuthorize : true },
115111 "GET:/api/v2/templates/{template}/versions" : {NoAuthorize : true },
116112 "PATCH:/api/v2/templates/{template}/versions" : {NoAuthorize : true },
117113 "GET:/api/v2/templates/{template}/versions/{templateversionname}" : {NoAuthorize : true },
@@ -185,7 +181,23 @@ func TestAuthorizeAllEndpoints(t *testing.T) {
185181 AssertAction : rbac .ActionRead ,
186182 AssertObject : workspaceRBACObj ,
187183 },
188-
184+ "GET:/api/v2/organizations/{organization}/templates" : {
185+ StatusCode : http .StatusOK ,
186+ AssertAction : rbac .ActionRead ,
187+ AssertObject : rbac .ResourceTemplate .InOrg (template .OrganizationID ).WithID (template .ID .String ()),
188+ },
189+ "POST:/api/v2/organizations/{organization}/templates" : {
190+ AssertAction : rbac .ActionCreate ,
191+ AssertObject : rbac .ResourceTemplate .InOrg (organization .ID ),
192+ },
193+ "DELETE:/api/v2/templates/{template}" : {
194+ AssertAction : rbac .ActionDelete ,
195+ AssertObject : rbac .ResourceTemplate .InOrg (template .OrganizationID ).WithID (template .ID .String ()),
196+ },
197+ "GET:/api/v2/templates/{template}" : {
198+ AssertAction : rbac .ActionRead ,
199+ AssertObject : rbac .ResourceTemplate .InOrg (template .OrganizationID ).WithID (template .ID .String ()),
200+ },
189201 "POST:/api/v2/files" : {AssertAction : rbac .ActionCreate , AssertObject : rbac .ResourceFile },
190202 "GET:/api/v2/files/{fileHash}" : {AssertAction : rbac .ActionRead ,
191203 AssertObject : rbac .ResourceFile .WithOwner (admin .UserID .String ()).WithID (file .Hash )},
@@ -226,6 +238,7 @@ func TestAuthorizeAllEndpoints(t *testing.T) {
226238 route = strings .ReplaceAll (route , "{workspacebuild}" , workspace .LatestBuild .ID .String ())
227239 route = strings .ReplaceAll (route , "{workspacename}" , workspace .Name )
228240 route = strings .ReplaceAll (route , "{workspacebuildname}" , workspace .LatestBuild .Name )
241+ route = strings .ReplaceAll (route , "{template}" , template .ID .String ())
229242 route = strings .ReplaceAll (route , "{hash}" , file .Hash )
230243
231244 resp , err := client .Request (context .Background (), method , route , nil )
0 commit comments