Handle non-existent shareId
This commit is contained in:
@ -174,6 +174,9 @@ router.post('documents.info', auth({ required: false }), async ctx => {
|
||||
},
|
||||
],
|
||||
});
|
||||
if (!share) {
|
||||
throw new InvalidRequestError('Document could not be found for shareId');
|
||||
}
|
||||
document = share.document;
|
||||
} else {
|
||||
document = await Document.findById(id);
|
||||
|
@ -73,6 +73,13 @@ describe('#documents.info', async () => {
|
||||
expect(body.data.createdBy.id).toEqual(user.id);
|
||||
expect(body.data.updatedBy.id).toEqual(user.id);
|
||||
});
|
||||
|
||||
it('should require a valid shareId', async () => {
|
||||
const res = await server.post('/api/documents.info', {
|
||||
body: { shareId: 123 },
|
||||
});
|
||||
expect(res.status).toEqual(400);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#documents.list', async () => {
|
||||
|
Reference in New Issue
Block a user