fix(core): Ensure maxRedirects is used for any http request defining it (#8706)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-02-22 17:56:48 +01:00
committed by GitHub
parent 8c4a744c56
commit 246c988b93
5 changed files with 62 additions and 17 deletions

View File

@@ -11,6 +11,7 @@ import type { IncomingMessage } from 'http';
import { mock } from 'jest-mock-extended';
import type {
IBinaryData,
IHttpRequestMethods,
INode,
ITaskDataConnections,
IWorkflowExecuteAdditionalData,
@@ -368,6 +369,46 @@ describe('NodeExecuteFunctions', () => {
});
expect((axiosOptions.httpsAgent as Agent).options.servername).toEqual('example.de');
});
describe('when followRedirect is true', () => {
test.each(['GET', 'HEAD'] as IHttpRequestMethods[])(
'should set maxRedirects on %s ',
async (method) => {
const axiosOptions = await parseRequestObject({
method,
followRedirect: true,
maxRedirects: 1234,
});
expect(axiosOptions.maxRedirects).toEqual(1234);
},
);
test.each(['POST', 'PUT', 'PATCH', 'DELETE'] as IHttpRequestMethods[])(
'should not set maxRedirects on %s ',
async (method) => {
const axiosOptions = await parseRequestObject({
method,
followRedirect: true,
maxRedirects: 1234,
});
expect(axiosOptions.maxRedirects).toEqual(0);
},
);
});
describe('when followAllRedirects is true', () => {
test.each(['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE'] as IHttpRequestMethods[])(
'should set maxRedirects on %s ',
async (method) => {
const axiosOptions = await parseRequestObject({
method,
followAllRedirects: true,
maxRedirects: 1234,
});
expect(axiosOptions.maxRedirects).toEqual(1234);
},
);
});
});
describe('copyInputItems', () => {