Restore config after finisht the test case (#9085)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
7c08ff9986
Коммит
7ed712f938
@@ -163,6 +163,11 @@ func TestLoadTestHelpCommands(t *testing.T) {
|
|||||||
Client := th.Client
|
Client := th.Client
|
||||||
channel := th.BasicChannel
|
channel := th.BasicChannel
|
||||||
|
|
||||||
|
enableTesting := th.App.Config().ServiceSettings.EnableTesting
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = enableTesting })
|
||||||
|
}()
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
|
||||||
|
|
||||||
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test help")).(*model.CommandResponse)
|
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test help")).(*model.CommandResponse)
|
||||||
@@ -180,6 +185,11 @@ func TestLoadTestSetupCommands(t *testing.T) {
|
|||||||
Client := th.Client
|
Client := th.Client
|
||||||
channel := th.BasicChannel
|
channel := th.BasicChannel
|
||||||
|
|
||||||
|
enableTesting := th.App.Config().ServiceSettings.EnableTesting
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = enableTesting })
|
||||||
|
}()
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
|
||||||
|
|
||||||
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test setup fuzz 1 1 1")).(*model.CommandResponse)
|
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test setup fuzz 1 1 1")).(*model.CommandResponse)
|
||||||
@@ -197,6 +207,11 @@ func TestLoadTestUsersCommands(t *testing.T) {
|
|||||||
Client := th.Client
|
Client := th.Client
|
||||||
channel := th.BasicChannel
|
channel := th.BasicChannel
|
||||||
|
|
||||||
|
enableTesting := th.App.Config().ServiceSettings.EnableTesting
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = enableTesting })
|
||||||
|
}()
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
|
||||||
|
|
||||||
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test users fuzz 1 2")).(*model.CommandResponse)
|
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test users fuzz 1 2")).(*model.CommandResponse)
|
||||||
@@ -214,6 +229,11 @@ func TestLoadTestChannelsCommands(t *testing.T) {
|
|||||||
Client := th.Client
|
Client := th.Client
|
||||||
channel := th.BasicChannel
|
channel := th.BasicChannel
|
||||||
|
|
||||||
|
enableTesting := th.App.Config().ServiceSettings.EnableTesting
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = enableTesting })
|
||||||
|
}()
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
|
||||||
|
|
||||||
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test channels fuzz 1 2")).(*model.CommandResponse)
|
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test channels fuzz 1 2")).(*model.CommandResponse)
|
||||||
@@ -231,6 +251,11 @@ func TestLoadTestPostsCommands(t *testing.T) {
|
|||||||
Client := th.Client
|
Client := th.Client
|
||||||
channel := th.BasicChannel
|
channel := th.BasicChannel
|
||||||
|
|
||||||
|
enableTesting := th.App.Config().ServiceSettings.EnableTesting
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = enableTesting })
|
||||||
|
}()
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableTesting = true })
|
||||||
|
|
||||||
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test posts fuzz 2 3 2")).(*model.CommandResponse)
|
rs := Client.Must(Client.ExecuteCommand(channel.Id, "/test posts fuzz 2 3 2")).(*model.CommandResponse)
|
||||||
|
|||||||
@@ -28,6 +28,15 @@ func TestGetImage(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
r.Header.Set(model.HEADER_AUTH, th.Client.AuthType+" "+th.Client.AuthToken)
|
r.Header.Set(model.HEADER_AUTH, th.Client.AuthType+" "+th.Client.AuthToken)
|
||||||
|
|
||||||
|
imageProxyType := th.App.Config().ServiceSettings.ImageProxyType
|
||||||
|
imageProxyOptions := th.App.Config().ServiceSettings.ImageProxyOptions
|
||||||
|
imageProxyURL := th.App.Config().ServiceSettings.ImageProxyURL
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.ImageProxyType = imageProxyType })
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.ImageProxyOptions = imageProxyOptions })
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.ImageProxyOptions = imageProxyURL })
|
||||||
|
}()
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||||
cfg.ServiceSettings.ImageProxyType = nil
|
cfg.ServiceSettings.ImageProxyType = nil
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -26,8 +26,10 @@ func TestCreateOAuthApp(t *testing.T) {
|
|||||||
AdminClient := th.SystemAdminClient
|
AdminClient := th.SystemAdminClient
|
||||||
|
|
||||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||||
|
enableOAuthServiceProvider := th.App.Config().ServiceSettings.EnableOAuthServiceProvider
|
||||||
defer func() {
|
defer func() {
|
||||||
th.RestoreDefaultRolePermissions(defaultRolePermissions)
|
th.RestoreDefaultRolePermissions(defaultRolePermissions)
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = enableOAuthServiceProvider })
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Grant permission to regular users.
|
// Grant permission to regular users.
|
||||||
@@ -97,8 +99,10 @@ func TestUpdateOAuthApp(t *testing.T) {
|
|||||||
AdminClient := th.SystemAdminClient
|
AdminClient := th.SystemAdminClient
|
||||||
|
|
||||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||||
|
enableOAuthServiceProvider := th.App.Config().ServiceSettings.EnableOAuthServiceProvider
|
||||||
defer func() {
|
defer func() {
|
||||||
th.RestoreDefaultRolePermissions(defaultRolePermissions)
|
th.RestoreDefaultRolePermissions(defaultRolePermissions)
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = enableOAuthServiceProvider })
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Grant permission to regular users.
|
// Grant permission to regular users.
|
||||||
@@ -212,8 +216,10 @@ func TestGetOAuthApps(t *testing.T) {
|
|||||||
AdminClient := th.SystemAdminClient
|
AdminClient := th.SystemAdminClient
|
||||||
|
|
||||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||||
|
enableOAuthServiceProvider := th.App.Config().ServiceSettings.EnableOAuthServiceProvider
|
||||||
defer func() {
|
defer func() {
|
||||||
th.RestoreDefaultRolePermissions(defaultRolePermissions)
|
th.RestoreDefaultRolePermissions(defaultRolePermissions)
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = enableOAuthServiceProvider })
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Grant permission to regular users.
|
// Grant permission to regular users.
|
||||||
@@ -284,8 +290,10 @@ func TestGetOAuthApp(t *testing.T) {
|
|||||||
AdminClient := th.SystemAdminClient
|
AdminClient := th.SystemAdminClient
|
||||||
|
|
||||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||||
|
enableOAuthServiceProvider := th.App.Config().ServiceSettings.EnableOAuthServiceProvider
|
||||||
defer func() {
|
defer func() {
|
||||||
th.RestoreDefaultRolePermissions(defaultRolePermissions)
|
th.RestoreDefaultRolePermissions(defaultRolePermissions)
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = enableOAuthServiceProvider })
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Grant permission to regular users.
|
// Grant permission to regular users.
|
||||||
@@ -358,8 +366,10 @@ func TestGetOAuthAppInfo(t *testing.T) {
|
|||||||
AdminClient := th.SystemAdminClient
|
AdminClient := th.SystemAdminClient
|
||||||
|
|
||||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||||
|
enableOAuthServiceProvider := th.App.Config().ServiceSettings.EnableOAuthServiceProvider
|
||||||
defer func() {
|
defer func() {
|
||||||
th.RestoreDefaultRolePermissions(defaultRolePermissions)
|
th.RestoreDefaultRolePermissions(defaultRolePermissions)
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = enableOAuthServiceProvider })
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Grant permission to regular users.
|
// Grant permission to regular users.
|
||||||
@@ -432,8 +442,10 @@ func TestDeleteOAuthApp(t *testing.T) {
|
|||||||
AdminClient := th.SystemAdminClient
|
AdminClient := th.SystemAdminClient
|
||||||
|
|
||||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||||
|
enableOAuthServiceProvider := th.App.Config().ServiceSettings.EnableOAuthServiceProvider
|
||||||
defer func() {
|
defer func() {
|
||||||
th.RestoreDefaultRolePermissions(defaultRolePermissions)
|
th.RestoreDefaultRolePermissions(defaultRolePermissions)
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = enableOAuthServiceProvider })
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Grant permission to regular users.
|
// Grant permission to regular users.
|
||||||
@@ -500,8 +512,10 @@ func TestRegenerateOAuthAppSecret(t *testing.T) {
|
|||||||
AdminClient := th.SystemAdminClient
|
AdminClient := th.SystemAdminClient
|
||||||
|
|
||||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||||
|
enableOAuthServiceProvider := th.App.Config().ServiceSettings.EnableOAuthServiceProvider
|
||||||
defer func() {
|
defer func() {
|
||||||
th.RestoreDefaultRolePermissions(defaultRolePermissions)
|
th.RestoreDefaultRolePermissions(defaultRolePermissions)
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = enableOAuthServiceProvider })
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Grant permission to regular users.
|
// Grant permission to regular users.
|
||||||
@@ -631,6 +645,11 @@ func TestAuthorizeOAuthApp(t *testing.T) {
|
|||||||
Client := th.Client
|
Client := th.Client
|
||||||
AdminClient := th.SystemAdminClient
|
AdminClient := th.SystemAdminClient
|
||||||
|
|
||||||
|
enableOAuth := th.App.Config().ServiceSettings.EnableOAuthServiceProvider
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = enableOAuth })
|
||||||
|
}()
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = true })
|
||||||
|
|
||||||
oapp := &model.OAuthApp{Name: GenerateTestAppName(), Homepage: "https://nowhere.com", Description: "test", CallbackUrls: []string{"https://nowhere.com"}}
|
oapp := &model.OAuthApp{Name: GenerateTestAppName(), Homepage: "https://nowhere.com", Description: "test", CallbackUrls: []string{"https://nowhere.com"}}
|
||||||
@@ -958,6 +977,23 @@ func TestOAuthComplete(t *testing.T) {
|
|||||||
|
|
||||||
Client := th.Client
|
Client := th.Client
|
||||||
|
|
||||||
|
gitLabSettingsEnable := th.App.Config().GitLabSettings.Enable
|
||||||
|
gitLabSettingsAuthEndpoint := th.App.Config().GitLabSettings.AuthEndpoint
|
||||||
|
gitLabSettingsId := th.App.Config().GitLabSettings.Id
|
||||||
|
gitLabSettingsSecret := th.App.Config().GitLabSettings.Secret
|
||||||
|
gitLabSettingsTokenEndpoint := th.App.Config().GitLabSettings.TokenEndpoint
|
||||||
|
gitLabSettingsUserApiEndpoint := th.App.Config().GitLabSettings.UserApiEndpoint
|
||||||
|
enableOAuthServiceProvider := th.App.Config().ServiceSettings.EnableOAuthServiceProvider
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.GitLabSettings.Enable = gitLabSettingsEnable })
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.GitLabSettings.AuthEndpoint = gitLabSettingsAuthEndpoint })
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.GitLabSettings.Id = gitLabSettingsId })
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.GitLabSettings.Secret = gitLabSettingsSecret })
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.GitLabSettings.TokenEndpoint = gitLabSettingsTokenEndpoint })
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.GitLabSettings.UserApiEndpoint = gitLabSettingsUserApiEndpoint })
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = enableOAuthServiceProvider })
|
||||||
|
}()
|
||||||
|
|
||||||
r, err := HttpGet(Client.Url+"/login/gitlab/complete?code=123", Client.HttpClient, "", true)
|
r, err := HttpGet(Client.Url+"/login/gitlab/complete?code=123", Client.HttpClient, "", true)
|
||||||
assert.NotNil(t, err)
|
assert.NotNil(t, err)
|
||||||
closeBody(r)
|
closeBody(r)
|
||||||
|
|||||||
@@ -170,6 +170,15 @@ func testCreatePostWithOutgoingHook(
|
|||||||
team := th.BasicTeam
|
team := th.BasicTeam
|
||||||
channel := th.BasicChannel
|
channel := th.BasicChannel
|
||||||
|
|
||||||
|
enableOutgoingWebhooks := th.App.Config().ServiceSettings.EnableOutgoingWebhooks
|
||||||
|
allowedUntrustedInternalConnections := th.App.Config().ServiceSettings.AllowedUntrustedInternalConnections
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = enableOutgoingWebhooks })
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||||
|
cfg.ServiceSettings.AllowedUntrustedInternalConnections = allowedUntrustedInternalConnections
|
||||||
|
})
|
||||||
|
}()
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||||
*cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost 127.0.0.1"
|
*cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost 127.0.0.1"
|
||||||
|
|||||||
@@ -540,6 +540,11 @@ func TestPermanentDeleteTeam(t *testing.T) {
|
|||||||
team := &model.Team{DisplayName: "DisplayName", Name: GenerateTestTeamName(), Email: th.GenerateTestEmail(), Type: model.TEAM_OPEN}
|
team := &model.Team{DisplayName: "DisplayName", Name: GenerateTestTeamName(), Email: th.GenerateTestEmail(), Type: model.TEAM_OPEN}
|
||||||
team, _ = Client.CreateTeam(team)
|
team, _ = Client.CreateTeam(team)
|
||||||
|
|
||||||
|
enableAPITeamDeletion := *th.App.Config().ServiceSettings.EnableAPITeamDeletion
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableAPITeamDeletion = &enableAPITeamDeletion })
|
||||||
|
}()
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableAPITeamDeletion = false })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableAPITeamDeletion = false })
|
||||||
|
|
||||||
// Does not error when deletion is disabled, just soft deletes
|
// Does not error when deletion is disabled, just soft deletes
|
||||||
@@ -1935,15 +1940,20 @@ func TestInviteUsersToTeam(t *testing.T) {
|
|||||||
utils.DeleteMailBox(user1)
|
utils.DeleteMailBox(user1)
|
||||||
utils.DeleteMailBox(user2)
|
utils.DeleteMailBox(user2)
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableEmailInvitations = false })
|
enableEmailInvitations := *th.App.Config().ServiceSettings.EnableEmailInvitations
|
||||||
|
restrictCreationToDomains := th.App.Config().TeamSettings.RestrictCreationToDomains
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableEmailInvitations = &enableEmailInvitations })
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.RestrictCreationToDomains = restrictCreationToDomains })
|
||||||
|
}()
|
||||||
|
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableEmailInvitations = false })
|
||||||
_, resp := th.SystemAdminClient.InviteUsersToTeam(th.BasicTeam.Id, emailList)
|
_, resp := th.SystemAdminClient.InviteUsersToTeam(th.BasicTeam.Id, emailList)
|
||||||
if resp.Error == nil {
|
if resp.Error == nil {
|
||||||
t.Fatal("Should be disabled")
|
t.Fatal("Should be disabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableEmailInvitations = true })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableEmailInvitations = true })
|
||||||
|
|
||||||
okMsg, resp := th.SystemAdminClient.InviteUsersToTeam(th.BasicTeam.Id, emailList)
|
okMsg, resp := th.SystemAdminClient.InviteUsersToTeam(th.BasicTeam.Id, emailList)
|
||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
if !okMsg {
|
if !okMsg {
|
||||||
|
|||||||
@@ -22,6 +22,13 @@ func TestCreateUser(t *testing.T) {
|
|||||||
Client := th.Client
|
Client := th.Client
|
||||||
AdminClient := th.SystemAdminClient
|
AdminClient := th.SystemAdminClient
|
||||||
|
|
||||||
|
enableOpenServer := th.App.Config().TeamSettings.EnableOpenServer
|
||||||
|
enableUserCreation := th.App.Config().TeamSettings.EnableUserCreation
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.EnableOpenServer = enableOpenServer })
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.EnableUserCreation = enableUserCreation })
|
||||||
|
}()
|
||||||
|
|
||||||
user := model.User{Email: th.GenerateTestEmail(), Nickname: "Corey Hulen", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_ADMIN_ROLE_ID + " " + model.SYSTEM_USER_ROLE_ID}
|
user := model.User{Email: th.GenerateTestEmail(), Nickname: "Corey Hulen", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_ADMIN_ROLE_ID + " " + model.SYSTEM_USER_ROLE_ID}
|
||||||
|
|
||||||
ruser, resp := Client.CreateUser(&user)
|
ruser, resp := Client.CreateUser(&user)
|
||||||
@@ -161,6 +168,12 @@ func TestCreateUserWithToken(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("EnableUserCreationDisable", func(t *testing.T) {
|
t.Run("EnableUserCreationDisable", func(t *testing.T) {
|
||||||
|
|
||||||
|
enableUserCreation := th.App.Config().TeamSettings.EnableUserCreation
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.EnableUserCreation = enableUserCreation })
|
||||||
|
}()
|
||||||
|
|
||||||
user := model.User{Email: th.GenerateTestEmail(), Nickname: "Corey Hulen", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_ADMIN_ROLE_ID + " " + model.SYSTEM_USER_ROLE_ID}
|
user := model.User{Email: th.GenerateTestEmail(), Nickname: "Corey Hulen", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_ADMIN_ROLE_ID + " " + model.SYSTEM_USER_ROLE_ID}
|
||||||
|
|
||||||
token := model.NewToken(
|
token := model.NewToken(
|
||||||
@@ -176,7 +189,6 @@ func TestCreateUserWithToken(t *testing.T) {
|
|||||||
CheckNotImplementedStatus(t, resp)
|
CheckNotImplementedStatus(t, resp)
|
||||||
CheckErrorMessage(t, resp, "api.user.create_user.signup_email_disabled.app_error")
|
CheckErrorMessage(t, resp, "api.user.create_user.signup_email_disabled.app_error")
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableUserCreation = true })
|
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("EnableOpenServerDisable", func(t *testing.T) {
|
t.Run("EnableOpenServerDisable", func(t *testing.T) {
|
||||||
@@ -188,6 +200,11 @@ func TestCreateUserWithToken(t *testing.T) {
|
|||||||
)
|
)
|
||||||
<-th.App.Srv.Store.Token().Save(token)
|
<-th.App.Srv.Store.Token().Save(token)
|
||||||
|
|
||||||
|
enableOpenServer := th.App.Config().TeamSettings.EnableOpenServer
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.EnableOpenServer = enableOpenServer })
|
||||||
|
}()
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableOpenServer = false })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableOpenServer = false })
|
||||||
|
|
||||||
ruser, resp := Client.CreateUserWithToken(&user, token.Token)
|
ruser, resp := Client.CreateUserWithToken(&user, token.Token)
|
||||||
@@ -270,6 +287,11 @@ func TestCreateUserWithInviteId(t *testing.T) {
|
|||||||
t.Run("EnableUserCreationDisable", func(t *testing.T) {
|
t.Run("EnableUserCreationDisable", func(t *testing.T) {
|
||||||
user := model.User{Email: th.GenerateTestEmail(), Nickname: "Corey Hulen", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_ADMIN_ROLE_ID + " " + model.SYSTEM_USER_ROLE_ID}
|
user := model.User{Email: th.GenerateTestEmail(), Nickname: "Corey Hulen", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_ADMIN_ROLE_ID + " " + model.SYSTEM_USER_ROLE_ID}
|
||||||
|
|
||||||
|
enableUserCreation := th.App.Config().TeamSettings.EnableUserCreation
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.EnableUserCreation = enableUserCreation })
|
||||||
|
}()
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableUserCreation = false })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableUserCreation = false })
|
||||||
|
|
||||||
inviteId := th.BasicTeam.InviteId
|
inviteId := th.BasicTeam.InviteId
|
||||||
@@ -277,13 +299,16 @@ func TestCreateUserWithInviteId(t *testing.T) {
|
|||||||
_, resp := Client.CreateUserWithInviteId(&user, inviteId)
|
_, resp := Client.CreateUserWithInviteId(&user, inviteId)
|
||||||
CheckNotImplementedStatus(t, resp)
|
CheckNotImplementedStatus(t, resp)
|
||||||
CheckErrorMessage(t, resp, "api.user.create_user.signup_email_disabled.app_error")
|
CheckErrorMessage(t, resp, "api.user.create_user.signup_email_disabled.app_error")
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableUserCreation = true })
|
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("EnableOpenServerDisable", func(t *testing.T) {
|
t.Run("EnableOpenServerDisable", func(t *testing.T) {
|
||||||
user := model.User{Email: th.GenerateTestEmail(), Nickname: "Corey Hulen", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_ADMIN_ROLE_ID + " " + model.SYSTEM_USER_ROLE_ID}
|
user := model.User{Email: th.GenerateTestEmail(), Nickname: "Corey Hulen", Password: "hello1", Username: GenerateTestUsername(), Roles: model.SYSTEM_ADMIN_ROLE_ID + " " + model.SYSTEM_USER_ROLE_ID}
|
||||||
|
|
||||||
|
enableOpenServer := th.App.Config().TeamSettings.EnableOpenServer
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.EnableOpenServer = enableOpenServer })
|
||||||
|
}()
|
||||||
|
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableOpenServer = false })
|
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.EnableOpenServer = false })
|
||||||
|
|
||||||
inviteId := th.BasicTeam.InviteId
|
inviteId := th.BasicTeam.InviteId
|
||||||
@@ -332,6 +357,13 @@ func TestGetUser(t *testing.T) {
|
|||||||
|
|
||||||
th.App.UpdateUser(user, false)
|
th.App.UpdateUser(user, false)
|
||||||
|
|
||||||
|
showEmailAddress := th.App.Config().PrivacySettings.ShowEmailAddress
|
||||||
|
showFullName := th.App.Config().PrivacySettings.ShowFullName
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = showEmailAddress })
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = showFullName })
|
||||||
|
}()
|
||||||
|
|
||||||
ruser, resp := Client.GetUser(user.Id, "")
|
ruser, resp := Client.GetUser(user.Id, "")
|
||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
CheckUserSanitization(t, ruser)
|
CheckUserSanitization(t, ruser)
|
||||||
@@ -393,6 +425,13 @@ func TestGetUserByUsername(t *testing.T) {
|
|||||||
|
|
||||||
user := th.BasicUser
|
user := th.BasicUser
|
||||||
|
|
||||||
|
showEmailAddress := th.App.Config().PrivacySettings.ShowEmailAddress
|
||||||
|
showFullName := th.App.Config().PrivacySettings.ShowFullName
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = showEmailAddress })
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = showFullName })
|
||||||
|
}()
|
||||||
|
|
||||||
ruser, resp := Client.GetUserByUsername(user.Username, "")
|
ruser, resp := Client.GetUserByUsername(user.Username, "")
|
||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
CheckUserSanitization(t, ruser)
|
CheckUserSanitization(t, ruser)
|
||||||
@@ -452,6 +491,13 @@ func TestGetUserByEmail(t *testing.T) {
|
|||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
Client := th.Client
|
Client := th.Client
|
||||||
|
|
||||||
|
showEmailAddress := th.App.Config().PrivacySettings.ShowEmailAddress
|
||||||
|
showFullName := th.App.Config().PrivacySettings.ShowFullName
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = showEmailAddress })
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = showFullName })
|
||||||
|
}()
|
||||||
|
|
||||||
user := th.CreateUser()
|
user := th.CreateUser()
|
||||||
|
|
||||||
ruser, resp := Client.GetUserByEmail(user.Email, "")
|
ruser, resp := Client.GetUserByEmail(user.Email, "")
|
||||||
@@ -510,6 +556,13 @@ func TestSearchUsers(t *testing.T) {
|
|||||||
defer th.TearDown()
|
defer th.TearDown()
|
||||||
Client := th.Client
|
Client := th.Client
|
||||||
|
|
||||||
|
showEmailAddress := th.App.Config().PrivacySettings.ShowEmailAddress
|
||||||
|
showFullName := th.App.Config().PrivacySettings.ShowFullName
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = showEmailAddress })
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = showFullName })
|
||||||
|
}()
|
||||||
|
|
||||||
search := &model.UserSearch{Term: th.BasicUser.Username}
|
search := &model.UserSearch{Term: th.BasicUser.Username}
|
||||||
|
|
||||||
users, resp := Client.SearchUsers(search)
|
users, resp := Client.SearchUsers(search)
|
||||||
@@ -696,6 +749,11 @@ func TestAutocompleteUsers(t *testing.T) {
|
|||||||
channelId := th.BasicChannel.Id
|
channelId := th.BasicChannel.Id
|
||||||
username := th.BasicUser.Username
|
username := th.BasicUser.Username
|
||||||
|
|
||||||
|
showFullName := th.App.Config().PrivacySettings.ShowFullName
|
||||||
|
defer func() {
|
||||||
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = showFullName })
|
||||||
|
}()
|
||||||
|
|
||||||
rusers, resp := Client.AutocompleteUsersInChannel(teamId, channelId, username, "")
|
rusers, resp := Client.AutocompleteUsersInChannel(teamId, channelId, username, "")
|
||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user