mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
fix: Prevent empty path in webhooks (#16864)
Co-authored-by: Roman Davydchuk <roman.davydchuk@n8n.io>
This commit is contained in:
@@ -448,6 +448,56 @@ describe('useWorkflowHelpers', () => {
|
||||
});
|
||||
expect(await workflowHelpers.checkConflictingWebhooks('123')).toEqual(null);
|
||||
});
|
||||
|
||||
it('should return trigger.parameters.path when both trigger.parameters.path and trigger.webhookId are strings', async () => {
|
||||
const workflowHelpers = useWorkflowHelpers();
|
||||
uiStore.stateIsDirty = false;
|
||||
vi.spyOn(workflowsStore, 'fetchWorkflow').mockResolvedValue({
|
||||
nodes: [
|
||||
{
|
||||
type: WEBHOOK_NODE_TYPE,
|
||||
parameters: {
|
||||
method: 'GET',
|
||||
path: 'test-path',
|
||||
},
|
||||
webhookId: 'test-webhook-id',
|
||||
},
|
||||
],
|
||||
} as unknown as IWorkflowDb);
|
||||
const findWebhookSpy = vi.spyOn(apiWebhooks, 'findWebhook');
|
||||
findWebhookSpy.mockResolvedValue(null);
|
||||
expect(await workflowHelpers.checkConflictingWebhooks('12345')).toEqual(null);
|
||||
expect(findWebhookSpy).toBeCalledWith(expect.anything(), {
|
||||
method: 'GET',
|
||||
path: 'test-path',
|
||||
});
|
||||
findWebhookSpy.mockRestore();
|
||||
});
|
||||
|
||||
it('should return trigger.webhookId when trigger.parameters.path is an empty string', async () => {
|
||||
const workflowHelpers = useWorkflowHelpers();
|
||||
uiStore.stateIsDirty = false;
|
||||
vi.spyOn(workflowsStore, 'fetchWorkflow').mockResolvedValue({
|
||||
nodes: [
|
||||
{
|
||||
type: WEBHOOK_NODE_TYPE,
|
||||
parameters: {
|
||||
method: 'GET',
|
||||
path: '',
|
||||
},
|
||||
webhookId: 'test-webhook-id',
|
||||
},
|
||||
],
|
||||
} as unknown as IWorkflowDb);
|
||||
const findWebhookSpy = vi.spyOn(apiWebhooks, 'findWebhook');
|
||||
findWebhookSpy.mockResolvedValue(null);
|
||||
expect(await workflowHelpers.checkConflictingWebhooks('12345')).toEqual(null);
|
||||
expect(findWebhookSpy).toBeCalledWith(expect.anything(), {
|
||||
method: 'GET',
|
||||
path: 'test-webhook-id',
|
||||
});
|
||||
findWebhookSpy.mockRestore();
|
||||
});
|
||||
});
|
||||
|
||||
describe('executeData', () => {
|
||||
|
||||
Reference in New Issue
Block a user