summaryrefslogtreecommitdiffstats
path: root/api/team_test.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2018-02-12 18:36:39 -0600
committerGitHub <noreply@github.com>2018-02-12 18:36:39 -0600
commitfbef16f8630f74248157c2cd9e546ece355c869a (patch)
tree95feb1a0b94f43fd38533adc508df2daf823ea86 /api/team_test.go
parent56f49cf4860cfca51e852ec3e7d9df772d2b2060 (diff)
parent32c1f7be239ddb19d6c59b114d9ae1a543f8ba9c (diff)
downloadchat-fbef16f8630f74248157c2cd9e546ece355c869a.tar.gz
chat-fbef16f8630f74248157c2cd9e546ece355c869a.tar.bz2
chat-fbef16f8630f74248157c2cd9e546ece355c869a.zip
Merge branch 'release-4.7' into rm-willnorris-proxy-support
Diffstat (limited to 'api/team_test.go')
-rw-r--r--api/team_test.go42
1 files changed, 39 insertions, 3 deletions
diff --git a/api/team_test.go b/api/team_test.go
index 696cf31bb..b1c892544 100644
--- a/api/team_test.go
+++ b/api/team_test.go
@@ -139,8 +139,20 @@ func TestAddUserToTeam(t *testing.T) {
t.Fatal(err)
}
+ // Restore config/license at end of test case.
+ restrictTeamInvite := *th.App.Config().TeamSettings.RestrictTeamInvite
+ isLicensed := utils.IsLicensed()
+ license := utils.License()
+ defer func() {
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.RestrictTeamInvite = restrictTeamInvite })
+ utils.SetIsLicensed(isLicensed)
+ utils.SetLicense(license)
+ th.App.SetDefaultRolesBasedOnConfig()
+ }()
+
// Set the config so that only team admins can add a user to a team.
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.RestrictTeamInvite = model.PERMISSIONS_TEAM_ADMIN })
+ th.App.SetDefaultRolesBasedOnConfig()
// Test without the EE license to see that the permission restriction is ignored.
user3 := th.CreateUser(th.BasicClient)
@@ -149,7 +161,10 @@ func TestAddUserToTeam(t *testing.T) {
}
// Add an EE license.
- th.App.SetLicense(model.NewTestLicense())
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
+ th.App.SetDefaultRolesBasedOnConfig()
// Check that a regular user can't add someone to the team.
user4 := th.CreateUser(th.BasicClient)
@@ -160,8 +175,11 @@ func TestAddUserToTeam(t *testing.T) {
// Should work as team admin.
th.UpdateUserToTeamAdmin(th.BasicUser, th.BasicTeam)
th.App.InvalidateAllCaches()
- th.App.SetLicense(model.NewTestLicense())
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.RestrictTeamInvite = model.PERMISSIONS_TEAM_ADMIN })
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
+ th.App.SetDefaultRolesBasedOnConfig()
user5 := th.CreateUser(th.BasicClient)
if _, err := th.BasicClient.AddUserToTeam(th.BasicTeam.Id, user5.Id); err != nil {
@@ -170,6 +188,7 @@ func TestAddUserToTeam(t *testing.T) {
// Change permission level to System Admin
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.RestrictTeamInvite = model.PERMISSIONS_SYSTEM_ADMIN })
+ th.App.SetDefaultRolesBasedOnConfig()
// Should not work as team admin.
user6 := th.CreateUser(th.BasicClient)
@@ -546,7 +565,13 @@ func TestInviteMembers(t *testing.T) {
t.Fatal("Should have errored out on no invites to send")
}
+ restrictTeamInvite := *th.App.Config().TeamSettings.RestrictTeamInvite
+ defer func() {
+ th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.RestrictTeamInvite = restrictTeamInvite })
+ th.App.SetDefaultRolesBasedOnConfig()
+ }()
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.RestrictTeamInvite = model.PERMISSIONS_TEAM_ADMIN })
+ th.App.SetDefaultRolesBasedOnConfig()
th.LoginBasic2()
th.LinkUserToTeam(th.BasicUser2, team)
@@ -555,7 +580,17 @@ func TestInviteMembers(t *testing.T) {
t.Fatal(err)
}
- th.App.SetLicense(model.NewTestLicense())
+ isLicensed := utils.IsLicensed()
+ license := utils.License()
+ defer func() {
+ utils.SetIsLicensed(isLicensed)
+ utils.SetLicense(license)
+ th.App.SetDefaultRolesBasedOnConfig()
+ }()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
+ th.App.SetDefaultRolesBasedOnConfig()
if _, err := Client.InviteMembers(invites); err == nil {
t.Fatal("should have errored not team admin and licensed")
@@ -571,6 +606,7 @@ func TestInviteMembers(t *testing.T) {
}
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.RestrictTeamInvite = model.PERMISSIONS_SYSTEM_ADMIN })
+ th.App.SetDefaultRolesBasedOnConfig()
if _, err := Client.InviteMembers(invites); err == nil {
t.Fatal("should have errored not system admin and licensed")