summaryrefslogtreecommitdiffstats
path: root/api4
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2017-08-16 09:51:45 -0700
committerChristopher Speller <crspeller@gmail.com>2017-08-16 09:51:45 -0700
commit0ab490845aed0ce3b58cbffd8ec35be237abda1c (patch)
tree5310cce7e546f5a03f97245af473b62d382028e8 /api4
parent32265df8be5d530f5b79284792afb9451464ad3a (diff)
downloadchat-0ab490845aed0ce3b58cbffd8ec35be237abda1c.tar.gz
chat-0ab490845aed0ce3b58cbffd8ec35be237abda1c.tar.bz2
chat-0ab490845aed0ce3b58cbffd8ec35be237abda1c.zip
PLT-6226 Fixing races with licensing (#7213)
* PLT-6226 Fixing races with licensing * Fixing build issue * Fixing licensing issue * removing commented code
Diffstat (limited to 'api4')
-rw-r--r--api4/apitestlib.go2
-rw-r--r--api4/channel_test.go144
-rw-r--r--api4/context.go4
-rw-r--r--api4/post_test.go28
-rw-r--r--api4/system.go2
-rw-r--r--api4/team_test.go56
-rw-r--r--api4/user.go2
-rw-r--r--api4/user_test.go30
8 files changed, 134 insertions, 134 deletions
diff --git a/api4/apitestlib.go b/api4/apitestlib.go
index 7f69b3690..b10e639e3 100644
--- a/api4/apitestlib.go
+++ b/api4/apitestlib.go
@@ -55,7 +55,7 @@ func SetupEnterprise() *TestHelper {
utils.Cfg.EmailSettings.SMTPPort = "2500"
utils.Cfg.EmailSettings.FeedbackEmail = "test@example.com"
utils.DisableDebugLogForTest()
- utils.License.Features.SetDefaults()
+ utils.License().Features.SetDefaults()
app.NewServer()
app.InitStores()
InitRouter()
diff --git a/api4/channel_test.go b/api4/channel_test.go
index 5cc770332..1747d79b9 100644
--- a/api4/channel_test.go
+++ b/api4/channel_test.go
@@ -82,22 +82,22 @@ func TestCreateChannel(t *testing.T) {
th.LoginBasic()
// Check permissions with policy config changes
- isLicensed := utils.IsLicensed
- license := utils.License
+ isLicensed := utils.IsLicensed()
+ license := utils.License()
restrictPublicChannel := *utils.Cfg.TeamSettings.RestrictPublicChannelCreation
restrictPrivateChannel := *utils.Cfg.TeamSettings.RestrictPrivateChannelCreation
defer func() {
*utils.Cfg.TeamSettings.RestrictPublicChannelCreation = restrictPublicChannel
*utils.Cfg.TeamSettings.RestrictPrivateChannelCreation = restrictPrivateChannel
- utils.IsLicensed = isLicensed
- utils.License = license
+ utils.SetIsLicensed(isLicensed)
+ utils.SetLicense(license)
utils.SetDefaultRolesBasedOnConfig()
}()
*utils.Cfg.TeamSettings.RestrictPublicChannelCreation = model.PERMISSIONS_ALL
*utils.Cfg.TeamSettings.RestrictPrivateChannelCreation = model.PERMISSIONS_ALL
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
utils.SetDefaultRolesBasedOnConfig()
channel.Name = GenerateTestChannelName()
@@ -165,8 +165,8 @@ func TestCreateChannel(t *testing.T) {
CheckNoError(t, resp)
// Check that if unlicensed the policy restriction is not enforced.
- utils.IsLicensed = false
- utils.License = nil
+ utils.SetIsLicensed(false)
+ utils.SetLicense(nil)
utils.SetDefaultRolesBasedOnConfig()
channel.Name = GenerateTestChannelName()
@@ -879,22 +879,22 @@ func TestDeleteChannel(t *testing.T) {
_, resp = th.SystemAdminClient.DeleteChannel(publicChannel5.Id)
CheckNoError(t, resp)
- isLicensed := utils.IsLicensed
- license := utils.License
+ isLicensed := utils.IsLicensed()
+ license := utils.License()
restrictPublicChannel := *utils.Cfg.TeamSettings.RestrictPublicChannelManagement
restrictPrivateChannel := *utils.Cfg.TeamSettings.RestrictPrivateChannelManagement
defer func() {
*utils.Cfg.TeamSettings.RestrictPublicChannelManagement = restrictPublicChannel
*utils.Cfg.TeamSettings.RestrictPrivateChannelManagement = restrictPrivateChannel
- utils.IsLicensed = isLicensed
- utils.License = license
+ utils.SetIsLicensed(isLicensed)
+ utils.SetLicense(license)
utils.SetDefaultRolesBasedOnConfig()
}()
*utils.Cfg.TeamSettings.RestrictPublicChannelManagement = model.PERMISSIONS_ALL
*utils.Cfg.TeamSettings.RestrictPrivateChannelManagement = model.PERMISSIONS_ALL
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
utils.SetDefaultRolesBasedOnConfig()
th = Setup().InitBasic().InitSystemAdmin()
@@ -956,9 +956,9 @@ func TestDeleteChannel(t *testing.T) {
// successful delete by team admin
UpdateUserToTeamAdmin(user, team)
app.InvalidateAllCaches()
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
_, resp = Client.DeleteChannel(publicChannel6.Id)
CheckNoError(t, resp)
@@ -971,9 +971,9 @@ func TestDeleteChannel(t *testing.T) {
utils.SetDefaultRolesBasedOnConfig()
UpdateUserToNonTeamAdmin(user, team)
app.InvalidateAllCaches()
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
// channels created by SystemAdmin
publicChannel6 = th.CreateChannelWithClient(th.SystemAdminClient, model.CHANNEL_OPEN)
@@ -1003,9 +1003,9 @@ func TestDeleteChannel(t *testing.T) {
// successful delete by team admin
UpdateUserToTeamAdmin(th.BasicUser, team)
app.InvalidateAllCaches()
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
_, resp = Client.DeleteChannel(publicChannel6.Id)
CheckNoError(t, resp)
@@ -1045,9 +1045,9 @@ func TestDeleteChannel(t *testing.T) {
// cannot delete by team admin
UpdateUserToTeamAdmin(th.BasicUser, team)
app.InvalidateAllCaches()
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
_, resp = Client.DeleteChannel(publicChannel6.Id)
CheckForbiddenStatus(t, resp)
@@ -1796,17 +1796,17 @@ func TestAddChannelMember(t *testing.T) {
Client.Logout()
// Add a license
- isLicensed := utils.IsLicensed
- license := utils.License
+ isLicensed := utils.IsLicensed()
+ license := utils.License()
defer func() {
- utils.IsLicensed = isLicensed
- utils.License = license
+ utils.SetIsLicensed(isLicensed)
+ utils.SetLicense(license)
utils.SetDefaultRolesBasedOnConfig()
}()
*utils.Cfg.TeamSettings.RestrictPrivateChannelManageMembers = model.PERMISSIONS_ALL
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
utils.SetDefaultRolesBasedOnConfig()
// Check that a regular channel user can add other users.
@@ -1823,9 +1823,9 @@ func TestAddChannelMember(t *testing.T) {
// Test with CHANNEL_ADMIN level permission.
*utils.Cfg.TeamSettings.RestrictPrivateChannelManageMembers = model.PERMISSIONS_CHANNEL_ADMIN
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
utils.SetDefaultRolesBasedOnConfig()
Client.Login(user2.Username, user2.Password)
@@ -1841,9 +1841,9 @@ func TestAddChannelMember(t *testing.T) {
MakeUserChannelAdmin(user, privateChannel)
app.InvalidateAllCaches()
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
utils.SetDefaultRolesBasedOnConfig()
Client.Login(user.Username, user.Password)
@@ -1853,9 +1853,9 @@ func TestAddChannelMember(t *testing.T) {
// Test with TEAM_ADMIN level permission.
*utils.Cfg.TeamSettings.RestrictPrivateChannelManageMembers = model.PERMISSIONS_TEAM_ADMIN
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
utils.SetDefaultRolesBasedOnConfig()
Client.Login(user2.Username, user2.Password)
@@ -1871,9 +1871,9 @@ func TestAddChannelMember(t *testing.T) {
UpdateUserToTeamAdmin(user, team)
app.InvalidateAllCaches()
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
utils.SetDefaultRolesBasedOnConfig()
Client.Login(user.Username, user.Password)
@@ -1883,9 +1883,9 @@ func TestAddChannelMember(t *testing.T) {
// Test with SYSTEM_ADMIN level permission.
*utils.Cfg.TeamSettings.RestrictPrivateChannelManageMembers = model.PERMISSIONS_SYSTEM_ADMIN
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
utils.SetDefaultRolesBasedOnConfig()
Client.Login(user2.Username, user2.Password)
@@ -1980,17 +1980,17 @@ func TestRemoveChannelMember(t *testing.T) {
CheckNoError(t, resp)
// Add a license
- isLicensed := utils.IsLicensed
- license := utils.License
+ isLicensed := utils.IsLicensed()
+ license := utils.License()
defer func() {
- utils.IsLicensed = isLicensed
- utils.License = license
+ utils.SetIsLicensed(isLicensed)
+ utils.SetLicense(license)
utils.SetDefaultRolesBasedOnConfig()
}()
*utils.Cfg.TeamSettings.RestrictPrivateChannelManageMembers = model.PERMISSIONS_ALL
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
utils.SetDefaultRolesBasedOnConfig()
// Check that a regular channel user can remove other users.
@@ -2005,9 +2005,9 @@ func TestRemoveChannelMember(t *testing.T) {
// Test with CHANNEL_ADMIN level permission.
*utils.Cfg.TeamSettings.RestrictPrivateChannelManageMembers = model.PERMISSIONS_CHANNEL_ADMIN
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
utils.SetDefaultRolesBasedOnConfig()
privateChannel = th.CreateChannelWithClient(th.SystemAdminClient, model.CHANNEL_PRIVATE)
@@ -2021,18 +2021,18 @@ func TestRemoveChannelMember(t *testing.T) {
MakeUserChannelAdmin(user1, privateChannel)
app.InvalidateAllCaches()
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
_, resp = Client.RemoveUserFromChannel(privateChannel.Id, user2.Id)
CheckNoError(t, resp)
// Test with TEAM_ADMIN level permission.
*utils.Cfg.TeamSettings.RestrictPrivateChannelManageMembers = model.PERMISSIONS_TEAM_ADMIN
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
utils.SetDefaultRolesBasedOnConfig()
privateChannel = th.CreateChannelWithClient(th.SystemAdminClient, model.CHANNEL_PRIVATE)
@@ -2046,18 +2046,18 @@ func TestRemoveChannelMember(t *testing.T) {
UpdateUserToTeamAdmin(user1, team)
app.InvalidateAllCaches()
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
_, resp = Client.RemoveUserFromChannel(privateChannel.Id, user2.Id)
CheckNoError(t, resp)
// Test with SYSTEM_ADMIN level permission.
*utils.Cfg.TeamSettings.RestrictPrivateChannelManageMembers = model.PERMISSIONS_SYSTEM_ADMIN
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
utils.SetDefaultRolesBasedOnConfig()
privateChannel = th.CreateChannelWithClient(th.SystemAdminClient, model.CHANNEL_PRIVATE)
diff --git a/api4/context.go b/api4/context.go
index d72b3593d..69351a098 100644
--- a/api4/context.go
+++ b/api4/context.go
@@ -129,7 +129,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
c.SetSiteURLHeader(app.GetProtocol(r) + "://" + r.Host)
w.Header().Set(model.HEADER_REQUEST_ID, c.RequestId)
- w.Header().Set(model.HEADER_VERSION_ID, fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, model.BuildNumber, utils.ClientCfgHash, utils.IsLicensed))
+ w.Header().Set(model.HEADER_VERSION_ID, fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, model.BuildNumber, utils.ClientCfgHash, utils.IsLicensed()))
w.Header().Set("Content-Type", "application/json")
@@ -252,7 +252,7 @@ func (c *Context) SessionRequired() {
func (c *Context) MfaRequired() {
// Must be licensed for MFA and have it configured for enforcement
- if !utils.IsLicensed || !*utils.License.Features.MFA || !*utils.Cfg.ServiceSettings.EnableMultifactorAuthentication || !*utils.Cfg.ServiceSettings.EnforceMultifactorAuthentication {
+ if !utils.IsLicensed() || !*utils.License().Features.MFA || !*utils.Cfg.ServiceSettings.EnableMultifactorAuthentication || !*utils.Cfg.ServiceSettings.EnforceMultifactorAuthentication {
return
}
diff --git a/api4/post_test.go b/api4/post_test.go
index b7ed06bd4..c09cb77d1 100644
--- a/api4/post_test.go
+++ b/api4/post_test.go
@@ -366,18 +366,18 @@ func TestUpdatePost(t *testing.T) {
Client := th.Client
channel := th.BasicChannel
- isLicensed := utils.IsLicensed
- license := utils.License
+ isLicensed := utils.IsLicensed()
+ license := utils.License()
allowEditPost := *utils.Cfg.ServiceSettings.AllowEditPost
defer func() {
- utils.IsLicensed = isLicensed
- utils.License = license
+ utils.SetIsLicensed(isLicensed)
+ utils.SetLicense(license)
*utils.Cfg.ServiceSettings.AllowEditPost = allowEditPost
utils.SetDefaultRolesBasedOnConfig()
}()
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
*utils.Cfg.ServiceSettings.AllowEditPost = model.ALLOW_EDIT_POST_ALWAYS
utils.SetDefaultRolesBasedOnConfig()
@@ -445,18 +445,18 @@ func TestPatchPost(t *testing.T) {
Client := th.Client
channel := th.BasicChannel
- isLicensed := utils.IsLicensed
- license := utils.License
+ isLicensed := utils.IsLicensed()
+ license := utils.License()
allowEditPost := *utils.Cfg.ServiceSettings.AllowEditPost
defer func() {
- utils.IsLicensed = isLicensed
- utils.License = license
+ utils.SetIsLicensed(isLicensed)
+ utils.SetLicense(license)
*utils.Cfg.ServiceSettings.AllowEditPost = allowEditPost
utils.SetDefaultRolesBasedOnConfig()
}()
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
*utils.Cfg.ServiceSettings.AllowEditPost = model.ALLOW_EDIT_POST_ALWAYS
utils.SetDefaultRolesBasedOnConfig()
diff --git a/api4/system.go b/api4/system.go
index ff3aab0d0..0c0fc7d12 100644
--- a/api4/system.go
+++ b/api4/system.go
@@ -258,7 +258,7 @@ func getClientLicense(c *Context, w http.ResponseWriter, r *http.Request) {
var clientLicense map[string]string
if app.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) {
- clientLicense = utils.ClientLicense
+ clientLicense = utils.ClientLicense()
} else {
clientLicense = utils.GetSanitizedClientLicense()
}
diff --git a/api4/team_test.go b/api4/team_test.go
index 421428afa..a498d1e04 100644
--- a/api4/team_test.go
+++ b/api4/team_test.go
@@ -826,12 +826,12 @@ func TestAddTeamMember(t *testing.T) {
// Check effects of config and license changes.
restrictTeamInvite := *utils.Cfg.TeamSettings.RestrictTeamInvite
- isLicensed := utils.IsLicensed
- license := utils.License
+ isLicensed := utils.IsLicensed()
+ license := utils.License()
defer func() {
*utils.Cfg.TeamSettings.RestrictTeamInvite = restrictTeamInvite
- utils.IsLicensed = isLicensed
- utils.License = license
+ utils.SetIsLicensed(isLicensed)
+ utils.SetLicense(license)
utils.SetDefaultRolesBasedOnConfig()
}()
@@ -845,9 +845,9 @@ func TestAddTeamMember(t *testing.T) {
CheckNoError(t, resp)
// Add an EE license.
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
utils.SetDefaultRolesBasedOnConfig()
th.LoginBasic()
@@ -859,9 +859,9 @@ func TestAddTeamMember(t *testing.T) {
UpdateUserToTeamAdmin(th.BasicUser, th.BasicTeam)
app.InvalidateAllCaches()
*utils.Cfg.TeamSettings.RestrictTeamInvite = model.PERMISSIONS_TEAM_ADMIN
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
utils.SetDefaultRolesBasedOnConfig()
th.LoginBasic()
@@ -885,9 +885,9 @@ func TestAddTeamMember(t *testing.T) {
UpdateUserToNonTeamAdmin(th.BasicUser, th.BasicTeam)
app.InvalidateAllCaches()
*utils.Cfg.TeamSettings.RestrictTeamInvite = model.PERMISSIONS_ALL
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
utils.SetDefaultRolesBasedOnConfig()
th.LoginBasic()
@@ -897,8 +897,8 @@ func TestAddTeamMember(t *testing.T) {
// Reset config and license.
*utils.Cfg.TeamSettings.RestrictTeamInvite = restrictTeamInvite
- utils.IsLicensed = isLicensed
- utils.License = license
+ utils.SetIsLicensed(isLicensed)
+ utils.SetLicense(license)
utils.SetDefaultRolesBasedOnConfig()
th.LoginBasic()
@@ -1040,12 +1040,12 @@ func TestAddTeamMembers(t *testing.T) {
// Check effects of config and license changes.
restrictTeamInvite := *utils.Cfg.TeamSettings.RestrictTeamInvite
- isLicensed := utils.IsLicensed
- license := utils.License
+ isLicensed := utils.IsLicensed()
+ license := utils.License()
defer func() {
*utils.Cfg.TeamSettings.RestrictTeamInvite = restrictTeamInvite
- utils.IsLicensed = isLicensed
- utils.License = license
+ utils.SetIsLicensed(isLicensed)
+ utils.SetLicense(license)
utils.SetDefaultRolesBasedOnConfig()
}()
@@ -1059,9 +1059,9 @@ func TestAddTeamMembers(t *testing.T) {
CheckNoError(t, resp)
// Add an EE license.
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
utils.SetDefaultRolesBasedOnConfig()
th.LoginBasic()
@@ -1073,9 +1073,9 @@ func TestAddTeamMembers(t *testing.T) {
UpdateUserToTeamAdmin(th.BasicUser, th.BasicTeam)
app.InvalidateAllCaches()
*utils.Cfg.TeamSettings.RestrictTeamInvite = model.PERMISSIONS_TEAM_ADMIN
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
utils.SetDefaultRolesBasedOnConfig()
th.LoginBasic()
@@ -1099,9 +1099,9 @@ func TestAddTeamMembers(t *testing.T) {
UpdateUserToNonTeamAdmin(th.BasicUser, th.BasicTeam)
app.InvalidateAllCaches()
*utils.Cfg.TeamSettings.RestrictTeamInvite = model.PERMISSIONS_ALL
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
utils.SetDefaultRolesBasedOnConfig()
th.LoginBasic()
diff --git a/api4/user.go b/api4/user.go
index b0192592c..365248c0f 100644
--- a/api4/user.go
+++ b/api4/user.go
@@ -675,7 +675,7 @@ func checkUserMfa(c *Context, w http.ResponseWriter, r *http.Request) {
resp := map[string]interface{}{}
resp["mfa_required"] = false
- if !utils.IsLicensed || !*utils.License.Features.MFA || !*utils.Cfg.ServiceSettings.EnableMultifactorAuthentication {
+ if !utils.IsLicensed() || !*utils.License().Features.MFA || !*utils.Cfg.ServiceSettings.EnableMultifactorAuthentication {
w.Write([]byte(model.StringInterfaceToJson(resp)))
return
}
diff --git a/api4/user_test.go b/api4/user_test.go
index 37ecd660d..894187469 100644
--- a/api4/user_test.go
+++ b/api4/user_test.go
@@ -1513,17 +1513,17 @@ func TestGetUsersNotInChannel(t *testing.T) {
defer TearDown()
Client := th.Client
- isLicensed := utils.IsLicensed
- license := utils.License
+ isLicensed := utils.IsLicensed()
+ license := utils.License()
enableMfa := *utils.Cfg.ServiceSettings.EnableMultifactorAuthentication
defer func() {
- utils.IsLicensed = isLicensed
- utils.License = license
+ utils.SetIsLicensed(isLicensed)
+ utils.SetLicense(license)
*utils.Cfg.ServiceSettings.EnableMultifactorAuthentication = enableMfa
}()
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
+ utils.IsLicensed()= true
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
team := model.Team{DisplayName: "Name", Name: "z-z-" + model.NewId() + "a", Email: "test@nowhere.com", Type: model.TEAM_OPEN}
rteam, _ := Client.CreateTeam(&team)
@@ -1574,18 +1574,18 @@ func TestCheckUserMfa(t *testing.T) {
t.Fatal("should be false - mfa not active")
}
- isLicensed := utils.IsLicensed
- license := utils.License
+ isLicensed := utils.IsLicensed()
+ license := utils.License()
enableMfa := *utils.Cfg.ServiceSettings.EnableMultifactorAuthentication
defer func() {
- utils.IsLicensed = isLicensed
- utils.License = license
+ utils.SetIsLicensed(isLicensed)
+ utils.SetLicense(license)
*utils.Cfg.ServiceSettings.EnableMultifactorAuthentication = enableMfa
}()
- utils.IsLicensed = true
- utils.License = &model.License{Features: &model.Features{}}
- utils.License.Features.SetDefaults()
- *utils.License.Features.MFA = true
+ utils.SetIsLicensed(true)
+ utils.SetLicense(&model.License{Features: &model.Features{}})
+ utils.License().Features.SetDefaults()
+ *utils.License().Features.MFA = true
*utils.Cfg.ServiceSettings.EnableMultifactorAuthentication = true
th.LoginBasic()