fix: scheduled topics and posts should return 404 on AP request

This commit is contained in:
Julian Lam
2025-02-27 13:34:11 -05:00
parent 01be4d7908
commit 428300de4f
2 changed files with 81 additions and 10 deletions

View File

@@ -253,7 +253,7 @@ describe('Controllers', () => {
});
});
describe.only('Topic', () => {
describe('Topic Collection endpoint', () => {
let cid;
let uid;
@@ -265,12 +265,11 @@ describe('Controllers', () => {
describe('Live', () => {
let topicData;
let postData;
let response;
let body;
before(async () => {
({ topicData, postData } = await topics.post({
({ topicData } = await topics.post({
uid,
cid,
title: 'Lorem "Lipsum" Ipsum',
@@ -299,12 +298,11 @@ describe('Controllers', () => {
describe('Scheduled', () => {
let topicData;
let postData;
let response;
let body;
before(async () => {
({ topicData, postData } = await topics.post({
({ topicData } = await topics.post({
uid,
cid,
title: 'Lorem "Lipsum" Ipsum',
@@ -325,4 +323,73 @@ describe('Controllers', () => {
});
});
});
describe('Post Object endpoint', () => {
let cid;
let uid;
before(async () => {
({ cid } = await categories.create({ name: utils.generateUUID().slice(0, 8) }));
const slug = slugify(utils.generateUUID().slice(0, 8));
uid = await user.create({ username: slug });
});
describe('Live', () => {
let postData;
let response;
let body;
before(async () => {
({ postData } = await topics.post({
uid,
cid,
title: 'Lorem "Lipsum" Ipsum',
content: 'Lorem ipsum dolor sit amet',
}));
({ response, body } = await request.get(`${nconf.get('url')}/post/${postData.pid}`, {
headers: {
Accept: 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
},
}));
});
it('should respond properly', async () => {
assert(response);
assert.strictEqual(response.statusCode, 200);
});
it('should return a Note type object', () => {
assert.strictEqual(body.type, 'Note');
});
});
describe('Scheduled', () => {
let topicData;
let postData;
let response;
let body;
before(async () => {
({ topicData, postData } = await topics.post({
uid,
cid,
title: 'Lorem "Lipsum" Ipsum',
content: 'Lorem ipsum dolor sit amet',
timestamp: Date.now() + (1000 * 60 * 60), // 1 hour in the future
}));
({ response, body } = await request.get(`${nconf.get('url')}/post/${postData.pid}`, {
headers: {
Accept: 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
},
}));
});
it('should respond with a 404 Not Found', async () => {
assert(response);
assert.strictEqual(response.statusCode, 404);
});
});
});
});