From 02d745827bdbe01a82f9f069a904f53197252685 Mon Sep 17 00:00:00 2001 From: Gusted Date: Mon, 20 Jun 2022 01:48:17 +0200 Subject: Disable federation by default (#20045) --- integrations/api_activitypub_person_test.go | 34 +++++++++++++++++++---------- integrations/api_nodeinfo_test.go | 13 ++++++----- 2 files changed, 30 insertions(+), 17 deletions(-) (limited to 'integrations') diff --git a/integrations/api_activitypub_person_test.go b/integrations/api_activitypub_person_test.go index 4898d5e01d..e19da40864 100644 --- a/integrations/api_activitypub_person_test.go +++ b/integrations/api_activitypub_person_test.go @@ -15,18 +15,21 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/activitypub" "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/routers" ap "github.com/go-ap/activitypub" "github.com/stretchr/testify/assert" ) func TestActivityPubPerson(t *testing.T) { - onGiteaRun(t, func(*testing.T, *url.URL) { - setting.Federation.Enabled = true - defer func() { - setting.Federation.Enabled = false - }() + setting.Federation.Enabled = true + c = routers.NormalRoutes() + defer func() { + setting.Federation.Enabled = false + c = routers.NormalRoutes() + }() + onGiteaRun(t, func(*testing.T, *url.URL) { username := "user2" req := NewRequestf(t, "GET", fmt.Sprintf("/api/v1/activitypub/user/%s", username)) resp := MakeRequest(t, req, http.StatusOK) @@ -56,12 +59,14 @@ func TestActivityPubPerson(t *testing.T) { } func TestActivityPubMissingPerson(t *testing.T) { - onGiteaRun(t, func(*testing.T, *url.URL) { - setting.Federation.Enabled = true - defer func() { - setting.Federation.Enabled = false - }() + setting.Federation.Enabled = true + c = routers.NormalRoutes() + defer func() { + setting.Federation.Enabled = false + c = routers.NormalRoutes() + }() + onGiteaRun(t, func(*testing.T, *url.URL) { req := NewRequestf(t, "GET", "/api/v1/activitypub/user/nonexistentuser") resp := MakeRequest(t, req, http.StatusNotFound) assert.Contains(t, resp.Body.String(), "user redirect does not exist") @@ -69,15 +74,20 @@ func TestActivityPubMissingPerson(t *testing.T) { } func TestActivityPubPersonInbox(t *testing.T) { + setting.Federation.Enabled = true + c = routers.NormalRoutes() + defer func() { + setting.Federation.Enabled = false + c = routers.NormalRoutes() + }() + srv := httptest.NewServer(c) defer srv.Close() onGiteaRun(t, func(*testing.T, *url.URL) { appURL := setting.AppURL - setting.Federation.Enabled = true setting.AppURL = srv.URL defer func() { - setting.Federation.Enabled = false setting.Database.LogSQL = false setting.AppURL = appURL }() diff --git a/integrations/api_nodeinfo_test.go b/integrations/api_nodeinfo_test.go index c2fcd2fea5..cf9ff4da1b 100644 --- a/integrations/api_nodeinfo_test.go +++ b/integrations/api_nodeinfo_test.go @@ -11,17 +11,20 @@ import ( "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" + "code.gitea.io/gitea/routers" "github.com/stretchr/testify/assert" ) func TestNodeinfo(t *testing.T) { - onGiteaRun(t, func(*testing.T, *url.URL) { - setting.Federation.Enabled = true - defer func() { - setting.Federation.Enabled = false - }() + setting.Federation.Enabled = true + c = routers.NormalRoutes() + defer func() { + setting.Federation.Enabled = false + c = routers.NormalRoutes() + }() + onGiteaRun(t, func(*testing.T, *url.URL) { req := NewRequestf(t, "GET", "/api/v1/nodeinfo") resp := MakeRequest(t, req, http.StatusOK) var nodeinfo api.NodeInfo -- cgit v1.2.3