mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 18:16:17 +01:00
test: log outgoing AP messages for local test runner
This commit is contained in:
@@ -48,6 +48,7 @@ ActivityPub._constants = Object.freeze({
|
||||
},
|
||||
});
|
||||
ActivityPub._cache = requestCache;
|
||||
ActivityPub._sent = new Map(); // used only in local tests
|
||||
|
||||
ActivityPub.helpers = require('./helpers');
|
||||
ActivityPub.inbox = require('./inbox');
|
||||
@@ -335,7 +336,12 @@ pubsub.on(`activitypub-retry-queue:lruCache:del`, (keys) => {
|
||||
async function sendMessage(uri, id, type, payload, attempts = 1) {
|
||||
const keyData = await ActivityPub.getPrivateKey(type, id);
|
||||
const headers = await ActivityPub.sign(keyData, uri, payload);
|
||||
|
||||
ActivityPub.helpers.log(`[activitypub/send] ${uri}`);
|
||||
if (process.env.CI === 'true') {
|
||||
ActivityPub._sent.set(payload.id, payload);
|
||||
}
|
||||
|
||||
try {
|
||||
const { response, body } = await request.post(uri, {
|
||||
headers: {
|
||||
|
||||
@@ -21,6 +21,7 @@ const activitypub = require('../src/activitypub');
|
||||
describe('ActivityPub integration', () => {
|
||||
before(async () => {
|
||||
meta.config.activitypubEnabled = 1;
|
||||
meta.config.activitypubAllowLoopback = 1;
|
||||
await install.giveWorldPrivileges();
|
||||
});
|
||||
|
||||
@@ -28,6 +29,16 @@ describe('ActivityPub integration', () => {
|
||||
delete meta.config.activitypubEnabled;
|
||||
});
|
||||
|
||||
describe.only('Outgoing AP logging for test runner', () => {
|
||||
it('should log an entry in ActivityPub._sent when .send is called', async () => {
|
||||
const uuid = utils.generateUUID();
|
||||
const uid = await user.create({ username: uuid });
|
||||
await activitypub.send('uid', 0, [`https://localhost/uid/${uid}`], { id: `${nconf.get('url')}/activity/${uuid}`, foo: 'bar' });
|
||||
|
||||
assert(activitypub._sent.has(`https://localhost/activity/${uuid}`));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Master toggle', () => {
|
||||
before(async () => {
|
||||
delete meta.config.activitypubEnabled;
|
||||
|
||||
Reference in New Issue
Block a user