Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into kbn-136040-server-s…
Browse files Browse the repository at this point in the history
…ide-rendering
  • Loading branch information
pgayvallet committed Sep 28, 2022
2 parents 262dfb8 + a47918d commit ee29bc5
Show file tree
Hide file tree
Showing 93 changed files with 4,002 additions and 353 deletions.
22 changes: 22 additions & 0 deletions x-pack/plugins/actions/server/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,28 @@ describe('config validation', () => {
`);
});

test('validates proxyUrl', () => {
const proxyUrl = 'https://test.com';
const badProxyUrl = 'bad url';
let validated: ActionsConfig;

validated = configSchema.validate({ proxyUrl });
expect(validated.proxyUrl).toEqual(proxyUrl);
expect(getValidatedConfig(mockLogger, validated).proxyUrl).toEqual(proxyUrl);
expect(mockLogger.warn.mock.calls).toMatchInlineSnapshot(`Array []`);

validated = configSchema.validate({ proxyUrl: badProxyUrl });
expect(validated.proxyUrl).toEqual(badProxyUrl);
expect(getValidatedConfig(mockLogger, validated).proxyUrl).toEqual(badProxyUrl);
expect(mockLogger.warn.mock.calls).toMatchInlineSnapshot(`
Array [
Array [
"The confguration xpack.actions.proxyUrl: bad url is invalid.",
],
]
`);
});

// Most of the customHostSettings tests are in ./lib/custom_host_settings.test.ts
// but this one seemed more relevant for this test suite, since url is the one
// required property.
Expand Down
9 changes: 9 additions & 0 deletions x-pack/plugins/actions/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ export type ActionsConfig = TypeOf<typeof configSchema>;
export function getValidatedConfig(logger: Logger, originalConfig: ActionsConfig): ActionsConfig {
const proxyBypassHosts = originalConfig.proxyBypassHosts;
const proxyOnlyHosts = originalConfig.proxyOnlyHosts;
const proxyUrl = originalConfig.proxyUrl;

if (proxyUrl) {
try {
new URL(proxyUrl);
} catch (err) {
logger.warn(`The confguration xpack.actions.proxyUrl: ${proxyUrl} is invalid.`);
}
}

if (proxyBypassHosts && proxyOnlyHosts) {
logger.warn(
Expand Down
13 changes: 13 additions & 0 deletions x-pack/plugins/alerting/common/execution_log_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ export const actionErrorLogSortableColumns = [
'event.action',
];

export const EMPTY_EXECUTION_KPI_RESULT = {
success: 0,
unknown: 0,
failure: 0,
activeAlerts: 0,
newAlerts: 0,
recoveredAlerts: 0,
erroredActions: 0,
triggeredActions: 0,
};

export type ExecutionLogSortFields = typeof executionLogSortableColumns[number];

export type ActionErrorLogSortFields = typeof actionErrorLogSortableColumns[number];
Expand Down Expand Up @@ -68,3 +79,5 @@ export interface IExecutionLogResult {
total: number;
data: IExecutionLog[];
}

export type IExecutionKPIResult = typeof EMPTY_EXECUTION_KPI_RESULT;
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export enum ReadOperations {
Find = 'find',
GetAuthorizedAlertsIndices = 'getAuthorizedAlertsIndices',
RunSoon = 'runSoon',
GetRuleExecutionKPI = 'getRuleExecutionKPI',
}

export enum WriteOperations {
Expand Down
Loading

0 comments on commit ee29bc5

Please sign in to comment.