teams: removed feature toggle as it is already in middleware
This commit is contained in:
@@ -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)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user