Skip to content

Node.js based forum software built for the modern web

tests: fix privileges in test runner

Julian Lamaadac7053a4c
diff --git a/src/activitypub/notes.js b/src/activitypub/notes.js
index 1b21de5b77..d84ecaa735 100644
--- a/src/activitypub/notes.js
+++ b/src/activitypub/notes.js
@@ -211,7 +211,6 @@ Notes.assertTopic = async (uid, id) => {
// Privilege check for local categories
const privilege = `topics:${tid ? 'reply' : 'create'}`;
const allowed = await privileges.categories.can(privilege, cid, activitypub._constants.uid);
- console.log(privilege, cid, allowed);
if (!allowed) {
return null;
}
diff --git a/src/install.js b/src/install.js
index 20c429a521..5be12763a2 100644
--- a/src/install.js
+++ b/src/install.js
@@ -662,3 +662,5 @@ install.save = async function (server_conf) {
file: serverConfigPath,
});
};
+
+install.giveWorldPrivileges = giveWorldPrivileges; // exported for upgrade script and test runner
diff --git a/src/upgrades/4.0.0/assign_world_privileges.js b/src/upgrades/4.0.0/assign_world_privileges.js
index d8d4555d6e..720843e757 100644
--- a/src/upgrades/4.0.0/assign_world_privileges.js
+++ b/src/upgrades/4.0.0/assign_world_privileges.js
@@ -6,33 +6,7 @@ module.exports = {
name: 'Assigning default privileges to "World" pseudo-category',
timestamp: Date.UTC(2024, 1, 22),
method: async () => {
- const privileges = require('../../privileges');
-
- // should match privilege assignment logic in src/categories/create.js EXCEPT commented one liner below
- const defaultPrivileges = [
- 'groups:find',
- 'groups:read',
- 'groups:topics:read',
- 'groups:topics:create',
- 'groups:topics:reply',
- 'groups:topics:tag',
- 'groups:posts:edit',
- 'groups:posts:history',
- 'groups:posts:delete',
- 'groups:posts:upvote',
- 'groups:posts:downvote',
- 'groups:topics:delete',
- ];
- const modPrivileges = defaultPrivileges.concat([
- 'groups:topics:schedule',
- 'groups:posts:view_deleted',
- 'groups:purge',
- ]);
- const guestPrivileges = ['groups:find', 'groups:read', 'groups:topics:read'];
-
- await privileges.categories.give(defaultPrivileges, -1, ['registered-users']);
- await privileges.categories.give(defaultPrivileges.slice(3), -1, ['fediverse']); // different priv set for fediverse
- await privileges.categories.give(modPrivileges, -1, ['administrators', 'Global Moderators']);
- await privileges.categories.give(guestPrivileges, -1, ['guests', 'spiders']);
+ const install = require('../../install');
+ await install.giveWorldPrivileges();
},
};
diff --git a/test/activitypub.js b/test/activitypub.js
index 936a7b0add..857b2a86a9 100644
--- a/test/activitypub.js
+++ b/test/activitypub.js
@@ -9,6 +9,7 @@ const slugify = require('../src/slugify');
const utils = require('../src/utils');
const request = require('../src/request');
+const install = require('../src/install');
const meta = require('../src/meta');
const user = require('../src/user');
const categories = require('../src/categories');
@@ -18,8 +19,9 @@ const privileges = require('../src/privileges');
const activitypub = require('../src/activitypub');
describe('ActivityPub integration', () => {
- before(() => {
+ before(async () => {
meta.config.activitypubEnabled = 1;
+ await install.giveWorldPrivileges();
});
after(() => {
@@ -467,9 +469,6 @@ describe('ActivityPub integration', () => {
object: remoteNote,
},
}, { sendStatus: () => {} });
-
- const tid = await posts.getPostField(id, 'tid');
- const topic = await topics.getTopicData(tid);
});
it('should create a new topic if Note is at root-level or its parent has not been seen before', async () => {