Automatic Merge
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
30aec66862
Коммит
06c6ee2566
@@ -310,6 +310,43 @@ func TestUpdateConfig(t *testing.T) {
|
||||
CheckForbiddenStatus(t, resp)
|
||||
})
|
||||
|
||||
t.Run("Should not be able to modify ImportSettings.Directory", func(t *testing.T) {
|
||||
t.Run("sysadmin", func(t *testing.T) {
|
||||
oldDirectory := *th.App.Config().ImportSettings.Directory
|
||||
cfg2 := th.App.Config().Clone()
|
||||
*cfg2.ImportSettings.Directory = "./new-import-dir"
|
||||
|
||||
cfg2, _, err = th.SystemAdminClient.UpdateConfig(context.Background(), cfg2)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, oldDirectory, *cfg2.ImportSettings.Directory)
|
||||
assert.Equal(t, oldDirectory, *th.App.Config().ImportSettings.Directory)
|
||||
|
||||
cfg2.ImportSettings.Directory = nil
|
||||
cfg2, _, err = th.SystemAdminClient.UpdateConfig(context.Background(), cfg2)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, oldDirectory, *cfg2.ImportSettings.Directory)
|
||||
assert.Equal(t, oldDirectory, *th.App.Config().ImportSettings.Directory)
|
||||
})
|
||||
|
||||
t.Run("local mode", func(t *testing.T) {
|
||||
oldDirectory := *th.App.Config().ImportSettings.Directory
|
||||
cfg2 := th.App.Config().Clone()
|
||||
newDirectory := "./new-import-dir"
|
||||
*cfg2.ImportSettings.Directory = newDirectory
|
||||
|
||||
cfg2, _, err = th.LocalClient.UpdateConfig(context.Background(), cfg2)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, newDirectory, *cfg2.ImportSettings.Directory)
|
||||
assert.Equal(t, newDirectory, *th.App.Config().ImportSettings.Directory)
|
||||
|
||||
cfg2.ImportSettings.Directory = nil
|
||||
cfg2, _, err = th.LocalClient.UpdateConfig(context.Background(), cfg2)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, oldDirectory, *cfg2.ImportSettings.Directory)
|
||||
assert.Equal(t, oldDirectory, *th.App.Config().ImportSettings.Directory)
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("System Admin should not be able to clear Site URL", func(t *testing.T) {
|
||||
siteURL := cfg.ServiceSettings.SiteURL
|
||||
defer th.App.UpdateConfig(func(cfg *model.Config) { cfg.ServiceSettings.SiteURL = siteURL })
|
||||
@@ -822,6 +859,30 @@ func TestPatchConfig(t *testing.T) {
|
||||
CheckForbiddenStatus(t, resp)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("not allowing to change import directory via api, unless local mode", func(t *testing.T) {
|
||||
oldDirectory := *th.App.Config().ImportSettings.Directory
|
||||
config := model.Config{ImportSettings: model.ImportSettings{
|
||||
Directory: model.NewPointer("./new-import-dir"),
|
||||
}}
|
||||
|
||||
updatedConfig, resp, err := client.PatchConfig(context.Background(), &config)
|
||||
if client == th.LocalClient {
|
||||
require.NoError(t, err)
|
||||
CheckOKStatus(t, resp)
|
||||
assert.Equal(t, "./new-import-dir", *updatedConfig.ImportSettings.Directory)
|
||||
} else {
|
||||
require.Error(t, err)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
}
|
||||
|
||||
// Reset for local mode
|
||||
if client == th.LocalClient {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ImportSettings.Directory = oldDirectory
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("Should not be able to modify PluginSettings.MarketplaceURL if EnableUploads is disabled", func(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user