Browse Source

teams: removed feature toggle as it is already in middleware

Leonard Gram 6 years ago
parent
commit
8e7a8282c1
4 changed files with 7 additions and 19 deletions
  1. 1 1
      pkg/api/api.go
  2. 1 1
      pkg/api/team.go
  3. 1 5
      pkg/services/teams/team.go
  4. 4 12
      pkg/services/teams/teams_test.go

+ 1 - 1
pkg/api/api.go

@@ -155,7 +155,7 @@ func (hs *HTTPServer) registerRoutes() {
 		// team (admin permission required)
 		apiRoute.Group("/teams", func(teamsRoute routing.RouteRegister) {
 			teamsRoute.Post("/", bind(m.CreateTeamCommand{}), Wrap(hs.CreateTeam))
-			teamsRoute.Put("/:teamId", bind(m.UpdateTeamCommand{}), Wrap(UpdateTeam))
+			teamsRoute.Put("/:teamId", bind(m.UpdateTeamCommand{}), Wrap(hs.UpdateTeam))
 			teamsRoute.Delete("/:teamId", Wrap(DeleteTeamByID))
 			teamsRoute.Get("/:teamId/members", Wrap(GetTeamMembers))
 			teamsRoute.Post("/:teamId/members", bind(m.AddTeamMemberCommand{}), Wrap(AddTeamMember))

+ 1 - 1
pkg/api/team.go

@@ -42,7 +42,7 @@ func (hs *HTTPServer) UpdateTeam(c *m.ReqContext, cmd m.UpdateTeamCommand) Respo
 	cmd.OrgId = c.OrgId
 	cmd.Id = c.ParamsInt64(":teamId")
 
-	if err := teams.CanUpdateTeam(cmd.OrgId, cmd.Id, c.SignedInUser, hs.Cfg.EditorsCanOwn); err != nil {
+	if err := teams.CanUpdateTeam(cmd.OrgId, cmd.Id, c.SignedInUser); err != nil {
 		return Error(403, "User not allowed to update team", err)
 	}
 

+ 1 - 5
pkg/services/teams/team.go

@@ -5,15 +5,11 @@ import (
 	m "github.com/grafana/grafana/pkg/models"
 )
 
-func CanUpdateTeam(orgId int64, teamId int64, user *m.SignedInUser, editorCanOwn bool) error {
+func CanUpdateTeam(orgId int64, teamId int64, user *m.SignedInUser) error {
 	if user.OrgRole == m.ROLE_ADMIN {
 		return nil
 	}
 
-	if !editorCanOwn {
-		return m.ErrNotAllowedToUpdateTeam
-	}
-
 	if user.OrgId != orgId {
 		return m.ErrNotAllowedToUpdateTeamInDifferentOrg
 	}

+ 4 - 12
pkg/services/teams/teams_test.go

@@ -33,7 +33,7 @@ func TestUpdateTeam(t *testing.T) {
 					return nil
 				})
 
-				err := CanUpdateTeam(testTeam.OrgId, testTeam.Id, &editor, true)
+				err := CanUpdateTeam(testTeam.OrgId, testTeam.Id, &editor)
 				So(err, ShouldEqual, m.ErrNotAllowedToUpdateTeam)
 			})
 		})
@@ -50,7 +50,7 @@ func TestUpdateTeam(t *testing.T) {
 					return nil
 				})
 
-				err := CanUpdateTeam(testTeam.OrgId, testTeam.Id, &editor, true)
+				err := CanUpdateTeam(testTeam.OrgId, testTeam.Id, &editor)
 				So(err, ShouldBeNil)
 			})
 		})
@@ -72,24 +72,16 @@ func TestUpdateTeam(t *testing.T) {
 					return nil
 				})
 
-				err := CanUpdateTeam(testTeamOtherOrg.OrgId, testTeamOtherOrg.Id, &editor, true)
+				err := CanUpdateTeam(testTeamOtherOrg.OrgId, testTeamOtherOrg.Id, &editor)
 				So(err, ShouldEqual, m.ErrNotAllowedToUpdateTeamInDifferentOrg)
 			})
 		})
 
 		Convey("Given an org admin and a team", func() {
 			Convey("Should be able to update the team", func() {
-				err := CanUpdateTeam(testTeam.OrgId, testTeam.Id, &admin, true)
+				err := CanUpdateTeam(testTeam.OrgId, testTeam.Id, &admin)
 				So(err, ShouldBeNil)
 			})
 		})
-
-		Convey("Given that the editorsCanOwn feature toggle is disabled", func() {
-			Convey("Editors should not be able to update teams", func() {
-				err := CanUpdateTeam(testTeam.OrgId, testTeam.Id, &editor, false)
-
-				So(err, ShouldEqual, m.ErrNotAllowedToUpdateTeam)
-			})
-		})
 	})
 }