Skip to content

Commit b0f22ac

Browse files
Rename getProxyAgents to getCustomAgents (elastic#89813)
Co-authored-by: Kibana Machine <[email protected]>
1 parent 2ba8627 commit b0f22ac

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

x-pack/plugins/actions/server/builtin_action_types/lib/axios_utils.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Logger } from '../../../../../../src/core/server';
1010
import { addTimeZoneToDate, request, patch, getErrorMessage } from './axios_utils';
1111
import { loggingSystemMock } from '../../../../../../src/core/server/mocks';
1212
import { actionsConfigMock } from '../../actions_config.mock';
13-
import { getProxyAgents } from './get_proxy_agents';
13+
import { getCustomAgents } from './get_custom_agents';
1414

1515
const logger = loggingSystemMock.create().get() as jest.Mocked<Logger>;
1616
const configurationUtilities = actionsConfigMock.create();
@@ -66,7 +66,7 @@ describe('request', () => {
6666
proxyRejectUnauthorizedCertificates: true,
6767
proxyUrl: 'https://localhost:1212',
6868
});
69-
const { httpAgent, httpsAgent } = getProxyAgents(configurationUtilities, logger);
69+
const { httpAgent, httpsAgent } = getCustomAgents(configurationUtilities, logger);
7070

7171
const res = await request({
7272
axios,

x-pack/plugins/actions/server/builtin_action_types/lib/axios_utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { AxiosInstance, Method, AxiosResponse, AxiosBasicCredentials } from 'axios';
88
import { Logger } from '../../../../../../src/core/server';
9-
import { getProxyAgents } from './get_proxy_agents';
9+
import { getCustomAgents } from './get_custom_agents';
1010
import { ActionsConfigurationUtilities } from '../../actions_config';
1111

1212
export const request = async <T = unknown>({
@@ -29,7 +29,7 @@ export const request = async <T = unknown>({
2929
validateStatus?: (status: number) => boolean;
3030
auth?: AxiosBasicCredentials;
3131
}): Promise<AxiosResponse> => {
32-
const { httpAgent, httpsAgent } = getProxyAgents(configurationUtilities, logger);
32+
const { httpAgent, httpsAgent } = getCustomAgents(configurationUtilities, logger);
3333

3434
return await axios(url, {
3535
...rest,

x-pack/plugins/actions/server/builtin_action_types/lib/get_proxy_agents.test.ts renamed to x-pack/plugins/actions/server/builtin_action_types/lib/get_custom_agents.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ import { Agent as HttpsAgent } from 'https';
88
import HttpProxyAgent from 'http-proxy-agent';
99
import { HttpsProxyAgent } from 'https-proxy-agent';
1010
import { Logger } from '../../../../../../src/core/server';
11-
import { getProxyAgents } from './get_proxy_agents';
11+
import { getCustomAgents } from './get_custom_agents';
1212
import { loggingSystemMock } from '../../../../../../src/core/server/mocks';
1313
import { actionsConfigMock } from '../../actions_config.mock';
1414
const logger = loggingSystemMock.create().get() as jest.Mocked<Logger>;
1515

16-
describe('getProxyAgents', () => {
16+
describe('getCustomAgents', () => {
1717
const configurationUtilities = actionsConfigMock.create();
1818

1919
test('get agents for valid proxy URL', () => {
2020
configurationUtilities.getProxySettings.mockReturnValue({
2121
proxyUrl: 'https://someproxyhost',
2222
proxyRejectUnauthorizedCertificates: false,
2323
});
24-
const { httpAgent, httpsAgent } = getProxyAgents(configurationUtilities, logger);
24+
const { httpAgent, httpsAgent } = getCustomAgents(configurationUtilities, logger);
2525
expect(httpAgent instanceof HttpProxyAgent).toBeTruthy();
2626
expect(httpsAgent instanceof HttpsProxyAgent).toBeTruthy();
2727
});
@@ -31,13 +31,13 @@ describe('getProxyAgents', () => {
3131
proxyUrl: ':nope: not a valid URL',
3232
proxyRejectUnauthorizedCertificates: false,
3333
});
34-
const { httpAgent, httpsAgent } = getProxyAgents(configurationUtilities, logger);
34+
const { httpAgent, httpsAgent } = getCustomAgents(configurationUtilities, logger);
3535
expect(httpAgent).toBe(undefined);
3636
expect(httpsAgent instanceof HttpsAgent).toBeTruthy();
3737
});
3838

3939
test('return default agents for undefined proxy options', () => {
40-
const { httpAgent, httpsAgent } = getProxyAgents(configurationUtilities, logger);
40+
const { httpAgent, httpsAgent } = getCustomAgents(configurationUtilities, logger);
4141
expect(httpAgent).toBe(undefined);
4242
expect(httpsAgent instanceof HttpsAgent).toBeTruthy();
4343
});

x-pack/plugins/actions/server/builtin_action_types/lib/get_proxy_agents.ts renamed to x-pack/plugins/actions/server/builtin_action_types/lib/get_custom_agents.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@ import { HttpsProxyAgent } from 'https-proxy-agent';
1111
import { Logger } from '../../../../../../src/core/server';
1212
import { ActionsConfigurationUtilities } from '../../actions_config';
1313

14-
interface GetProxyAgentsResponse {
14+
interface GetCustomAgentsResponse {
1515
httpAgent: HttpAgent | undefined;
1616
httpsAgent: HttpsAgent | undefined;
1717
}
1818

19-
export function getProxyAgents(
19+
export function getCustomAgents(
2020
configurationUtilities: ActionsConfigurationUtilities,
2121
logger: Logger
22-
): GetProxyAgentsResponse {
22+
): GetCustomAgentsResponse {
2323
const proxySettings = configurationUtilities.getProxySettings();
24-
const defaultResponse = {
24+
const defaultAgents = {
2525
httpAgent: undefined,
2626
httpsAgent: new HttpsAgent({
2727
rejectUnauthorized: configurationUtilities.isRejectUnauthorizedCertificatesEnabled(),
2828
}),
2929
};
3030

3131
if (!proxySettings) {
32-
return defaultResponse;
32+
return defaultAgents;
3333
}
3434

3535
logger.debug(`Creating proxy agents for proxy: ${proxySettings.proxyUrl}`);
@@ -38,7 +38,7 @@ export function getProxyAgents(
3838
proxyUrl = new URL(proxySettings.proxyUrl);
3939
} catch (err) {
4040
logger.warn(`invalid proxy URL "${proxySettings.proxyUrl}" ignored`);
41-
return defaultResponse;
41+
return defaultAgents;
4242
}
4343

4444
const httpAgent = new HttpProxyAgent(proxySettings.proxyUrl);

x-pack/plugins/actions/server/builtin_action_types/slack.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
ExecutorType,
2323
} from '../types';
2424
import { ActionsConfigurationUtilities } from '../actions_config';
25-
import { getProxyAgents } from './lib/get_proxy_agents';
25+
import { getCustomAgents } from './lib/get_custom_agents';
2626

2727
export type SlackActionType = ActionType<{}, ActionTypeSecretsType, ActionParamsType, unknown>;
2828
export type SlackActionTypeExecutorOptions = ActionTypeExecutorOptions<
@@ -130,10 +130,10 @@ async function slackExecutor(
130130
const { message } = params;
131131
const proxySettings = configurationUtilities.getProxySettings();
132132

133-
const proxyAgents = getProxyAgents(configurationUtilities, logger);
134-
const httpProxyAgent = webhookUrl.toLowerCase().startsWith('https')
135-
? proxyAgents.httpsAgent
136-
: proxyAgents.httpAgent;
133+
const customAgents = getCustomAgents(configurationUtilities, logger);
134+
const agent = webhookUrl.toLowerCase().startsWith('https')
135+
? customAgents.httpsAgent
136+
: customAgents.httpAgent;
137137

138138
if (proxySettings) {
139139
logger.debug(`IncomingWebhook was called with proxyUrl ${proxySettings.proxyUrl}`);
@@ -143,7 +143,7 @@ async function slackExecutor(
143143
// https://slack.dev/node-slack-sdk/webhook
144144
// node-slack-sdk use Axios inside :)
145145
const webhook = new IncomingWebhook(webhookUrl, {
146-
agent: httpProxyAgent,
146+
agent,
147147
});
148148
result = await webhook.send(message);
149149
} catch (err) {

0 commit comments

Comments
 (0)