Fix permission grants for channel management. (#5478)

When selecting the Channel, Team & System level for channel permissions,
they must be explicitly granted to the Channel *and* the Team admins.
This commit is contained in:
George Goldberg
2017-02-21 15:47:28 +00:00
committed by Christopher Speller
parent 9646bddd21
commit 8bbe5dfb2f
2 changed files with 49 additions and 0 deletions

View File

@@ -346,6 +346,17 @@ func TestUpdateChannel(t *testing.T) {
t.Fatal("should have errored not team admin")
}
UpdateUserToTeamAdmin(th.BasicUser, team)
app.InvalidateAllCaches()
if _, err := Client.UpdateChannel(channel2); err != nil {
t.Fatal(err)
}
if _, err := Client.UpdateChannel(channel3); err != nil {
t.Fatal(err)
}
UpdateUserToNonTeamAdmin(th.BasicUser, team)
app.InvalidateAllCaches()
MakeUserChannelAdmin(th.BasicUser, channel2)
MakeUserChannelAdmin(th.BasicUser, channel3)
store.ClearChannelCaches()
@@ -1285,6 +1296,28 @@ func TestDeleteChannel(t *testing.T) {
t.Fatal(err)
}
th.LoginSystemAdmin()
channel2 = th.CreateChannel(Client, team)
channel3 = th.CreatePrivateChannel(Client, team)
Client.Must(Client.AddChannelMember(channel2.Id, th.BasicUser.Id))
Client.Must(Client.AddChannelMember(channel3.Id, th.BasicUser.Id))
UpdateUserToTeamAdmin(th.BasicUser, team)
Client.Login(th.BasicUser.Email, th.BasicUser.Password)
app.InvalidateAllCaches()
if _, err := Client.DeleteChannel(channel2.Id); err != nil {
t.Fatal(err)
}
if _, err := Client.DeleteChannel(channel3.Id); err != nil {
t.Fatal(err)
}
UpdateUserToNonTeamAdmin(th.BasicUser, team)
app.InvalidateAllCaches()
*utils.Cfg.TeamSettings.RestrictPublicChannelDeletion = model.PERMISSIONS_TEAM_ADMIN
*utils.Cfg.TeamSettings.RestrictPrivateChannelDeletion = model.PERMISSIONS_TEAM_ADMIN
utils.SetDefaultRolesBasedOnConfig()