mirror of
https://github.com/logto-io/logto.git
synced 2025-03-17 22:31:28 -05:00
refactor(core): return 422 if failed to send a webhook test payload (#3970)
This commit is contained in:
parent
7dc7b0c934
commit
12ae2622b1
4 changed files with 5 additions and 5 deletions
|
@ -147,7 +147,7 @@ describe('testHook', () => {
|
|||
new RequestError({
|
||||
code: 'hook.send_test_payload_failed',
|
||||
message: 'test error',
|
||||
status: 500,
|
||||
status: 422,
|
||||
})
|
||||
);
|
||||
});
|
||||
|
|
|
@ -154,7 +154,7 @@ export const createHookLibrary = (queries: Queries) => {
|
|||
throw new RequestError({
|
||||
code: 'hook.send_test_payload_failed',
|
||||
message: conditional(error instanceof Error && String(error)) ?? 'Unknown error',
|
||||
status: 500,
|
||||
status: 422,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -159,7 +159,7 @@ export default function hookRoutes<T extends AuthedRouter>(
|
|||
koaGuard({
|
||||
params: z.object({ id: z.string() }),
|
||||
body: z.object({ events: nonemptyUniqueHookEventsGuard, config: hookConfigGuard }),
|
||||
status: [204, 404, 500],
|
||||
status: [204, 404, 422],
|
||||
}),
|
||||
async (ctx, next) => {
|
||||
const {
|
||||
|
|
|
@ -53,14 +53,14 @@ describe('hook testing', () => {
|
|||
).rejects.toMatchObject(createResponseWithCode(404));
|
||||
});
|
||||
|
||||
it('should return 500 if the hook endpoint is not working', async () => {
|
||||
it('should return 422 if the hook endpoint is not working', async () => {
|
||||
const payload = getHookCreationPayload(HookEvent.PostRegister);
|
||||
const created = await authedAdminApi.post('hooks', { json: payload }).json<Hook>();
|
||||
await expect(
|
||||
authedAdminApi.post(`hooks/${created.id}/test`, {
|
||||
json: { events: [HookEvent.PostSignIn], config: { url: 'not_work_url' } },
|
||||
})
|
||||
).rejects.toMatchObject(createResponseWithCode(500));
|
||||
).rejects.toMatchObject(createResponseWithCode(422));
|
||||
|
||||
// Clean Up
|
||||
await authedAdminApi.delete(`hooks/${created.id}`);
|
||||
|
|
Loading…
Add table
Reference in a new issue