Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

api_settings_test.go 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package integrations
  5. import (
  6. "net/http"
  7. "testing"
  8. "code.gitea.io/gitea/modules/setting"
  9. api "code.gitea.io/gitea/modules/structs"
  10. "github.com/stretchr/testify/assert"
  11. )
  12. func TestAPIExposedSettings(t *testing.T) {
  13. defer prepareTestEnv(t)()
  14. ui := new(api.GeneralUISettings)
  15. req := NewRequest(t, "GET", "/api/v1/settings/ui")
  16. resp := MakeRequest(t, req, http.StatusOK)
  17. DecodeJSON(t, resp, &ui)
  18. assert.Len(t, ui.AllowedReactions, len(setting.UI.Reactions))
  19. assert.ElementsMatch(t, setting.UI.Reactions, ui.AllowedReactions)
  20. apiSettings := new(api.GeneralAPISettings)
  21. req = NewRequest(t, "GET", "/api/v1/settings/api")
  22. resp = MakeRequest(t, req, http.StatusOK)
  23. DecodeJSON(t, resp, &apiSettings)
  24. assert.EqualValues(t, &api.GeneralAPISettings{
  25. MaxResponseItems: setting.API.MaxResponseItems,
  26. DefaultPagingNum: setting.API.DefaultPagingNum,
  27. DefaultGitTreesPerPage: setting.API.DefaultGitTreesPerPage,
  28. DefaultMaxBlobSize: setting.API.DefaultMaxBlobSize,
  29. }, apiSettings)
  30. repo := new(api.GeneralRepoSettings)
  31. req = NewRequest(t, "GET", "/api/v1/settings/repository")
  32. resp = MakeRequest(t, req, http.StatusOK)
  33. DecodeJSON(t, resp, &repo)
  34. assert.EqualValues(t, &api.GeneralRepoSettings{
  35. MirrorsDisabled: !setting.Mirror.Enabled,
  36. HTTPGitDisabled: setting.Repository.DisableHTTPGit,
  37. MigrationsDisabled: setting.Repository.DisableMigrations,
  38. TimeTrackingDisabled: false,
  39. LFSDisabled: !setting.LFS.StartServer,
  40. }, repo)
  41. attachment := new(api.GeneralAttachmentSettings)
  42. req = NewRequest(t, "GET", "/api/v1/settings/attachment")
  43. resp = MakeRequest(t, req, http.StatusOK)
  44. DecodeJSON(t, resp, &attachment)
  45. assert.EqualValues(t, &api.GeneralAttachmentSettings{
  46. Enabled: setting.Attachment.Enabled,
  47. AllowedTypes: setting.Attachment.AllowedTypes,
  48. MaxFiles: setting.Attachment.MaxFiles,
  49. MaxSize: setting.Attachment.MaxSize,
  50. }, attachment)
  51. }