Skip to content

Commit

Permalink
Fixed tests and some changes due to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed Aug 14, 2020
1 parent 2dacff0 commit bb9fcac
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function getProxyAgent(
): HttpsProxyAgent | HttpProxyAgent {
logger.debug(`Create proxy agent for ${proxySettings.proxyUrl}.`);

if (/^https/.test(proxySettings.proxyUrl)) {
if (/^https/i.test(proxySettings.proxyUrl)) {
const proxyUrl = new URL(proxySettings.proxyUrl);
return new HttpsProxyAgent({
host: proxyUrl.hostname,
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/actions/server/builtin_action_types/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async function slackExecutor(
});
result = await webhook.send(message);
} catch (err) {
logger.warn(`error on ${actionId} slack event: ${err.message}`);
logger.error(`error on ${actionId} slack event: ${err.message}`);

if (err.original == null || err.original.response == null) {
return serviceErrorResult(actionId, err.message);
Expand Down Expand Up @@ -161,7 +161,7 @@ async function slackExecutor(
},
}
);
logger.warn(`error on ${actionId} slack action: ${errMessage}`);
logger.error(`error on ${actionId} slack action: ${errMessage}`);

return errorResult(actionId, errMessage);
}
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/actions/server/builtin_action_types/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export async function executor(
if (error.response) {
const { status, statusText, headers: responseHeaders } = error.response;
const message = `[${status}] ${statusText}`;
logger.warn(`error on ${actionId} webhook event: ${message}`);
logger.error(`error on ${actionId} webhook event: ${message}`);
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
// special handling for 5xx
Expand All @@ -184,7 +184,7 @@ export async function executor(
return errorResultInvalid(actionId, message);
}

logger.warn(`error on ${actionId} webhook action: unexpected error`);
logger.error(`error on ${actionId} webhook action: unexpected error`);
return errorResultUnexpectedError(actionId);
}
}
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/actions/server/lib/action_executor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ actionExecutor.initialize({
encryptedSavedObjectsClient,
eventLogger: eventLoggerMock.create(),
preconfiguredActions: [],
rejectUnauthorizedCertificates: true,
});

beforeEach(() => {
Expand Down Expand Up @@ -315,7 +314,6 @@ test('throws an error when passing isESOUsingEphemeralEncryptionKey with value o
encryptedSavedObjectsClient,
eventLogger: eventLoggerMock.create(),
preconfiguredActions: [],
rejectUnauthorizedCertificates: true,
});
await expect(
customActionExecutor.execute(executeParams)
Expand Down
7 changes: 4 additions & 3 deletions x-pack/test/alerting_api_integration/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions)
);

const actionsProxyUrl = options.enableActionsProxy
? `http://localhost:${await getPort()}`
: undefined;
? [`--xpack.actions.proxyUrl=http://localhost:${await getPort()}`]
: [];

return {
testFiles: [require.resolve(`../${name}/tests/`)],
Expand Down Expand Up @@ -91,8 +91,9 @@ export function createTestConfig(name: string, options: CreateTestConfigOptions)
])}`,
'--xpack.encryptedSavedObjects.encryptionKey="wuGNaIhoMpk5sO4UBxgr3NyW1sFcLgIf"',
`--xpack.actions.enabledActionTypes=${JSON.stringify(enabledActionTypes)}`,
`--xpack.actions.proxyUrl=${actionsProxyUrl}`,
...actionsProxyUrl,
'--xpack.actions.rejectUnauthorizedCertificates=false',

'--xpack.eventLog.logEntries=true',
`--xpack.actions.preconfigured=${JSON.stringify({
'my-slack1': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export const getHttpProxyServer = (
};

export const getProxyUrl = (kbnTestServerConfig: any) => {
const proxySlackSimulatorURL = kbnTestServerConfig
const proxyUrl = kbnTestServerConfig
.find((val: string) => val.startsWith('--xpack.actions.proxyUrl='))
.replace('--xpack.actions.proxyUrl=', '');

return new URL(proxySlackSimulatorURL);
return new URL(proxyUrl);
};
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export default function webhookTest({ getService }: FtrProviderContext) {
.expect(200);

expect(result.status).to.eql('error');
expect(result.message).to.match(/error calling webhook, unexpected error/);
expect(result.message).to.match(/error calling webhook, retry later/);
});

it('should handle failing webhook targets', async () => {
Expand Down

0 comments on commit bb9fcac

Please sign in to comment.