MM-10658 Change config fields to pointers (#9033)
* MM 10658 Change config fields to pointers (#8898) * Change fields of config structs to pointers and set defaults MM-10658 https://github.com/mattermost/mattermost-server/issues/8841 * Fix tests that go broken during switching config structs to pointers MM-10658 https://github.com/mattermost/mattermost-server/issues/8841 * Apply changes of current master while switching config structs to pointers MM-10658 https://github.com/mattermost/mattermost-server/issues/8841 * Fix new config pointer uses * Fix app tests * Fix mail test * remove debugging statement * fix TestUpdateConfig * assign config consistently * initialize AmazonS3Region in TestS3TestConnection * initialize fields for TestEmailTest * fix TestCheckMandatoryS3Fields
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
0c981aa010
Коммит
2ca222033c
@@ -96,7 +96,7 @@ func setupTestHelper(enterprise bool, updateConfig func(*model.Config)) *TestHel
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.TeamSettings.MaxUsersPerTeam = 50
|
||||
*cfg.RateLimitSettings.Enable = false
|
||||
cfg.EmailSettings.SendEmailNotifications = true
|
||||
*cfg.EmailSettings.SendEmailNotifications = true
|
||||
})
|
||||
prevListenAddress := *th.App.Config().ServiceSettings.ListenAddress
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ListenAddress = ":0" })
|
||||
@@ -514,7 +514,7 @@ func (me *TestHelper) AddUserToChannel(user *model.User, channel *model.Channel)
|
||||
}
|
||||
|
||||
func (me *TestHelper) GenerateTestEmail() string {
|
||||
if me.App.Config().EmailSettings.SMTPServer != "dockerhost" && os.Getenv("CI_INBUCKET_PORT") == "" {
|
||||
if *me.App.Config().EmailSettings.SMTPServer != "dockerhost" && os.Getenv("CI_INBUCKET_PORT") == "" {
|
||||
return strings.ToLower("success+" + model.NewId() + "@simulator.amazonses.com")
|
||||
}
|
||||
return strings.ToLower(model.NewId() + "@dockerhost")
|
||||
@@ -674,17 +674,17 @@ func s3New(endpoint, accessKey, secretKey string, secure bool, signV2 bool, regi
|
||||
func (me *TestHelper) cleanupTestFile(info *model.FileInfo) error {
|
||||
cfg := me.App.Config()
|
||||
if *cfg.FileSettings.DriverName == model.IMAGE_DRIVER_S3 {
|
||||
endpoint := cfg.FileSettings.AmazonS3Endpoint
|
||||
accessKey := cfg.FileSettings.AmazonS3AccessKeyId
|
||||
secretKey := cfg.FileSettings.AmazonS3SecretAccessKey
|
||||
endpoint := *cfg.FileSettings.AmazonS3Endpoint
|
||||
accessKey := *cfg.FileSettings.AmazonS3AccessKeyId
|
||||
secretKey := *cfg.FileSettings.AmazonS3SecretAccessKey
|
||||
secure := *cfg.FileSettings.AmazonS3SSL
|
||||
signV2 := *cfg.FileSettings.AmazonS3SignV2
|
||||
region := cfg.FileSettings.AmazonS3Region
|
||||
region := *cfg.FileSettings.AmazonS3Region
|
||||
s3Clnt, err := s3New(endpoint, accessKey, secretKey, secure, signV2, region)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
bucket := cfg.FileSettings.AmazonS3Bucket
|
||||
bucket := *cfg.FileSettings.AmazonS3Bucket
|
||||
if err := s3Clnt.RemoveObject(bucket, info.Path); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -701,18 +701,18 @@ func (me *TestHelper) cleanupTestFile(info *model.FileInfo) error {
|
||||
}
|
||||
}
|
||||
} else if *cfg.FileSettings.DriverName == model.IMAGE_DRIVER_LOCAL {
|
||||
if err := os.Remove(cfg.FileSettings.Directory + info.Path); err != nil {
|
||||
if err := os.Remove(*cfg.FileSettings.Directory + info.Path); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if info.ThumbnailPath != "" {
|
||||
if err := os.Remove(cfg.FileSettings.Directory + info.ThumbnailPath); err != nil {
|
||||
if err := os.Remove(*cfg.FileSettings.Directory + info.ThumbnailPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if info.PreviewPath != "" {
|
||||
if err := os.Remove(cfg.FileSettings.Directory + info.PreviewPath); err != nil {
|
||||
if err := os.Remove(*cfg.FileSettings.Directory + info.PreviewPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,12 +163,12 @@ func TestLoadTestHelpCommands(t *testing.T) {
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
||||
enableTesting := th.App.Config().ServiceSettings.EnableTesting
|
||||
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 = 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)
|
||||
if !strings.Contains(rs.Text, "Mattermost testing commands to help") {
|
||||
@@ -185,12 +185,12 @@ func TestLoadTestSetupCommands(t *testing.T) {
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
||||
enableTesting := th.App.Config().ServiceSettings.EnableTesting
|
||||
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 = 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)
|
||||
if rs.Text != "Created environment" {
|
||||
@@ -207,12 +207,12 @@ func TestLoadTestUsersCommands(t *testing.T) {
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
||||
enableTesting := th.App.Config().ServiceSettings.EnableTesting
|
||||
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 = 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)
|
||||
if rs.Text != "Added users" {
|
||||
@@ -229,12 +229,12 @@ func TestLoadTestChannelsCommands(t *testing.T) {
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
||||
enableTesting := th.App.Config().ServiceSettings.EnableTesting
|
||||
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 = 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)
|
||||
if rs.Text != "Added channels" {
|
||||
@@ -251,12 +251,12 @@ func TestLoadTestPostsCommands(t *testing.T) {
|
||||
Client := th.Client
|
||||
channel := th.BasicChannel
|
||||
|
||||
enableTesting := th.App.Config().ServiceSettings.EnableTesting
|
||||
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 = 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)
|
||||
if rs.Text != "Added posts" {
|
||||
|
||||
@@ -600,7 +600,7 @@ func getFileLink(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if !c.App.Config().FileSettings.EnablePublicLink {
|
||||
if !*c.App.Config().FileSettings.EnablePublicLink {
|
||||
c.Err = model.NewAppError("getPublicLink", "api.file.get_public_link.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
@@ -696,7 +696,7 @@ func getPublicFile(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if !c.App.Config().FileSettings.EnablePublicLink {
|
||||
if !*c.App.Config().FileSettings.EnablePublicLink {
|
||||
c.Err = model.NewAppError("getPublicFile", "api.file.get_public_link.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -934,7 +934,7 @@ func TestGetFileLink(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FileSettings.EnablePublicLink = enablePublicLink })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.FileSettings.PublicLinkSalt = publicLinkSalt })
|
||||
}()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FileSettings.EnablePublicLink = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.FileSettings.EnablePublicLink = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.FileSettings.PublicLinkSalt = model.NewId() })
|
||||
|
||||
fileId := ""
|
||||
@@ -953,14 +953,14 @@ func TestGetFileLink(t *testing.T) {
|
||||
// Hacky way to assign file to a post (usually would be done by CreatePost call)
|
||||
store.Must(th.App.Srv.Store.FileInfo().AttachToPost(fileId, th.BasicPost.Id, th.BasicUser.Id))
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FileSettings.EnablePublicLink = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.FileSettings.EnablePublicLink = false })
|
||||
_, resp = Client.GetFileLink(fileId)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
|
||||
// Wait a bit for files to ready
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FileSettings.EnablePublicLink = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.FileSettings.EnablePublicLink = true })
|
||||
link, resp := Client.GetFileLink(fileId)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
@@ -1129,7 +1129,7 @@ func TestGetPublicFile(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FileSettings.EnablePublicLink = enablePublicLink })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.FileSettings.PublicLinkSalt = publicLinkSalt })
|
||||
}()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FileSettings.EnablePublicLink = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.FileSettings.EnablePublicLink = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.FileSettings.PublicLinkSalt = GenerateTestId() })
|
||||
|
||||
fileId := ""
|
||||
@@ -1161,13 +1161,13 @@ func TestGetPublicFile(t *testing.T) {
|
||||
t.Fatal("should've failed to get image with public link without hash", resp.Status)
|
||||
}
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FileSettings.EnablePublicLink = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.FileSettings.EnablePublicLink = false })
|
||||
if resp, err := http.Get(link); err == nil && resp.StatusCode != http.StatusNotImplemented {
|
||||
t.Fatal("should've failed to get image with disabled public link")
|
||||
}
|
||||
|
||||
// test after the salt has changed
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.FileSettings.EnablePublicLink = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.FileSettings.EnablePublicLink = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.FileSettings.PublicLinkSalt = GenerateTestId() })
|
||||
|
||||
if resp, err := http.Get(link); err == nil && resp.StatusCode != http.StatusBadRequest {
|
||||
|
||||
@@ -325,7 +325,7 @@ func deauthorizeOAuthApp(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func authorizeOAuthPage(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if !c.App.Config().ServiceSettings.EnableOAuthServiceProvider {
|
||||
if !*c.App.Config().ServiceSettings.EnableOAuthServiceProvider {
|
||||
err := model.NewAppError("authorizeOAuth", "api.oauth.authorize_oauth.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
utils.RenderWebAppError(c.App.Config(), w, r, err, c.App.AsymmetricSigningKey())
|
||||
return
|
||||
|
||||
@@ -38,7 +38,7 @@ func TestCreateOAuthApp(t *testing.T) {
|
||||
// Grant permission to regular users.
|
||||
th.AddPermissionToRole(model.PERMISSION_MANAGE_OAUTH.Id, model.SYSTEM_USER_ROLE_ID)
|
||||
|
||||
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"}, IsTrusted: true}
|
||||
|
||||
@@ -89,7 +89,7 @@ func TestCreateOAuthApp(t *testing.T) {
|
||||
_, resp = Client.CreateOAuthApp(oapp)
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOAuthServiceProvider = false })
|
||||
oapp.Name = GenerateTestAppName()
|
||||
_, resp = AdminClient.CreateOAuthApp(oapp)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
@@ -110,7 +110,7 @@ func TestUpdateOAuthApp(t *testing.T) {
|
||||
|
||||
// Grant permission to regular users.
|
||||
th.AddPermissionToRole(model.PERMISSION_MANAGE_OAUTH.Id, model.SYSTEM_USER_ROLE_ID)
|
||||
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: "oapp",
|
||||
@@ -198,7 +198,7 @@ func TestUpdateOAuthApp(t *testing.T) {
|
||||
_, resp = AdminClient.UpdateOAuthApp(oapp)
|
||||
CheckNotFoundStatus(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOAuthServiceProvider = false })
|
||||
|
||||
_, resp = AdminClient.UpdateOAuthApp(oapp)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
@@ -227,7 +227,7 @@ func TestGetOAuthApps(t *testing.T) {
|
||||
|
||||
// Grant permission to regular users.
|
||||
th.AddPermissionToRole(model.PERMISSION_MANAGE_OAUTH.Id, model.SYSTEM_USER_ROLE_ID)
|
||||
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"}}
|
||||
|
||||
@@ -281,7 +281,7 @@ func TestGetOAuthApps(t *testing.T) {
|
||||
_, resp = Client.GetOAuthApps(0, 1000)
|
||||
CheckUnauthorizedStatus(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOAuthServiceProvider = false })
|
||||
_, resp = AdminClient.GetOAuthApps(0, 1000)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
}
|
||||
@@ -301,7 +301,7 @@ func TestGetOAuthApp(t *testing.T) {
|
||||
|
||||
// Grant permission to regular users.
|
||||
th.AddPermissionToRole(model.PERMISSION_MANAGE_OAUTH.Id, model.SYSTEM_USER_ROLE_ID)
|
||||
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"}}
|
||||
|
||||
@@ -357,7 +357,7 @@ func TestGetOAuthApp(t *testing.T) {
|
||||
_, resp = AdminClient.GetOAuthApp(model.NewId())
|
||||
CheckNotFoundStatus(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOAuthServiceProvider = false })
|
||||
_, resp = AdminClient.GetOAuthApp(rapp.Id)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
}
|
||||
@@ -377,7 +377,7 @@ func TestGetOAuthAppInfo(t *testing.T) {
|
||||
|
||||
// Grant permission to regular users.
|
||||
th.AddPermissionToRole(model.PERMISSION_MANAGE_OAUTH.Id, model.SYSTEM_USER_ROLE_ID)
|
||||
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"}}
|
||||
|
||||
@@ -433,7 +433,7 @@ func TestGetOAuthAppInfo(t *testing.T) {
|
||||
_, resp = AdminClient.GetOAuthAppInfo(model.NewId())
|
||||
CheckNotFoundStatus(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOAuthServiceProvider = false })
|
||||
_, resp = AdminClient.GetOAuthAppInfo(rapp.Id)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
}
|
||||
@@ -453,7 +453,7 @@ func TestDeleteOAuthApp(t *testing.T) {
|
||||
|
||||
// Grant permission to regular users.
|
||||
th.AddPermissionToRole(model.PERMISSION_MANAGE_OAUTH.Id, model.SYSTEM_USER_ROLE_ID)
|
||||
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"}}
|
||||
|
||||
@@ -503,7 +503,7 @@ func TestDeleteOAuthApp(t *testing.T) {
|
||||
_, resp = AdminClient.DeleteOAuthApp(model.NewId())
|
||||
CheckNotFoundStatus(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOAuthServiceProvider = false })
|
||||
_, resp = AdminClient.DeleteOAuthApp(rapp.Id)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
}
|
||||
@@ -523,7 +523,7 @@ func TestRegenerateOAuthAppSecret(t *testing.T) {
|
||||
|
||||
// Grant permission to regular users.
|
||||
th.AddPermissionToRole(model.PERMISSION_MANAGE_OAUTH.Id, model.SYSTEM_USER_ROLE_ID)
|
||||
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"}}
|
||||
|
||||
@@ -577,7 +577,7 @@ func TestRegenerateOAuthAppSecret(t *testing.T) {
|
||||
_, resp = AdminClient.RegenerateOAuthAppSecret(model.NewId())
|
||||
CheckNotFoundStatus(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOAuthServiceProvider = false })
|
||||
_, resp = AdminClient.RegenerateOAuthAppSecret(rapp.Id)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
}
|
||||
@@ -592,7 +592,7 @@ func TestGetAuthorizedOAuthAppsForUser(t *testing.T) {
|
||||
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"}}
|
||||
|
||||
@@ -648,12 +648,12 @@ func TestAuthorizeOAuthApp(t *testing.T) {
|
||||
Client := th.Client
|
||||
AdminClient := th.SystemAdminClient
|
||||
|
||||
enableOAuth := th.App.Config().ServiceSettings.EnableOAuthServiceProvider
|
||||
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 = 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"}}
|
||||
|
||||
@@ -741,7 +741,7 @@ func TestDeauthorizeOAuthApp(t *testing.T) {
|
||||
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"}}
|
||||
|
||||
@@ -791,7 +791,7 @@ func TestOAuthAccessToken(t *testing.T) {
|
||||
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 })
|
||||
|
||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||
defer func() {
|
||||
@@ -803,14 +803,14 @@ func TestOAuthAccessToken(t *testing.T) {
|
||||
oauthApp := &model.OAuthApp{Name: "TestApp5" + model.NewId(), Homepage: "https://nowhere.com", Description: "test", CallbackUrls: []string{"https://nowhere.com"}}
|
||||
oauthApp = Client.Must(Client.CreateOAuthApp(oauthApp)).(*model.OAuthApp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOAuthServiceProvider = false })
|
||||
data := url.Values{"grant_type": []string{"junk"}, "client_id": []string{"12345678901234567890123456"}, "client_secret": []string{"12345678901234567890123456"}, "code": []string{"junk"}, "redirect_uri": []string{oauthApp.CallbackUrls[0]}}
|
||||
|
||||
if _, resp := Client.GetOAuthAccessToken(data); resp.Error == nil {
|
||||
t.Log(resp.StatusCode)
|
||||
t.Fatal("should have failed - oauth providing turned off")
|
||||
}
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOAuthServiceProvider = true })
|
||||
|
||||
authRequest := &model.AuthorizeRequest{
|
||||
ResponseType: model.AUTHCODE_RESPONSE_TYPE,
|
||||
@@ -1022,32 +1022,32 @@ func TestOAuthComplete(t *testing.T) {
|
||||
assert.NotNil(t, err)
|
||||
closeBody(r)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.GitLabSettings.Enable = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GitLabSettings.Enable = true })
|
||||
r, err = HttpGet(Client.Url+"/login/gitlab/complete?code=123&state=!#$#F@#Yˆ&~ñ", Client.HttpClient, "", true)
|
||||
assert.NotNil(t, err)
|
||||
closeBody(r)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.GitLabSettings.AuthEndpoint = Client.Url + "/oauth/authorize" })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.GitLabSettings.Id = model.NewId() })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GitLabSettings.AuthEndpoint = Client.Url + "/oauth/authorize" })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GitLabSettings.Id = model.NewId() })
|
||||
|
||||
stateProps := map[string]string{}
|
||||
stateProps["action"] = model.OAUTH_ACTION_LOGIN
|
||||
stateProps["team_id"] = th.BasicTeam.Id
|
||||
stateProps["redirect_to"] = th.App.Config().GitLabSettings.AuthEndpoint
|
||||
stateProps["redirect_to"] = *th.App.Config().GitLabSettings.AuthEndpoint
|
||||
|
||||
state := base64.StdEncoding.EncodeToString([]byte(model.MapToJson(stateProps)))
|
||||
r, err = HttpGet(Client.Url+"/login/gitlab/complete?code=123&state="+url.QueryEscape(state), Client.HttpClient, "", true)
|
||||
assert.NotNil(t, err)
|
||||
closeBody(r)
|
||||
|
||||
stateProps["hash"] = utils.HashSha256(th.App.Config().GitLabSettings.Id)
|
||||
stateProps["hash"] = utils.HashSha256(*th.App.Config().GitLabSettings.Id)
|
||||
state = base64.StdEncoding.EncodeToString([]byte(model.MapToJson(stateProps)))
|
||||
r, err = HttpGet(Client.Url+"/login/gitlab/complete?code=123&state="+url.QueryEscape(state), Client.HttpClient, "", true)
|
||||
assert.NotNil(t, err)
|
||||
closeBody(r)
|
||||
|
||||
// We are going to use mattermost as the provider emulating gitlab
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOAuthServiceProvider = true })
|
||||
|
||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||
defer func() {
|
||||
@@ -1068,11 +1068,11 @@ func TestOAuthComplete(t *testing.T) {
|
||||
}
|
||||
oauthApp = Client.Must(Client.CreateOAuthApp(oauthApp)).(*model.OAuthApp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.GitLabSettings.Id = oauthApp.Id })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.GitLabSettings.Secret = oauthApp.ClientSecret })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.GitLabSettings.AuthEndpoint = Client.Url + "/oauth/authorize" })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.GitLabSettings.TokenEndpoint = Client.Url + "/oauth/access_token" })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.GitLabSettings.UserApiEndpoint = Client.ApiUrl + "/users/me" })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GitLabSettings.Id = oauthApp.Id })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GitLabSettings.Secret = oauthApp.ClientSecret })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GitLabSettings.AuthEndpoint = Client.Url + "/oauth/authorize" })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GitLabSettings.TokenEndpoint = Client.Url + "/oauth/access_token" })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GitLabSettings.UserApiEndpoint = Client.ApiUrl + "/users/me" })
|
||||
|
||||
provider := &MattermostTestProvider{}
|
||||
|
||||
@@ -1091,8 +1091,8 @@ func TestOAuthComplete(t *testing.T) {
|
||||
code := rurl.Query().Get("code")
|
||||
stateProps["action"] = model.OAUTH_ACTION_EMAIL_TO_SSO
|
||||
delete(stateProps, "team_id")
|
||||
stateProps["redirect_to"] = th.App.Config().GitLabSettings.AuthEndpoint
|
||||
stateProps["hash"] = utils.HashSha256(th.App.Config().GitLabSettings.Id)
|
||||
stateProps["redirect_to"] = *th.App.Config().GitLabSettings.AuthEndpoint
|
||||
stateProps["hash"] = utils.HashSha256(*th.App.Config().GitLabSettings.Id)
|
||||
stateProps["redirect_to"] = "/oauth/authorize"
|
||||
state = base64.StdEncoding.EncodeToString([]byte(model.MapToJson(stateProps)))
|
||||
if r, err := HttpGet(Client.Url+"/login/"+model.SERVICE_GITLAB+"/complete?code="+url.QueryEscape(code)+"&state="+url.QueryEscape(state), Client.HttpClient, "", false); err == nil {
|
||||
|
||||
@@ -174,16 +174,16 @@ func testCreatePostWithOutgoingHook(
|
||||
team := th.BasicTeam
|
||||
channel := th.BasicChannel
|
||||
|
||||
enableOutgoingWebhooks := th.App.Config().ServiceSettings.EnableOutgoingWebhooks
|
||||
allowedUntrustedInternalConnections := th.App.Config().ServiceSettings.AllowedUntrustedInternalConnections
|
||||
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.EnableOutgoingWebhooks = enableOutgoingWebhooks })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.ServiceSettings.AllowedUntrustedInternalConnections = allowedUntrustedInternalConnections
|
||||
*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) {
|
||||
*cfg.ServiceSettings.AllowedUntrustedInternalConnections = "localhost 127.0.0.1"
|
||||
})
|
||||
|
||||
@@ -456,7 +456,7 @@ func testS3(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if cfg.FileSettings.AmazonS3SecretAccessKey == model.FAKE_SETTING {
|
||||
if *cfg.FileSettings.AmazonS3SecretAccessKey == model.FAKE_SETTING {
|
||||
cfg.FileSettings.AmazonS3SecretAccessKey = c.App.Config().FileSettings.AmazonS3SecretAccessKey
|
||||
}
|
||||
|
||||
|
||||
@@ -57,22 +57,22 @@ func TestGetConfig(t *testing.T) {
|
||||
if *cfg.FileSettings.PublicLinkSalt != model.FAKE_SETTING {
|
||||
t.Fatal("did not sanitize properly")
|
||||
}
|
||||
if cfg.FileSettings.AmazonS3SecretAccessKey != model.FAKE_SETTING && len(cfg.FileSettings.AmazonS3SecretAccessKey) != 0 {
|
||||
if *cfg.FileSettings.AmazonS3SecretAccessKey != model.FAKE_SETTING && len(*cfg.FileSettings.AmazonS3SecretAccessKey) != 0 {
|
||||
t.Fatal("did not sanitize properly")
|
||||
}
|
||||
if cfg.EmailSettings.InviteSalt != model.FAKE_SETTING {
|
||||
if *cfg.EmailSettings.InviteSalt != model.FAKE_SETTING {
|
||||
t.Fatal("did not sanitize properly")
|
||||
}
|
||||
if cfg.EmailSettings.SMTPPassword != model.FAKE_SETTING && len(cfg.EmailSettings.SMTPPassword) != 0 {
|
||||
if *cfg.EmailSettings.SMTPPassword != model.FAKE_SETTING && len(*cfg.EmailSettings.SMTPPassword) != 0 {
|
||||
t.Fatal("did not sanitize properly")
|
||||
}
|
||||
if cfg.GitLabSettings.Secret != model.FAKE_SETTING && len(cfg.GitLabSettings.Secret) != 0 {
|
||||
if *cfg.GitLabSettings.Secret != model.FAKE_SETTING && len(*cfg.GitLabSettings.Secret) != 0 {
|
||||
t.Fatal("did not sanitize properly")
|
||||
}
|
||||
if *cfg.SqlSettings.DataSource != model.FAKE_SETTING {
|
||||
t.Fatal("did not sanitize properly")
|
||||
}
|
||||
if cfg.SqlSettings.AtRestEncryptKey != model.FAKE_SETTING {
|
||||
if *cfg.SqlSettings.AtRestEncryptKey != model.FAKE_SETTING {
|
||||
t.Fatal("did not sanitize properly")
|
||||
}
|
||||
if !strings.Contains(strings.Join(cfg.SqlSettings.DataSourceReplicas, " "), model.FAKE_SETTING) && len(cfg.SqlSettings.DataSourceReplicas) != 0 {
|
||||
@@ -117,11 +117,11 @@ func TestUpdateConfig(t *testing.T) {
|
||||
|
||||
SiteName := th.App.Config().TeamSettings.SiteName
|
||||
|
||||
cfg.TeamSettings.SiteName = "MyFancyName"
|
||||
*cfg.TeamSettings.SiteName = "MyFancyName"
|
||||
cfg, resp = th.SystemAdminClient.UpdateConfig(cfg)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
require.Equal(t, "MyFancyName", cfg.TeamSettings.SiteName, "It should update the SiteName")
|
||||
require.Equal(t, "MyFancyName", *cfg.TeamSettings.SiteName, "It should update the SiteName")
|
||||
|
||||
//Revert the change
|
||||
cfg.TeamSettings.SiteName = SiteName
|
||||
@@ -284,11 +284,11 @@ func TestGetOldClientConfig(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
|
||||
testKey := "supersecretkey"
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.GoogleDeveloperKey = testKey })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.GoogleDeveloperKey = testKey })
|
||||
|
||||
t.Run("with session", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.ServiceSettings.GoogleDeveloperKey = testKey
|
||||
*cfg.ServiceSettings.GoogleDeveloperKey = testKey
|
||||
})
|
||||
|
||||
Client := th.Client
|
||||
@@ -307,7 +307,7 @@ func TestGetOldClientConfig(t *testing.T) {
|
||||
|
||||
t.Run("without session", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.ServiceSettings.GoogleDeveloperKey = testKey
|
||||
*cfg.ServiceSettings.GoogleDeveloperKey = testKey
|
||||
})
|
||||
|
||||
Client := th.CreateClient()
|
||||
@@ -417,9 +417,16 @@ func TestEmailTest(t *testing.T) {
|
||||
Client := th.Client
|
||||
|
||||
config := model.Config{
|
||||
ServiceSettings: model.ServiceSettings{
|
||||
SiteURL: model.NewString(""),
|
||||
},
|
||||
EmailSettings: model.EmailSettings{
|
||||
SMTPServer: "",
|
||||
SMTPPort: "",
|
||||
SMTPServer: model.NewString(""),
|
||||
SMTPPort: model.NewString(""),
|
||||
SMTPPassword: model.NewString(""),
|
||||
FeedbackName: model.NewString(""),
|
||||
FeedbackEmail: model.NewString(""),
|
||||
SendEmailNotifications: model.NewBool(false),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -440,8 +447,8 @@ func TestEmailTest(t *testing.T) {
|
||||
inbucket_port = "9000"
|
||||
}
|
||||
|
||||
config.EmailSettings.SMTPServer = inbucket_host
|
||||
config.EmailSettings.SMTPPort = inbucket_port
|
||||
*config.EmailSettings.SMTPServer = inbucket_host
|
||||
*config.EmailSettings.SMTPPort = inbucket_port
|
||||
_, resp = th.SystemAdminClient.TestEmail(&config)
|
||||
CheckOKStatus(t, resp)
|
||||
}
|
||||
@@ -679,10 +686,11 @@ func TestS3TestConnection(t *testing.T) {
|
||||
config := model.Config{
|
||||
FileSettings: model.FileSettings{
|
||||
DriverName: model.NewString(model.IMAGE_DRIVER_S3),
|
||||
AmazonS3AccessKeyId: model.MINIO_ACCESS_KEY,
|
||||
AmazonS3SecretAccessKey: model.MINIO_SECRET_KEY,
|
||||
AmazonS3Bucket: "",
|
||||
AmazonS3Endpoint: s3Endpoint,
|
||||
AmazonS3AccessKeyId: model.NewString(model.MINIO_ACCESS_KEY),
|
||||
AmazonS3SecretAccessKey: model.NewString(model.MINIO_SECRET_KEY),
|
||||
AmazonS3Bucket: model.NewString(""),
|
||||
AmazonS3Endpoint: model.NewString(s3Endpoint),
|
||||
AmazonS3Region: model.NewString(""),
|
||||
AmazonS3SSL: model.NewBool(false),
|
||||
},
|
||||
}
|
||||
@@ -698,21 +706,21 @@ func TestS3TestConnection(t *testing.T) {
|
||||
|
||||
// If this fails, check the test configuration to ensure minio is setup with the
|
||||
// `mattermost-test` bucket defined by model.MINIO_BUCKET.
|
||||
config.FileSettings.AmazonS3Bucket = model.MINIO_BUCKET
|
||||
config.FileSettings.AmazonS3Region = "us-east-1"
|
||||
*config.FileSettings.AmazonS3Bucket = model.MINIO_BUCKET
|
||||
*config.FileSettings.AmazonS3Region = "us-east-1"
|
||||
_, resp = th.SystemAdminClient.TestS3Connection(&config)
|
||||
CheckOKStatus(t, resp)
|
||||
|
||||
config.FileSettings.AmazonS3Region = ""
|
||||
config.FileSettings.AmazonS3Region = model.NewString("")
|
||||
_, resp = th.SystemAdminClient.TestS3Connection(&config)
|
||||
CheckOKStatus(t, resp)
|
||||
|
||||
config.FileSettings.AmazonS3Bucket = "Wrong_bucket"
|
||||
config.FileSettings.AmazonS3Bucket = model.NewString("Wrong_bucket")
|
||||
_, resp = th.SystemAdminClient.TestS3Connection(&config)
|
||||
CheckInternalErrorStatus(t, resp)
|
||||
assert.Equal(t, "Unable to create bucket.", resp.Error.Message)
|
||||
|
||||
config.FileSettings.AmazonS3Bucket = "shouldcreatenewbucket"
|
||||
*config.FileSettings.AmazonS3Bucket = "shouldcreatenewbucket"
|
||||
_, resp = th.SystemAdminClient.TestS3Connection(&config)
|
||||
CheckOKStatus(t, resp)
|
||||
|
||||
|
||||
@@ -1952,7 +1952,7 @@ func TestInviteUsersToTeam(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.TeamSettings.RestrictCreationToDomains = "@global.com,@common.com" })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.RestrictCreationToDomains = "@global.com,@common.com" })
|
||||
|
||||
t.Run("restricted domains", func(t *testing.T) {
|
||||
err := th.App.InviteNewUsersToTeam(emailList, th.BasicTeam.Id, th.BasicUser.Id)
|
||||
|
||||
12
api4/user.go
12
api4/user.go
@@ -119,7 +119,7 @@ func getUser(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
etag := user.Etag(c.App.Config().PrivacySettings.ShowFullName, c.App.Config().PrivacySettings.ShowEmailAddress)
|
||||
etag := user.Etag(*c.App.Config().PrivacySettings.ShowFullName, *c.App.Config().PrivacySettings.ShowEmailAddress)
|
||||
|
||||
if c.HandleEtag(etag, "Get User", w, r) {
|
||||
return
|
||||
@@ -149,7 +149,7 @@ func getUserByUsername(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
etag := user.Etag(c.App.Config().PrivacySettings.ShowFullName, c.App.Config().PrivacySettings.ShowEmailAddress)
|
||||
etag := user.Etag(*c.App.Config().PrivacySettings.ShowFullName, *c.App.Config().PrivacySettings.ShowEmailAddress)
|
||||
|
||||
if c.HandleEtag(etag, "Get User", w, r) {
|
||||
return
|
||||
@@ -184,7 +184,7 @@ func getUserByEmail(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
etag := user.Etag(c.App.Config().PrivacySettings.ShowFullName, c.App.Config().PrivacySettings.ShowEmailAddress)
|
||||
etag := user.Etag(*c.App.Config().PrivacySettings.ShowFullName, *c.App.Config().PrivacySettings.ShowEmailAddress)
|
||||
|
||||
if c.HandleEtag(etag, "Get User", w, r) {
|
||||
return
|
||||
@@ -577,8 +577,8 @@ func searchUsers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
options.AllowEmails = true
|
||||
options.AllowFullNames = true
|
||||
} else {
|
||||
options.AllowEmails = c.App.Config().PrivacySettings.ShowEmailAddress
|
||||
options.AllowFullNames = c.App.Config().PrivacySettings.ShowFullName
|
||||
options.AllowEmails = *c.App.Config().PrivacySettings.ShowEmailAddress
|
||||
options.AllowFullNames = *c.App.Config().PrivacySettings.ShowFullName
|
||||
}
|
||||
|
||||
profiles, err := c.App.SearchUsers(props, options)
|
||||
@@ -610,7 +610,7 @@ func autocompleteUsers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if c.App.SessionHasPermissionTo(c.App.Session, model.PERMISSION_MANAGE_SYSTEM) {
|
||||
options.AllowFullNames = true
|
||||
} else {
|
||||
options.AllowFullNames = c.App.Config().PrivacySettings.ShowFullName
|
||||
options.AllowFullNames = *c.App.Config().PrivacySettings.ShowFullName
|
||||
}
|
||||
|
||||
if len(channelId) > 0 {
|
||||
|
||||
@@ -364,8 +364,8 @@ func TestGetUser(t *testing.T) {
|
||||
CheckNotFoundStatus(t, resp)
|
||||
|
||||
// Check against privacy config settings
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PrivacySettings.ShowEmailAddress = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PrivacySettings.ShowFullName = false })
|
||||
|
||||
ruser, resp = th.Client.GetUser(user.Id, "")
|
||||
CheckNoError(t, resp)
|
||||
@@ -418,8 +418,8 @@ func TestGetUserByUsername(t *testing.T) {
|
||||
CheckNotFoundStatus(t, resp)
|
||||
|
||||
// Check against privacy config settings
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PrivacySettings.ShowEmailAddress = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PrivacySettings.ShowFullName = false })
|
||||
|
||||
ruser, resp = th.Client.GetUserByUsername(th.BasicUser2.Username, "")
|
||||
CheckNoError(t, resp)
|
||||
@@ -464,8 +464,8 @@ func TestGetUserByEmail(t *testing.T) {
|
||||
user := th.CreateUser()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.PrivacySettings.ShowEmailAddress = true
|
||||
cfg.PrivacySettings.ShowFullName = true
|
||||
*cfg.PrivacySettings.ShowEmailAddress = true
|
||||
*cfg.PrivacySettings.ShowFullName = true
|
||||
})
|
||||
|
||||
t.Run("should be able to get another user by email", func(t *testing.T) {
|
||||
@@ -498,8 +498,8 @@ func TestGetUserByEmail(t *testing.T) {
|
||||
|
||||
t.Run("should sanitize full name for non-admin based on privacy settings", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.PrivacySettings.ShowEmailAddress = true
|
||||
cfg.PrivacySettings.ShowFullName = false
|
||||
*cfg.PrivacySettings.ShowEmailAddress = true
|
||||
*cfg.PrivacySettings.ShowFullName = false
|
||||
})
|
||||
|
||||
ruser, resp := th.Client.GetUserByEmail(user.Email, "")
|
||||
@@ -508,7 +508,7 @@ func TestGetUserByEmail(t *testing.T) {
|
||||
assert.Equal(t, "", ruser.LastName, "last name should be blank")
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.PrivacySettings.ShowFullName = true
|
||||
*cfg.PrivacySettings.ShowFullName = true
|
||||
})
|
||||
|
||||
ruser, resp = th.Client.GetUserByEmail(user.Email, "")
|
||||
@@ -519,8 +519,8 @@ func TestGetUserByEmail(t *testing.T) {
|
||||
|
||||
t.Run("should not sanitize full name for admin, regardless of privacy settings", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.PrivacySettings.ShowEmailAddress = true
|
||||
cfg.PrivacySettings.ShowFullName = false
|
||||
*cfg.PrivacySettings.ShowEmailAddress = true
|
||||
*cfg.PrivacySettings.ShowFullName = false
|
||||
})
|
||||
|
||||
ruser, resp := th.SystemAdminClient.GetUserByEmail(user.Email, "")
|
||||
@@ -529,7 +529,7 @@ func TestGetUserByEmail(t *testing.T) {
|
||||
assert.NotEqual(t, "", ruser.LastName, "last name should be set")
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.PrivacySettings.ShowFullName = true
|
||||
*cfg.PrivacySettings.ShowFullName = true
|
||||
})
|
||||
|
||||
ruser, resp = th.SystemAdminClient.GetUserByEmail(user.Email, "")
|
||||
@@ -540,14 +540,14 @@ func TestGetUserByEmail(t *testing.T) {
|
||||
|
||||
t.Run("should return forbidden for non-admin when privacy settings hide email", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.PrivacySettings.ShowEmailAddress = false
|
||||
*cfg.PrivacySettings.ShowEmailAddress = false
|
||||
})
|
||||
|
||||
_, resp := th.Client.GetUserByEmail(user.Email, "")
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.PrivacySettings.ShowEmailAddress = true
|
||||
*cfg.PrivacySettings.ShowEmailAddress = true
|
||||
})
|
||||
|
||||
ruser, resp := th.Client.GetUserByEmail(user.Email, "")
|
||||
@@ -557,7 +557,7 @@ func TestGetUserByEmail(t *testing.T) {
|
||||
|
||||
t.Run("should always return email for admin, regardless of privacy settings", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.PrivacySettings.ShowEmailAddress = false
|
||||
*cfg.PrivacySettings.ShowEmailAddress = false
|
||||
})
|
||||
|
||||
ruser, resp := th.SystemAdminClient.GetUserByEmail(user.Email, "")
|
||||
@@ -565,7 +565,7 @@ func TestGetUserByEmail(t *testing.T) {
|
||||
assert.Equal(t, user.Email, ruser.Email, "email should be set")
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
cfg.PrivacySettings.ShowEmailAddress = true
|
||||
*cfg.PrivacySettings.ShowEmailAddress = true
|
||||
})
|
||||
|
||||
ruser, resp = th.SystemAdminClient.GetUserByEmail(user.Email, "")
|
||||
@@ -701,8 +701,8 @@ func TestSearchUsers(t *testing.T) {
|
||||
|
||||
search.Term = th.BasicUser.Username
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PrivacySettings.ShowEmailAddress = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PrivacySettings.ShowFullName = false })
|
||||
|
||||
_, err = th.App.UpdateActive(th.BasicUser2, true)
|
||||
if err != nil {
|
||||
@@ -852,7 +852,7 @@ func TestAutocompleteUsers(t *testing.T) {
|
||||
CheckNoError(t, resp)
|
||||
|
||||
// Check against privacy config settings
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PrivacySettings.ShowFullName = false })
|
||||
|
||||
th.LoginBasic()
|
||||
|
||||
@@ -1389,7 +1389,7 @@ func TestUpdateUserActive(t *testing.T) {
|
||||
}
|
||||
|
||||
// Verify that both admins and regular users see the email when privacy settings allow same.
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PrivacySettings.ShowEmailAddress = true })
|
||||
_, resp := th.SystemAdminClient.UpdateUserActive(user.Id, false)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
@@ -1397,7 +1397,7 @@ func TestUpdateUserActive(t *testing.T) {
|
||||
assertWebsocketEventUserUpdatedWithEmail(t, adminWebSocketClient, user.Email)
|
||||
|
||||
// Verify that only admins see the email when privacy settings hide emails.
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.PrivacySettings.ShowEmailAddress = false })
|
||||
_, resp = th.SystemAdminClient.UpdateUserActive(user.Id, true)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
@@ -2354,7 +2354,7 @@ func TestSwitchAccount(t *testing.T) {
|
||||
th := Setup().InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.GitLabSettings.Enable = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.GitLabSettings.Enable = true })
|
||||
|
||||
th.Client.Logout()
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ func TestCreateIncomingWebhook(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnablePostUsernameOverride = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnablePostIconOverride = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnablePostUsernameOverride = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnablePostIconOverride = true })
|
||||
|
||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||
defer func() {
|
||||
@@ -63,13 +63,13 @@ func TestCreateIncomingWebhook(t *testing.T) {
|
||||
_, resp = Client.CreateIncomingWebhook(hook)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnablePostUsernameOverride = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnablePostIconOverride = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnablePostUsernameOverride = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnablePostIconOverride = false })
|
||||
|
||||
_, resp = Client.CreateIncomingWebhook(hook)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableIncomingWebhooks = false })
|
||||
_, resp = Client.CreateIncomingWebhook(hook)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func TestGetIncomingWebhooks(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
|
||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||
defer func() {
|
||||
@@ -158,7 +158,7 @@ func TestGetIncomingWebhook(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.SystemAdminClient
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
|
||||
var resp *model.Response
|
||||
var rhook *model.IncomingWebhook
|
||||
@@ -197,7 +197,7 @@ func TestDeleteIncomingWebhook(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.SystemAdminClient
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
|
||||
var resp *model.Response
|
||||
var rhook *model.IncomingWebhook
|
||||
@@ -248,7 +248,7 @@ func TestCreateOutgoingWebhook(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
|
||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||
defer func() {
|
||||
@@ -288,7 +288,7 @@ func TestCreateOutgoingWebhook(t *testing.T) {
|
||||
_, resp = Client.CreateOutgoingWebhook(hook)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOutgoingWebhooks = false })
|
||||
_, resp = Client.CreateOutgoingWebhook(hook)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
}
|
||||
@@ -298,7 +298,7 @@ func TestGetOutgoingWebhooks(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||
defer func() {
|
||||
th.RestoreDefaultRolePermissions(defaultRolePermissions)
|
||||
@@ -399,7 +399,7 @@ func TestGetOutgoingWebhook(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
|
||||
hook := &model.OutgoingWebhook{ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId, CallbackURLs: []string{"http://nowhere.com"}}
|
||||
|
||||
@@ -429,7 +429,7 @@ func TestUpdateIncomingHook(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
|
||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||
defer func() {
|
||||
@@ -443,8 +443,8 @@ func TestUpdateIncomingHook(t *testing.T) {
|
||||
createdHook, resp := th.SystemAdminClient.CreateIncomingWebhook(hook1)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnablePostUsernameOverride = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnablePostIconOverride = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnablePostUsernameOverride = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnablePostIconOverride = false })
|
||||
|
||||
t.Run("UpdateIncomingHook, overrides disabled", func(t *testing.T) {
|
||||
createdHook.DisplayName = "hook2"
|
||||
@@ -483,8 +483,8 @@ func TestUpdateIncomingHook(t *testing.T) {
|
||||
assert.Equal(t, updatedHook.ChannelId, createdHook.ChannelId)
|
||||
})
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnablePostUsernameOverride = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnablePostIconOverride = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnablePostUsernameOverride = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnablePostIconOverride = true })
|
||||
|
||||
t.Run("UpdateIncomingHook", func(t *testing.T) {
|
||||
createdHook.DisplayName = "hook2"
|
||||
@@ -604,13 +604,13 @@ func TestUpdateIncomingHook(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("IncomingHooksDisabled", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableIncomingWebhooks = false })
|
||||
_, resp := Client.UpdateIncomingWebhook(createdHook)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
CheckErrorMessage(t, resp, "api.incoming_webhook.disabled.app_error")
|
||||
})
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
|
||||
t.Run("PrivateChannel", func(t *testing.T) {
|
||||
privateChannel := th.CreatePrivateChannel()
|
||||
@@ -644,7 +644,7 @@ func TestRegenOutgoingHookToken(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
|
||||
hook := &model.OutgoingWebhook{ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId, CallbackURLs: []string{"http://nowhere.com"}}
|
||||
rhook, resp := th.SystemAdminClient.CreateOutgoingWebhook(hook)
|
||||
@@ -666,7 +666,7 @@ func TestRegenOutgoingHookToken(t *testing.T) {
|
||||
_, resp = Client.RegenOutgoingHookToken(rhook.Id)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOutgoingWebhooks = false })
|
||||
_, resp = th.SystemAdminClient.RegenOutgoingHookToken(rhook.Id)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
}
|
||||
@@ -676,7 +676,7 @@ func TestUpdateOutgoingHook(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.Client
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
defaultRolePermissions := th.SaveDefaultRolePermissions()
|
||||
defer func() {
|
||||
th.RestoreDefaultRolePermissions(defaultRolePermissions)
|
||||
@@ -705,12 +705,12 @@ func TestUpdateOutgoingHook(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("OutgoingHooksDisabled", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = false })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOutgoingWebhooks = false })
|
||||
_, resp := th.SystemAdminClient.UpdateOutgoingWebhook(createdHook)
|
||||
CheckNotImplementedStatus(t, resp)
|
||||
})
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOutgoingWebhooks = true })
|
||||
t.Run("RetainCreateAt", func(t *testing.T) {
|
||||
hook2 := &model.OutgoingWebhook{ChannelId: th.BasicChannel.Id, TeamId: th.BasicChannel.TeamId,
|
||||
CallbackURLs: []string{"http://nowhere.com"}, TriggerWords: []string{"rats"}}
|
||||
@@ -839,7 +839,7 @@ func TestDeleteOutgoingHook(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
Client := th.SystemAdminClient
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableIncomingWebhooks = true })
|
||||
|
||||
var resp *model.Response
|
||||
var rhook *model.OutgoingWebhook
|
||||
|
||||
Ссылка в новой задаче
Block a user