mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
teams: removed feature toggle as it is already in middleware
This commit is contained in:
parent
d668550aa2
commit
8e7a8282c1
@ -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))
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user