Skip to content

Commit

Permalink
Merge branch 'master' into move-index-patterns-to-new-plugins-2
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Nov 28, 2019
2 parents 676f2be + 1367814 commit 5b70c21
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 13 deletions.
10 changes: 10 additions & 0 deletions test/visual_regression/tests/discover/chart_visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function ({ getService, getPageObjects }) {
const kibanaServer = getService('kibanaServer');
const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker']);
const visualTesting = getService('visualTesting');
const find = getService('find');
const defaultSettings = {
defaultIndex: 'logstash-*',
'discover:sampleSize': 1
Expand All @@ -48,10 +49,12 @@ export default function ({ getService, getPageObjects }) {

describe('query', function () {
this.tags(['skipFirefox']);
let renderCounter = 0;

it('should show bars in the correct time zone', async function () {
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
await PageObjects.discover.waitUntilSearchingHasFinished();
await find.byCssSelector(`.echChart[data-ech-render-count="${++renderCounter}"]`);
await visualTesting.snapshot({
show: ['discoverChart'],
});
Expand All @@ -61,6 +64,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
await PageObjects.discover.waitUntilSearchingHasFinished();
await PageObjects.discover.setChartInterval('Hourly');
await find.byCssSelector(`.echChart[data-ech-render-count="${++renderCounter}"]`);
await visualTesting.snapshot({
show: ['discoverChart'],
});
Expand All @@ -70,6 +74,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
await PageObjects.discover.waitUntilSearchingHasFinished();
await PageObjects.discover.setChartInterval('Daily');
await find.byCssSelector(`.echChart[data-ech-render-count="${++renderCounter}"]`);
await visualTesting.snapshot({
show: ['discoverChart'],
});
Expand All @@ -79,6 +84,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
await PageObjects.discover.waitUntilSearchingHasFinished();
await PageObjects.discover.setChartInterval('Weekly');
await find.byCssSelector(`.echChart[data-ech-render-count="${++renderCounter}"]`);
await visualTesting.snapshot({
show: ['discoverChart'],
});
Expand All @@ -92,6 +98,7 @@ export default function ({ getService, getPageObjects }) {
});
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
await PageObjects.discover.waitUntilSearchingHasFinished();
await find.byCssSelector(`.echChart[data-ech-render-count="${++renderCounter}"]`);
await visualTesting.snapshot({
show: ['discoverChart'],
});
Expand All @@ -101,6 +108,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
await PageObjects.discover.waitUntilSearchingHasFinished();
await PageObjects.discover.setChartInterval('Monthly');
await find.byCssSelector(`.echChart[data-ech-render-count="${++renderCounter}"]`);
await visualTesting.snapshot({
show: ['discoverChart'],
});
Expand All @@ -110,6 +118,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
await PageObjects.discover.waitUntilSearchingHasFinished();
await PageObjects.discover.setChartInterval('Yearly');
await find.byCssSelector(`.echChart[data-ech-render-count="${++renderCounter}"]`);
await visualTesting.snapshot({
show: ['discoverChart'],
});
Expand All @@ -119,6 +128,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
await PageObjects.discover.waitUntilSearchingHasFinished();
await PageObjects.discover.setChartInterval('Auto');
await find.byCssSelector(`.echChart[data-ech-render-count="${++renderCounter}"]`);
await visualTesting.snapshot({
show: ['discoverChart'],
});
Expand Down
7 changes: 3 additions & 4 deletions x-pack/legacy/plugins/actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ action types.

## Usage

1. Enable the actions plugin in the `kibana.yml` by setting `xpack.actions.enabled: true`.
2. Develop and register an action type (see action types -> example).
3. Create an action by using the RESTful API (see actions -> create action).
4. Use alerts to execute actions or execute manually (see firing actions).
1. Develop and register an action type (see action types -> example).
2. Create an action by using the RESTful API (see actions -> create action).
3. Use alerts to execute actions or execute manually (see firing actions).

## Kibana Actions Configuration
Implemented under the [Actions Config](./server/actions_config.ts).
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function actions(kibana: any) {
config(Joi: Root) {
return Joi.object()
.keys({
enabled: Joi.boolean().default(false),
enabled: Joi.boolean().default(true),
whitelistedHosts: Joi.array()
.items(
Joi.string()
Expand Down
5 changes: 2 additions & 3 deletions x-pack/legacy/plugins/alerting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ A Kibana alert detects a condition and executes one or more actions when that co

## Usage

1. Enable the alerting plugin in the `kibana.yml` by setting `xpack.alerting.enabled: true`.
2. Develop and register an alert type (see alert types -> example).
3. Create an alert using the RESTful API (see alerts -> create).
1. Develop and register an alert type (see alert types -> example).
2. Create an alert using the RESTful API (see alerts -> create).

## Limitations

Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/alerting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function alerting(kibana: any) {
config(Joi: Root) {
return Joi.object()
.keys({
enabled: Joi.boolean().default(false),
enabled: Joi.boolean().default(true),
})
.default();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ test('createAPIKey() returns { created: false } when security is disabled', asyn
expect(createAPIKeyResult).toEqual({ created: false });
});

test('createAPIKey() returns { created: false } when security is enabled but ES security is disabled', async () => {
const factory = new AlertsClientFactory(alertsClientFactoryParams);
factory.create(KibanaRequest.from(fakeRequest), fakeRequest);
const constructorCall = jest.requireMock('../alerts_client').AlertsClient.mock.calls[0][0];

securityPluginSetup.authc.createAPIKey.mockResolvedValueOnce(null);
const createAPIKeyResult = await constructorCall.createAPIKey();
expect(createAPIKeyResult).toEqual({ created: false });
});

test('createAPIKey() returns an API key when security is enabled', async () => {
const factory = new AlertsClientFactory({
...alertsClientFactoryParams,
Expand All @@ -105,3 +115,17 @@ test('createAPIKey() returns an API key when security is enabled', async () => {
const createAPIKeyResult = await constructorCall.createAPIKey();
expect(createAPIKeyResult).toEqual({ created: true, result: { api_key: '123', id: 'abc' } });
});

test('createAPIKey() throws when security plugin createAPIKey throws an error', async () => {
const factory = new AlertsClientFactory({
...alertsClientFactoryParams,
securityPluginSetup: securityPluginSetup as any,
});
factory.create(KibanaRequest.from(fakeRequest), fakeRequest);
const constructorCall = jest.requireMock('../alerts_client').AlertsClient.mock.calls[0][0];

securityPluginSetup.authc.createAPIKey.mockRejectedValueOnce(new Error('TLS disabled'));
await expect(constructorCall.createAPIKey()).rejects.toThrowErrorMatchingInlineSnapshot(
`"TLS disabled"`
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ export class AlertsClientFactory {
if (!securityPluginSetup) {
return { created: false };
}
const createAPIKeyResult = await securityPluginSetup.authc.createAPIKey(request, {
name: `source: alerting, generated uuid: "${uuid.v4()}"`,
role_descriptors: {},
});
if (!createAPIKeyResult) {
return { created: false };
}
return {
created: true,
result: (await securityPluginSetup.authc.createAPIKey(request, {
name: `source: alerting, generated uuid: "${uuid.v4()}"`,
role_descriptors: {},
}))!,
result: createAPIKeyResult,
};
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ export default function({ getService }: FtrProviderContext) {
'maps',
'uptime',
'siem',
'alerting',
'actions',
].sort()
);
});
Expand Down
2 changes: 2 additions & 0 deletions x-pack/test/api_integration/apis/security/privileges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export default function({ getService }: FtrProviderContext) {
uptime: ['all', 'read'],
apm: ['all', 'read'],
siem: ['all', 'read'],
actions: ['all', 'read'],
alerting: ['all', 'read'],
},
global: ['all', 'read'],
space: ['all', 'read'],
Expand Down

0 comments on commit 5b70c21

Please sign in to comment.