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