loading up the forgejo repo on tangled to test page performance
at forgejo 48 lines 1.4 kB view raw
1// Copyright 2024 The Forgejo Authors. All rights reserved. 2// SPDX-License-Identifier: MIT 3 4package integration 5 6import ( 7 "net/http" 8 "testing" 9 10 "forgejo.org/modules/setting" 11 "forgejo.org/modules/test" 12 "forgejo.org/routers" 13 "forgejo.org/tests" 14 15 ap "github.com/go-ap/activitypub" 16 "github.com/stretchr/testify/assert" 17 "github.com/stretchr/testify/require" 18) 19 20func TestActivityPubActor(t *testing.T) { 21 defer test.MockVariableValue(&setting.Federation.Enabled, true)() 22 defer test.MockVariableValue(&testWebRoutes, routers.NormalRoutes())() 23 defer tests.PrepareTestEnv(t)() 24 25 req := NewRequest(t, "GET", "/api/v1/activitypub/actor") 26 resp := MakeRequest(t, req, http.StatusOK) 27 assert.Contains(t, resp.Body.String(), "@context") 28 29 var actor ap.Actor 30 err := actor.UnmarshalJSON(resp.Body.Bytes()) 31 require.NoError(t, err) 32 33 assert.Equal(t, ap.ApplicationType, actor.Type) 34 assert.Equal(t, setting.Domain, actor.PreferredUsername.String()) 35 keyID := actor.GetID().String() 36 assert.Regexp(t, "activitypub/actor$", keyID) 37 assert.Regexp(t, "activitypub/actor/outbox$", actor.Outbox.GetID().String()) 38 assert.Regexp(t, "activitypub/actor/inbox$", actor.Inbox.GetID().String()) 39 40 pubKey := actor.PublicKey 41 assert.NotNil(t, pubKey) 42 publicKeyID := keyID + "#main-key" 43 assert.Equal(t, pubKey.ID.String(), publicKeyID) 44 45 pubKeyPem := pubKey.PublicKeyPem 46 assert.NotNil(t, pubKeyPem) 47 assert.Regexp(t, "^-----BEGIN PUBLIC KEY-----", pubKeyPem) 48}