summaryrefslogtreecommitdiffstats
path: root/integrations
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2022-06-20 01:48:17 +0200
committerGitHub <noreply@github.com>2022-06-20 07:48:17 +0800
commit02d745827bdbe01a82f9f069a904f53197252685 (patch)
tree76fafa40fe638203ea618122a033f04738301da1 /integrations
parente91229eefbd09fecaebd0e058c3bfe7612a0bc61 (diff)
downloadgitea-02d745827bdbe01a82f9f069a904f53197252685.tar.gz
gitea-02d745827bdbe01a82f9f069a904f53197252685.zip
Disable federation by default (#20045)
Diffstat (limited to 'integrations')
-rw-r--r--integrations/api_activitypub_person_test.go34
-rw-r--r--integrations/api_nodeinfo_test.go13
2 files changed, 30 insertions, 17 deletions
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