Skip to content

Commit

Permalink
Merge branch 'master' into prevent-rerenders-observability-flyout
Browse files Browse the repository at this point in the history
  • Loading branch information
kqualters-elastic committed Aug 16, 2021
2 parents 7bfe3b2 + 3ffd6af commit 551c1d5
Show file tree
Hide file tree
Showing 115 changed files with 1,834 additions and 1,057 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"@elastic/datemath": "link:bazel-bin/packages/elastic-datemath",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.14",
"@elastic/ems-client": "7.14.0",
"@elastic/eui": "36.1.0",
"@elastic/eui": "37.1.1",
"@elastic/filesaver": "1.1.2",
"@elastic/good": "^9.0.1-kibana3",
"@elastic/maki": "6.3.0",
Expand Down
7 changes: 2 additions & 5 deletions packages/kbn-rule-data-utils/src/alerts_as_data_rbac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ import type { EsQueryConfig } from '@kbn/es-query';
* registering a new instance of the rule data client
* in a new plugin will require updating the below data structure
* to include the index name where the alerts as data will be written to.
*
* This doesn't work in combination with the `xpack.ruleRegistry.index`
* setting, with which the user can change the index prefix.
*/

export const AlertConsumers = {
Expand All @@ -24,7 +21,7 @@ export const AlertConsumers = {
INFRASTRUCTURE: 'infrastructure',
OBSERVABILITY: 'observability',
SIEM: 'siem',
SYNTHETICS: 'synthetics',
UPTIME: 'uptime',
} as const;
export type AlertConsumers = typeof AlertConsumers[keyof typeof AlertConsumers];
export type STATUS_VALUES = 'open' | 'acknowledged' | 'closed' | 'in-progress'; // TODO: remove 'in-progress' after migration to 'acknowledged'
Expand All @@ -35,7 +32,7 @@ export const mapConsumerToIndexName: Record<AlertConsumers, string | string[]> =
infrastructure: '.alerts-observability.metrics',
observability: '.alerts-observability',
siem: ['.alerts-security.alerts', '.siem-signals'],
synthetics: '.alerts-observability-synthetics',
uptime: '.alerts-observability.uptime',
};
export type ValidFeatureId = keyof typeof mapConsumerToIndexName;

Expand Down
2 changes: 2 additions & 0 deletions src/core/public/i18n/__snapshots__/i18n_service.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/core/public/i18n/i18n_eui_mapping.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,16 @@ export const getEuiContextMapping = (): EuiTokensObject => {
description: 'Descending size label',
}
),
'euiDatePopoverButton.invalidTitle': ({ title }: EuiValues) =>
i18n.translate('core.euiDatePopoverButton.invalidTitle', {
defaultMessage: 'Invalid date: {title}',
values: { title },
}),
'euiDatePopoverButton.outdatedTitle': ({ title }: EuiValues) =>
i18n.translate('core.euiDatePopoverButton.outdatedTitle', {
defaultMessage: 'Update needed: {title}',
values: { title },
}),
'euiFieldPassword.showPassword': i18n.translate('core.euiFieldPassword.showPassword', {
defaultMessage:
'Show password as plain text. Note: this will visually expose your password on the screen.',
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/environment/resolve_uuid.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,15 @@ describe('resolveInstanceUuid', () => {
await expect(
resolveInstanceUuid({ pathConfig, serverConfig, logger })
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Unable to read Kibana UUID file, please check the uuid.server configuration value in kibana.yml and ensure Kibana has sufficient permissions to read / write to this file. Error was: EACCES"`
`"Unable to read UUID file at data-folder/uuid. Ensure Kibana has sufficient permissions to read / write to this file. Error was: EACCES"`
);
});
it('throws an explicit error for file write errors', async () => {
mockWriteFile(isDirectoryError);
await expect(
resolveInstanceUuid({ pathConfig, serverConfig, logger })
).rejects.toThrowErrorMatchingInlineSnapshot(
`"Unable to write Kibana UUID file, please check the uuid.server configuration value in kibana.yml and ensure Kibana has sufficient permissions to read / write to this file. Error was: EISDIR"`
`"Unable to write to UUID file at data-folder/uuid. Ensure Kibana has sufficient permissions to read / write to this file. Error was: EISDIR"`
);
});
});
Expand Down
8 changes: 4 additions & 4 deletions src/core/server/environment/resolve_uuid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ async function readUuidFromFile(filepath: string, logger: Logger): Promise<strin
return undefined;
}
throw new Error(
'Unable to read Kibana UUID file, please check the uuid.server configuration ' +
'value in kibana.yml and ensure Kibana has sufficient permissions to read / write to this file. ' +
`Unable to read UUID file at ${filepath}. ` +
'Ensure Kibana has sufficient permissions to read / write to this file. ' +
`Error was: ${e.code}`
);
}
Expand All @@ -91,8 +91,8 @@ async function writeUuidToFile(filepath: string, uuidValue: string) {
return await writeFile(filepath, uuidValue, { encoding: FILE_ENCODING });
} catch (e) {
throw new Error(
'Unable to write Kibana UUID file, please check the uuid.server configuration ' +
'value in kibana.yml and ensure Kibana has sufficient permissions to read / write to this file. ' +
`Unable to write to UUID file at ${filepath}. ` +
'Ensure Kibana has sufficient permissions to read / write to this file. ' +
`Error was: ${e.code}`
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@
* Side Public License, v 1.
*/

import type { KibanaExecutionContext } from '../../types';
import type {
IExecutionContext,
InternalExecutionContextSetup,
ExecutionContextSetup,
} from './execution_context_service';

// attempted removal of any: unsuccessful! In theory, replaceable with <R>/R
function withContextMock(context: KibanaExecutionContext | undefined, fn: () => any): any {
return fn();
}

const createExecutionContextMock = () => {
const mock: jest.Mocked<IExecutionContext> = {
set: jest.fn(),
Expand All @@ -21,6 +27,7 @@ const createExecutionContextMock = () => {
getParentContextFrom: jest.fn(),
getAsHeader: jest.fn(),
};
mock.withContext.mockImplementation(withContextMock);
return mock;
};
const createInternalSetupContractMock = () => {
Expand All @@ -32,6 +39,7 @@ const createSetupContractMock = () => {
const mock: jest.Mocked<ExecutionContextSetup> = {
withContext: jest.fn(),
};
mock.withContext.mockImplementation(withContextMock);
return mock;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ describe('ExecutionContextService', () => {
id: 'id-a',
description: 'description-a',
},
(i) => i
() => null
);
expect(loggingSystemMock.collect(core.logger).debug).toMatchInlineSnapshot(`
Array [
Expand Down Expand Up @@ -378,6 +378,26 @@ describe('ExecutionContextService', () => {

expect(result).toBeUndefined();
});
it('executes provided function when disabled', async () => {
const coreWithDisabledService = mockCoreContext.create();
coreWithDisabledService.configService.atPath.mockReturnValue(
new BehaviorSubject({ enabled: false })
);
const disabledService = new ExecutionContextService(coreWithDisabledService).setup();
const fn = jest.fn();

disabledService.withContext(
{
type: 'type-b',
name: 'name-b',
id: 'id-b',
description: 'description-b',
},
fn
);

expect(fn).toHaveBeenCalledTimes(1);
});
});

describe('getAsHeader', () => {
Expand All @@ -387,6 +407,21 @@ describe('ExecutionContextService', () => {
expect(service.getAsHeader()).toBe('1234');
});

it('falls back to "unknownId" if no id provided', async () => {
expect(service.getAsHeader()).toBe('unknownId');
});

it('falls back to "unknownId" and context if no id provided', async () => {
service.set({
type: 'type-a',
name: 'name-a',
id: 'id-a',
description: 'description-a',
});

expect(service.getAsHeader()).toBe('unknownId;kibana:type-a:name-a:id-a');
});

it('returns request id and registered context', async () => {
service.setRequestId('1234');
service.set({
Expand Down
11 changes: 7 additions & 4 deletions src/core/server/execution_context/execution_context_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface IExecutionContext {
* https://nodejs.org/api/async_context.html#async_context_asynclocalstorage_enterwith_store
*/
get(): IExecutionContextContainer | undefined;
withContext<R>(context: KibanaExecutionContext | undefined, fn: (...args: any[]) => R): R;
withContext<R>(context: KibanaExecutionContext | undefined, fn: () => R): R;
/**
* returns serialized representation to send as a header
**/
Expand Down Expand Up @@ -153,8 +153,11 @@ export class ExecutionContextService

private getAsHeader(): string | undefined {
if (!this.enabled) return;
const stringifiedCtx = this.contextStore.getStore()?.toString();
const requestId = this.requestIdStore.getStore()?.requestId;
return stringifiedCtx ? `${requestId};kibana:${stringifiedCtx}` : requestId;
// requestId may not be present in the case of FakeRequest
const requestId = this.requestIdStore.getStore()?.requestId ?? 'unknownId';
const executionContext = this.contextStore.getStore()?.toString();
const executionContextStr = executionContext ? `;kibana:${executionContext}` : '';

return `${requestId}${executionContextStr}`;
}
}
2 changes: 1 addition & 1 deletion src/dev/license_checker/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const LICENSE_OVERRIDES = {
'@mapbox/jsonlint-lines-primitives@2.0.2': ['MIT'], // license in readme https://github.com/tmcw/jsonlint
'node-sql-parser@3.6.1': ['(GPL-2.0 OR MIT)'], // GPL-2.0* https://github.com/taozhi8833998/node-sql-parser
'@elastic/ems-client@7.14.0': ['Elastic License 2.0'],
'@elastic/eui@36.0.0': ['SSPL-1.0 OR Elastic License 2.0'],
'@elastic/eui@37.1.1': ['SSPL-1.0 OR Elastic License 2.0'],

// TODO can be removed if the https://github.com/jindw/xmldom/issues/239 is released
'xmldom@0.1.27': ['MIT'],
Expand Down
16 changes: 16 additions & 0 deletions src/dev/typescript/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ export const PROJECTS = [
createProject('x-pack/plugins/security_solution/cypress/tsconfig.json', {
name: 'security_solution/cypress',
}),
createProject(
'x-pack/plugins/enterprise_search/public/applications/shared/cypress/tsconfig.json',
{ name: 'enterprise_search/shared/cypress' }
),
createProject(
'x-pack/plugins/enterprise_search/public/applications/enterprise_search/cypress/tsconfig.json',
{ name: 'enterprise_search/overview/cypress' }
),
createProject(
'x-pack/plugins/enterprise_search/public/applications/app_search/cypress/tsconfig.json',
{ name: 'enterprise_search/app_search/cypress' }
),
createProject(
'x-pack/plugins/enterprise_search/public/applications/workplace_search/cypress/tsconfig.json',
{ name: 'enterprise_search/workplace_search/cypress' }
),
createProject('x-pack/plugins/osquery/cypress/tsconfig.json', {
name: 'osquery/cypress',
}),
Expand Down
Loading

0 comments on commit 551c1d5

Please sign in to comment.