You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

api_nodeinfo_test.go 1023B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2021 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package integration
  4. import (
  5. "net/http"
  6. "net/url"
  7. "testing"
  8. "code.gitea.io/gitea/modules/setting"
  9. api "code.gitea.io/gitea/modules/structs"
  10. "code.gitea.io/gitea/routers"
  11. "github.com/stretchr/testify/assert"
  12. )
  13. func TestNodeinfo(t *testing.T) {
  14. setting.Federation.Enabled = true
  15. testWebRoutes = routers.NormalRoutes()
  16. defer func() {
  17. setting.Federation.Enabled = false
  18. testWebRoutes = routers.NormalRoutes()
  19. }()
  20. onGiteaRun(t, func(*testing.T, *url.URL) {
  21. req := NewRequestf(t, "GET", "/api/v1/nodeinfo")
  22. resp := MakeRequest(t, req, http.StatusOK)
  23. VerifyJSONSchema(t, resp, "nodeinfo_2.1.json")
  24. var nodeinfo api.NodeInfo
  25. DecodeJSON(t, resp, &nodeinfo)
  26. assert.True(t, nodeinfo.OpenRegistrations)
  27. assert.Equal(t, "gitea", nodeinfo.Software.Name)
  28. assert.Equal(t, 25, nodeinfo.Usage.Users.Total)
  29. assert.Equal(t, 20, nodeinfo.Usage.LocalPosts)
  30. assert.Equal(t, 3, nodeinfo.Usage.LocalComments)
  31. })
  32. }