From 12fb205b0989a7b31b91a97563c18beedbf7b9ca Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 7 Jan 2025 12:20:46 -0500 Subject: [PATCH] fix: activitypub tests --- test/activitypub.js | 12 ++++++++---- test/activitypub/webfinger.js | 4 ++-- test/mocks/databasemock.js | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/test/activitypub.js b/test/activitypub.js index c470ca74ef..9fa2c757af 100644 --- a/test/activitypub.js +++ b/test/activitypub.js @@ -11,6 +11,7 @@ const request = require('../src/request'); const file = require('../src/file'); const install = require('../src/install'); +const privileges = require('../src/privileges'); const meta = require('../src/meta'); const user = require('../src/user'); const categories = require('../src/categories'); @@ -358,9 +359,12 @@ describe('ActivityPub integration', () => { assert(saved.tid); topic = await topics.getTopicData(saved.tid); - assert(topic); - assert.strictEqual(saved.uid, 'https://example.org/user/foobar'); - assert.strictEqual(saved.content, 'Baz quux'); + const { uid, mainPid } = topic; + assert(uid && mainPid); + 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 () => { @@ -501,7 +505,7 @@ describe('ActivityPub integration', () => { it('should return true if successfully asserted', async () => { 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 () => { diff --git a/test/activitypub/webfinger.js b/test/activitypub/webfinger.js index 9e503ebfc3..c408000e9e 100644 --- a/test/activitypub/webfinger.js +++ b/test/activitypub/webfinger.js @@ -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 () => { - 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}`); assert(response); 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 () => { diff --git a/test/mocks/databasemock.js b/test/mocks/databasemock.js index 507f29d6fc..587dd65dcc 100644 --- a/test/mocks/databasemock.js +++ b/test/mocks/databasemock.js @@ -246,6 +246,7 @@ async function giveDefaultGlobalPrivileges() { await privileges.global.give([ 'groups:view:users', 'groups:view:tags', 'groups:view:groups', ], 'guests'); + await privileges.global.give(['groups:view:users'], 'fediverse'); } async function enableDefaultPlugins() {