mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-12 22:10:25 +00:00
- Massive replacement of changing `code.gitea.io/gitea` to `forgejo.org`. - Resolves forgejo/discussions#258 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7337 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Reviewed-by: Beowulf <beowulf@beocode.eu> Reviewed-by: Panagiotis "Ivory" Vasilopoulos <git@n0toose.net> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package integration
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"forgejo.org/modules/setting"
|
|
"forgejo.org/modules/test"
|
|
"forgejo.org/routers"
|
|
"forgejo.org/tests"
|
|
|
|
ap "github.com/go-ap/activitypub"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestActivityPubActor(t *testing.T) {
|
|
defer test.MockVariableValue(&setting.Federation.Enabled, true)()
|
|
defer test.MockVariableValue(&testWebRoutes, routers.NormalRoutes())()
|
|
defer tests.PrepareTestEnv(t)()
|
|
|
|
req := NewRequest(t, "GET", "/api/v1/activitypub/actor")
|
|
resp := MakeRequest(t, req, http.StatusOK)
|
|
assert.Contains(t, resp.Body.String(), "@context")
|
|
|
|
var actor ap.Actor
|
|
err := actor.UnmarshalJSON(resp.Body.Bytes())
|
|
require.NoError(t, err)
|
|
|
|
assert.Equal(t, ap.ApplicationType, actor.Type)
|
|
assert.Equal(t, setting.Domain, actor.PreferredUsername.String())
|
|
keyID := actor.GetID().String()
|
|
assert.Regexp(t, "activitypub/actor$", keyID)
|
|
assert.Regexp(t, "activitypub/actor/outbox$", actor.Outbox.GetID().String())
|
|
assert.Regexp(t, "activitypub/actor/inbox$", actor.Inbox.GetID().String())
|
|
|
|
pubKey := actor.PublicKey
|
|
assert.NotNil(t, pubKey)
|
|
publicKeyID := keyID + "#main-key"
|
|
assert.Equal(t, pubKey.ID.String(), publicKeyID)
|
|
|
|
pubKeyPem := pubKey.PublicKeyPem
|
|
assert.NotNil(t, pubKeyPem)
|
|
assert.Regexp(t, "^-----BEGIN PUBLIC KEY-----", pubKeyPem)
|
|
}
|