mirror of
https://github.com/n8n-io/n8n
synced 2026-04-21 15:47:20 +00:00
adding agetntOptions tests
This commit is contained in:
parent
64a0b80472
commit
5cf5de3501
1 changed files with 33 additions and 1 deletions
|
|
@ -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', () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue