fix: activitypub tests

This commit is contained in:
Julian Lam
2025-01-07 12:20:46 -05:00
parent de076a213a
commit 12fb205b09
3 changed files with 11 additions and 6 deletions

View File

@@ -11,6 +11,7 @@ const request = require('../src/request');
const file = require('../src/file'); const file = require('../src/file');
const install = require('../src/install'); const install = require('../src/install');
const privileges = require('../src/privileges');
const meta = require('../src/meta'); const meta = require('../src/meta');
const user = require('../src/user'); const user = require('../src/user');
const categories = require('../src/categories'); const categories = require('../src/categories');
@@ -358,9 +359,12 @@ describe('ActivityPub integration', () => {
assert(saved.tid); assert(saved.tid);
topic = await topics.getTopicData(saved.tid); topic = await topics.getTopicData(saved.tid);
assert(topic); const { uid, mainPid } = topic;
assert.strictEqual(saved.uid, 'https://example.org/user/foobar'); assert(uid && mainPid);
assert.strictEqual(saved.content, '<b>Baz quux</b>'); const { content, sourceContent } = await posts.getPostData(mainPid);
assert.strictEqual(uid, 'https://example.org/user/foobar');
assert.strictEqual(content, '');
assert.strictEqual(sourceContent, '**Baz quux**');
}); });
it('should properly save the topic title in the topic hash', async () => { it('should properly save the topic title in the topic hash', async () => {
@@ -501,7 +505,7 @@ describe('ActivityPub integration', () => {
it('should return true if successfully asserted', async () => { it('should return true if successfully asserted', async () => {
const result = await activitypub.actors.assert([actorUri]); const result = await activitypub.actors.assert([actorUri]);
assert(result); assert(result && result.length);
}); });
it('should contain a representation of that remote user in the database', async () => { it('should contain a representation of that remote user in the database', async () => {

View File

@@ -34,12 +34,12 @@ describe('WebFinger endpoint', () => {
}); });
it('should return 403 Forbidden if the calling user is not allowed to view the user list/profiles', async () => { it('should return 403 Forbidden if the calling user is not allowed to view the user list/profiles', async () => {
await privileges.global.rescind(['groups:view:users'], 'guests'); await privileges.global.rescind(['groups:view:users'], 'fediverse');
const { response } = await request.get(`${nconf.get('url')}/.well-known/webfinger?resource=acct%3a${slug}%40${host}`); const { response } = await request.get(`${nconf.get('url')}/.well-known/webfinger?resource=acct%3a${slug}%40${host}`);
assert(response); assert(response);
assert.strictEqual(response.statusCode, 400); assert.strictEqual(response.statusCode, 400);
await privileges.global.give(['groups:view:users'], 'guests'); await privileges.global.give(['groups:view:users'], 'fediverse');
}); });
it('should return a valid WebFinger response otherwise', async () => { it('should return a valid WebFinger response otherwise', async () => {

View File

@@ -246,6 +246,7 @@ async function giveDefaultGlobalPrivileges() {
await privileges.global.give([ await privileges.global.give([
'groups:view:users', 'groups:view:tags', 'groups:view:groups', 'groups:view:users', 'groups:view:tags', 'groups:view:groups',
], 'guests'); ], 'guests');
await privileges.global.give(['groups:view:users'], 'fediverse');
} }
async function enableDefaultPlugins() { async function enableDefaultPlugins() {