Skip to content

Commit f1cea7f

Browse files
authored
fix: UpdateProject operation to authz (#1281)
* fix: UpdateProject operation to authz * tests: authz update project roles
1 parent 104895b commit f1cea7f

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

api/server/v1/tx.go

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const (
5858
ListProjectsMethodName = apiMethodPrefix + "ListProjects"
5959
ListCollectionsMethodName = apiMethodPrefix + "ListCollections"
6060
CreateProjectMethodName = apiMethodPrefix + "CreateProject"
61+
UpdateProjectMethodName = apiMethodPrefix + "UpdateProject"
6162

6263
DeleteProjectMethodName = apiMethodPrefix + "DeleteProject"
6364
DescribeDatabaseMethodName = apiMethodPrefix + "DescribeDatabase"

server/middleware/authz.go

+3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ var (
102102
api.ListProjectsMethodName,
103103
api.ListCollectionsMethodName,
104104
api.CreateProjectMethodName,
105+
api.UpdateProjectMethodName,
105106
api.DeleteProjectMethodName,
106107
api.DescribeDatabaseMethodName,
107108
api.DescribeCollectionMethodName,
@@ -194,6 +195,7 @@ var (
194195
api.ListProjectsMethodName,
195196
api.ListCollectionsMethodName,
196197
api.CreateProjectMethodName,
198+
api.UpdateProjectMethodName,
197199
api.DeleteProjectMethodName,
198200
api.DescribeDatabaseMethodName,
199201
api.DescribeCollectionMethodName,
@@ -293,6 +295,7 @@ var (
293295
api.ListProjectsMethodName,
294296
api.ListCollectionsMethodName,
295297
api.CreateProjectMethodName,
298+
api.UpdateProjectMethodName,
296299
api.DeleteProjectMethodName,
297300
api.DescribeDatabaseMethodName,
298301
api.DescribeCollectionMethodName,

server/middleware/authz_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func TestAuthzOwnerRole(t *testing.T) {
4040
require.True(t, isAuthorizedOperation(api.CreateOrUpdateCollectionsMethodName, auth.OwnerRoleName))
4141
require.True(t, isAuthorizedOperation(api.DropCollectionMethodName, auth.OwnerRoleName))
4242
require.True(t, isAuthorizedOperation(api.ListProjectsMethodName, auth.OwnerRoleName))
43+
require.True(t, isAuthorizedOperation(api.UpdateProjectMethodName, auth.OwnerRoleName))
4344
require.True(t, isAuthorizedOperation(api.ListCollectionsMethodName, auth.OwnerRoleName))
4445
require.True(t, isAuthorizedOperation(api.CreateProjectMethodName, auth.OwnerRoleName))
4546
require.True(t, isAuthorizedOperation(api.DeleteProjectMethodName, auth.OwnerRoleName))
@@ -149,6 +150,7 @@ func TestAuthzEditorRole(t *testing.T) {
149150
require.True(t, isAuthorizedOperation(api.ListProjectsMethodName, auth.EditorRoleName))
150151
require.True(t, isAuthorizedOperation(api.ListCollectionsMethodName, auth.EditorRoleName))
151152
require.True(t, isAuthorizedOperation(api.CreateProjectMethodName, auth.EditorRoleName))
153+
require.True(t, isAuthorizedOperation(api.UpdateProjectMethodName, auth.EditorRoleName))
152154
require.True(t, isAuthorizedOperation(api.DeleteProjectMethodName, auth.EditorRoleName))
153155
require.True(t, isAuthorizedOperation(api.DescribeDatabaseMethodName, auth.EditorRoleName))
154156
require.True(t, isAuthorizedOperation(api.DescribeCollectionMethodName, auth.EditorRoleName))
@@ -285,6 +287,7 @@ func TestAuthzReadOnlyRole(t *testing.T) {
285287
require.False(t, isAuthorizedOperation(api.UpdateMethodName, auth.ReadOnlyRoleName))
286288
require.False(t, isAuthorizedOperation(api.DeleteMethodName, auth.ReadOnlyRoleName))
287289
require.False(t, isAuthorizedOperation(api.CreateProjectMethodName, auth.ReadOnlyRoleName))
290+
require.False(t, isAuthorizedOperation(api.UpdateProjectMethodName, auth.ReadOnlyRoleName))
288291
require.False(t, isAuthorizedOperation(api.CreateOrUpdateCollectionMethodName, auth.ReadOnlyRoleName))
289292
require.False(t, isAuthorizedOperation(api.CreateOrUpdateCollectionsMethodName, auth.ReadOnlyRoleName))
290293
require.False(t, isAuthorizedOperation(api.DeleteProjectMethodName, auth.ReadOnlyRoleName))

0 commit comments

Comments
 (0)