mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
tests: fix privileges in test runner
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -662,3 +662,5 @@ install.save = async function (server_conf) {
|
||||
file: serverConfigPath,
|
||||
});
|
||||
};
|
||||
|
||||
install.giveWorldPrivileges = giveWorldPrivileges; // exported for upgrade script and test runner
|
||||
|
||||
@@ -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();
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user