PLT-6226 Fixing races with licensing (#7213)
* PLT-6226 Fixing races with licensing * Fixing build issue * Fixing licensing issue * removing commented code
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
32265df8be
Коммит
0ab490845a
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Ссылка в новой задаче
Block a user