коммит произвёл
Christopher Speller
родитель
01e652ed48
Коммит
816a30397d
@@ -10,7 +10,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/mattermost/mattermost-server/model"
|
||||
"github.com/mattermost/mattermost-server/utils"
|
||||
)
|
||||
|
||||
func TestCreateOAuthApp(t *testing.T) {
|
||||
@@ -26,7 +25,7 @@ func TestCreateOAuthApp(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = adminOnly })
|
||||
}()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = true })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
th.App.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
oapp := &model.OAuthApp{Name: GenerateTestAppName(), Homepage: "https://nowhere.com", Description: "test", CallbackUrls: []string{"https://nowhere.com"}, IsTrusted: true}
|
||||
|
||||
@@ -43,12 +42,12 @@ func TestCreateOAuthApp(t *testing.T) {
|
||||
}
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = true })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
th.App.SetDefaultRolesBasedOnConfig()
|
||||
_, resp = Client.CreateOAuthApp(oapp)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = false })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
th.App.SetDefaultRolesBasedOnConfig()
|
||||
rapp, resp = Client.CreateOAuthApp(oapp)
|
||||
CheckNoError(t, resp)
|
||||
CheckCreatedStatus(t, resp)
|
||||
@@ -94,7 +93,7 @@ func TestUpdateOAuthApp(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = adminOnly })
|
||||
}()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = true })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
th.App.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
oapp := &model.OAuthApp{
|
||||
Name: "oapp",
|
||||
@@ -166,7 +165,7 @@ func TestUpdateOAuthApp(t *testing.T) {
|
||||
}
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = false })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
th.App.SetDefaultRolesBasedOnConfig()
|
||||
_, resp = Client.UpdateOAuthApp(oapp)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
@@ -201,7 +200,7 @@ func TestGetOAuthApps(t *testing.T) {
|
||||
}()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = false })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
th.App.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
oapp := &model.OAuthApp{Name: GenerateTestAppName(), Homepage: "https://nowhere.com", Description: "test", CallbackUrls: []string{"https://nowhere.com"}}
|
||||
|
||||
@@ -245,7 +244,7 @@ func TestGetOAuthApps(t *testing.T) {
|
||||
}
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = true })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
th.App.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
_, resp = Client.GetOAuthApps(0, 1000)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
@@ -274,7 +273,7 @@ func TestGetOAuthApp(t *testing.T) {
|
||||
}()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = false })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
th.App.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
oapp := &model.OAuthApp{Name: GenerateTestAppName(), Homepage: "https://nowhere.com", Description: "test", CallbackUrls: []string{"https://nowhere.com"}}
|
||||
|
||||
@@ -314,7 +313,7 @@ func TestGetOAuthApp(t *testing.T) {
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = true })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
th.App.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
_, resp = Client.GetOAuthApp(rapp2.Id)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
@@ -349,7 +348,7 @@ func TestGetOAuthAppInfo(t *testing.T) {
|
||||
}()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = false })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
th.App.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
oapp := &model.OAuthApp{Name: GenerateTestAppName(), Homepage: "https://nowhere.com", Description: "test", CallbackUrls: []string{"https://nowhere.com"}}
|
||||
|
||||
@@ -389,7 +388,7 @@ func TestGetOAuthAppInfo(t *testing.T) {
|
||||
CheckNoError(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = true })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
th.App.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
_, resp = Client.GetOAuthAppInfo(rapp2.Id)
|
||||
CheckNoError(t, resp)
|
||||
@@ -424,7 +423,7 @@ func TestDeleteOAuthApp(t *testing.T) {
|
||||
}()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = false })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
th.App.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
oapp := &model.OAuthApp{Name: GenerateTestAppName(), Homepage: "https://nowhere.com", Description: "test", CallbackUrls: []string{"https://nowhere.com"}}
|
||||
|
||||
@@ -459,7 +458,7 @@ func TestDeleteOAuthApp(t *testing.T) {
|
||||
CheckNoError(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = false })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
th.App.SetDefaultRolesBasedOnConfig()
|
||||
_, resp = Client.DeleteOAuthApp(rapp.Id)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
@@ -492,7 +491,7 @@ func TestRegenerateOAuthAppSecret(t *testing.T) {
|
||||
}()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = true })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = false })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
th.App.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
oapp := &model.OAuthApp{Name: GenerateTestAppName(), Homepage: "https://nowhere.com", Description: "test", CallbackUrls: []string{"https://nowhere.com"}}
|
||||
|
||||
@@ -531,7 +530,7 @@ func TestRegenerateOAuthAppSecret(t *testing.T) {
|
||||
CheckNoError(t, resp)
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.EnableOnlyAdminIntegrations = false })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
th.App.SetDefaultRolesBasedOnConfig()
|
||||
_, resp = Client.RegenerateOAuthAppSecret(rapp.Id)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
@@ -621,7 +620,7 @@ func TestAuthorizeOAuthApp(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = enableOAuth })
|
||||
}()
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.EnableOAuthServiceProvider = true })
|
||||
utils.SetDefaultRolesBasedOnConfig()
|
||||
th.App.SetDefaultRolesBasedOnConfig()
|
||||
|
||||
oapp := &model.OAuthApp{Name: GenerateTestAppName(), Homepage: "https://nowhere.com", Description: "test", CallbackUrls: []string{"https://nowhere.com"}}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user