adding agetntOptions tests

This commit is contained in:
Marcus 2026-04-21 08:25:59 +02:00
parent 64a0b80472
commit 5cf5de3501

View file

@ -31,6 +31,8 @@ import {
requestOAuth2,
} from '../request-helper-functions';
const TEST_CA_CERT = '-----BEGIN CERTIFICATE-----\nTEST\n-----END CERTIFICATE-----';
describe('Request Helper Functions', () => {
describe('proxyRequestToAxios', () => {
const baseUrl = 'https://example.de';
@ -447,7 +449,7 @@ describe('Request Helper Functions', () => {
describe('should set SSL certificates', () => {
const agentOptions: SecureContextOptions = {
ca: '-----BEGIN CERTIFICATE-----\nTEST\n-----END CERTIFICATE-----',
ca: TEST_CA_CERT,
};
const requestObject: IRequestOptions = {
method: 'GET',
@ -644,6 +646,36 @@ describe('Request Helper Functions', () => {
expect(axiosConfig.validateStatus!(401)).toBe(true);
expect(axiosConfig.validateStatus!(500)).toBe(true);
});
test('should pass agentOptions through to the https agent', () => {
const requestOptions: IHttpRequestOptions = {
method: 'GET',
url: 'https://example.com',
agentOptions: {
ca: TEST_CA_CERT,
},
};
const axiosConfig = convertN8nRequestToAxios(requestOptions);
expect((axiosConfig.httpsAgent as HttpsAgent).options.ca).toBe(TEST_CA_CERT);
});
test('should merge agentOptions with skipSslCertificateValidation', () => {
const requestOptions: IHttpRequestOptions = {
method: 'GET',
url: 'https://example.com',
skipSslCertificateValidation: true,
agentOptions: {
ca: TEST_CA_CERT,
},
};
const axiosConfig = convertN8nRequestToAxios(requestOptions);
expect((axiosConfig.httpsAgent as HttpsAgent).options.rejectUnauthorized).toBe(false);
expect((axiosConfig.httpsAgent as HttpsAgent).options.ca).toBe(TEST_CA_CERT);
});
});
describe('applyPaginationRequestData', () => {