Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into kbn-54375-migrate…
Browse files Browse the repository at this point in the history
…-bootstrap-endpoint
  • Loading branch information
pgayvallet committed Mar 10, 2021
2 parents 793ce95 + 8a01d86 commit e117889
Show file tree
Hide file tree
Showing 66 changed files with 811 additions and 536 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@
"json5": "^1.0.1",
"jsondiffpatch": "0.4.1",
"jsts": "^1.6.2",
"kea": "^2.2.0",
"kea": "^2.3.0",
"keymirror": "0.1.1",
"leaflet": "1.5.1",
"leaflet-draw": "0.4.14",
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14759,14 +14759,15 @@ var isWin32 = __webpack_require__(121).platform() === 'win32';

var slash = '/';
var backslash = /\\/g;
var enclosure = /[\{\[].*[\/]*.*[\}\]]$/;
var enclosure = /[\{\[].*[\}\]]$/;
var globby = /(^|[^\\])([\{\[]|\([^\)]+$)/;
var escaped = /\\([\!\*\?\|\[\]\(\)\{\}])/g;

/**
* @param {string} str
* @param {Object} opts
* @param {boolean} [opts.flipBackslashes=true]
* @returns {string}
*/
module.exports = function globParent(str, opts) {
var options = Object.assign({ flipBackslashes: true }, opts);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ RUN groupadd --gid 1000 kibana && \
--home-dir /usr/share/kibana --no-create-home \
kibana

USER kibana

ENTRYPOINT ["/bin/tini", "--"]

CMD ["/usr/local/bin/kibana-docker"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,18 @@ export function getTopNavConfig(
const navItems: TopNavMenuData[] = [
getOptionsConfig(actions[TopNavIds.OPTIONS], disableButton),
getShareConfig(actions[TopNavIds.SHARE], disableButton),
getViewConfig(actions[TopNavIds.EXIT_EDIT_MODE], disableButton),
getSaveConfig(actions[TopNavIds.SAVE], options.isNewDashboard, disableButton),
];
if (!options.isNewDashboard) {
navItems.push(
getSaveConfig(actions[TopNavIds.SAVE], options.isNewDashboard, disableButton)
);
navItems.push(getViewConfig(actions[TopNavIds.EXIT_EDIT_MODE], disableButton));
navItems.push(getQuickSave(actions[TopNavIds.QUICK_SAVE], disableButton, options.isDirty));
} else {
navItems.push(getViewConfig(actions[TopNavIds.EXIT_EDIT_MODE], true));
navItems.push(
getSaveConfig(actions[TopNavIds.SAVE], options.isNewDashboard, disableButton)
);
}
return navItems;
default:
Expand Down Expand Up @@ -151,7 +158,7 @@ function getViewConfig(action: NavAction, disableButton?: boolean) {
disableButton,
id: 'cancel',
label: i18n.translate('dashboard.topNave.cancelButtonAriaLabel', {
defaultMessage: 'Cancel',
defaultMessage: 'Switch to view mode',
}),
description: i18n.translate('dashboard.topNave.viewConfigDescription', {
defaultMessage: 'Switch to view-only mode',
Expand Down
4 changes: 2 additions & 2 deletions test/functional/apps/dashboard/dashboard_listing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const listingTable = getService('listingTable');

// FLAKY: https://github.com/elastic/kibana/issues/86948
describe.skip('dashboard listing page', function describeIndexTests() {
describe('dashboard listing page', function describeIndexTests() {
const dashboardName = 'Dashboard Listing Test';

before(async function () {
Expand Down Expand Up @@ -126,7 +126,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(onDashboardLandingPage).to.equal(false);
});

it.skip('title match is case insensitive', async function () {
it('title match is case insensitive', async function () {
await PageObjects.dashboard.gotoDashboardLandingPage();
const currentUrl = await browser.getCurrentUrl();
const newUrl = currentUrl + '&title=two%20words';
Expand Down
5 changes: 2 additions & 3 deletions x-pack/plugins/actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,9 @@ This is the primary function for an action type. Whenever the action needs to ex
| --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| actionId | The action saved object id that the action type is executing for. |
| config | The action configuration. If you would like to validate the config before being passed to the executor, define `validate.config` within the action type. |
| secrets | The decrypted secrets object given to an action. This comes from the action saved object that is partially or fully encrypted within the data store. If you would like to validate the secrets object before being passed to the executor, define `validate.secrets` within the action type. |
| secrets | The decrypted secrets object given to an action. This comes from the action saved object that is partially or fully encrypted within the data store. If you would like to validate the secrets object before being passed to the executor, define `validate.secrets` within the action type. |
| params | Parameters for the execution. These will be given at execution time by either an alert or manually provided when calling the plugin provided execute function. |
| services.callCluster(path, opts) | Use this to do Elasticsearch queries on the cluster Kibana connects to. This function is the same as any other `callCluster` in Kibana but runs in the context of the user who is calling the action when security is enabled. |
| services.getLegacyScopedClusterClient | This function returns an instance of the LegacyScopedClusterClient scoped to the user who is calling the action when security is enabled. |
| services.scopedClusterClient | Use this to do Elasticsearch queries on the cluster Kibana connects to. Serves the same purpose as the normal IClusterClient, but exposes an additional `asCurrentUser` method that doesn't use credentials of the Kibana internal user (as `asInternalUser` does) to request Elasticsearch API, but rather passes HTTP headers extracted from the current user request to the API instead.|
| services.savedObjectsClient | This is an instance of the saved objects client. This provides the ability to do CRUD on any saved objects within the same space the alert lives in.<br><br>The scope of the saved objects client is tied to the user in context calling the execute API or the API key provided to the execute plugin function (only when security isenabled). |
| services.log(tags, [data], [timestamp]) | Use this to create server logs. (This is the same function as server.log)

Expand Down
88 changes: 51 additions & 37 deletions x-pack/plugins/actions/server/actions_client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { actionExecutorMock } from './lib/action_executor.mock';
import uuid from 'uuid';
import { ActionsAuthorization } from './authorization/actions_authorization';
import { actionsAuthorizationMock } from './authorization/actions_authorization.mock';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { elasticsearchClientMock } from '../../../../src/core/server/elasticsearch/client/mocks';

jest.mock('../../../../src/core/server/saved_objects/service/lib/utils', () => ({
SavedObjectsUtils: {
Expand All @@ -36,7 +38,7 @@ jest.mock('../../../../src/core/server/saved_objects/service/lib/utils', () => (

const defaultKibanaIndex = '.kibana';
const unsecuredSavedObjectsClient = savedObjectsClientMock.create();
const scopedClusterClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
const scopedClusterClient = elasticsearchServiceMock.createScopedClusterClient();
const actionExecutor = actionExecutorMock.create();
const authorization = actionsAuthorizationMock.create();
const executionEnqueuer = jest.fn();
Expand Down Expand Up @@ -741,12 +743,14 @@ describe('getAll()', () => {
],
};
unsecuredSavedObjectsClient.find.mockResolvedValueOnce(expectedResult);
scopedClusterClient.callAsInternalUser.mockResolvedValueOnce({
aggregations: {
'1': { doc_count: 6 },
testPreconfigured: { doc_count: 2 },
},
});
scopedClusterClient.asInternalUser.search.mockResolvedValueOnce(
elasticsearchClientMock.createSuccessTransportRequestPromise({
aggregations: {
'1': { doc_count: 6 },
testPreconfigured: { doc_count: 2 },
},
})
);

actionsClient = new ActionsClient({
actionTypeRegistry,
Expand Down Expand Up @@ -812,12 +816,14 @@ describe('getAll()', () => {
},
],
});
scopedClusterClient.callAsInternalUser.mockResolvedValueOnce({
aggregations: {
'1': { doc_count: 6 },
testPreconfigured: { doc_count: 2 },
},
});
scopedClusterClient.asInternalUser.search.mockResolvedValueOnce(
elasticsearchClientMock.createSuccessTransportRequestPromise({
aggregations: {
'1': { doc_count: 6 },
testPreconfigured: { doc_count: 2 },
},
})
);

await actionsClient.getAll();

Expand Down Expand Up @@ -870,12 +876,14 @@ describe('getAll()', () => {
],
};
unsecuredSavedObjectsClient.find.mockResolvedValueOnce(expectedResult);
scopedClusterClient.callAsInternalUser.mockResolvedValueOnce({
aggregations: {
'1': { doc_count: 6 },
testPreconfigured: { doc_count: 2 },
},
});
scopedClusterClient.asInternalUser.search.mockResolvedValueOnce(
elasticsearchClientMock.createSuccessTransportRequestPromise({
aggregations: {
'1': { doc_count: 6 },
testPreconfigured: { doc_count: 2 },
},
})
);

actionsClient = new ActionsClient({
actionTypeRegistry,
Expand Down Expand Up @@ -940,12 +948,14 @@ describe('getBulk()', () => {
},
],
});
scopedClusterClient.callAsInternalUser.mockResolvedValueOnce({
aggregations: {
'1': { doc_count: 6 },
testPreconfigured: { doc_count: 2 },
},
});
scopedClusterClient.asInternalUser.search.mockResolvedValueOnce(
elasticsearchClientMock.createSuccessTransportRequestPromise({
aggregations: {
'1': { doc_count: 6 },
testPreconfigured: { doc_count: 2 },
},
})
);

actionsClient = new ActionsClient({
actionTypeRegistry,
Expand Down Expand Up @@ -1008,12 +1018,14 @@ describe('getBulk()', () => {
},
],
});
scopedClusterClient.callAsInternalUser.mockResolvedValueOnce({
aggregations: {
'1': { doc_count: 6 },
testPreconfigured: { doc_count: 2 },
},
});
scopedClusterClient.asInternalUser.search.mockResolvedValueOnce(
elasticsearchClientMock.createSuccessTransportRequestPromise({
aggregations: {
'1': { doc_count: 6 },
testPreconfigured: { doc_count: 2 },
},
})
);

await actionsClient.getBulk(['1']);

Expand Down Expand Up @@ -1063,12 +1075,14 @@ describe('getBulk()', () => {
},
],
});
scopedClusterClient.callAsInternalUser.mockResolvedValueOnce({
aggregations: {
'1': { doc_count: 6 },
testPreconfigured: { doc_count: 2 },
},
});
scopedClusterClient.asInternalUser.search.mockResolvedValueOnce(
elasticsearchClientMock.createSuccessTransportRequestPromise({
aggregations: {
'1': { doc_count: 6 },
testPreconfigured: { doc_count: 2 },
},
})
);

actionsClient = new ActionsClient({
actionTypeRegistry,
Expand Down
10 changes: 5 additions & 5 deletions x-pack/plugins/actions/server/actions_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Boom from '@hapi/boom';
import { i18n } from '@kbn/i18n';
import { omitBy, isUndefined } from 'lodash';
import {
ILegacyScopedClusterClient,
IScopedClusterClient,
SavedObjectsClientContract,
SavedObjectAttributes,
SavedObject,
Expand Down Expand Up @@ -62,7 +62,7 @@ export interface CreateOptions {

interface ConstructorOptions {
defaultKibanaIndex: string;
scopedClusterClient: ILegacyScopedClusterClient;
scopedClusterClient: IScopedClusterClient;
actionTypeRegistry: ActionTypeRegistry;
unsecuredSavedObjectsClient: SavedObjectsClientContract;
preconfiguredActions: PreConfiguredAction[];
Expand All @@ -80,7 +80,7 @@ export interface UpdateOptions {

export class ActionsClient {
private readonly defaultKibanaIndex: string;
private readonly scopedClusterClient: ILegacyScopedClusterClient;
private readonly scopedClusterClient: IScopedClusterClient;
private readonly unsecuredSavedObjectsClient: SavedObjectsClientContract;
private readonly actionTypeRegistry: ActionTypeRegistry;
private readonly preconfiguredActions: PreConfiguredAction[];
Expand Down Expand Up @@ -506,7 +506,7 @@ function actionFromSavedObject(savedObject: SavedObject<RawAction>): ActionResul

async function injectExtraFindData(
defaultKibanaIndex: string,
scopedClusterClient: ILegacyScopedClusterClient,
scopedClusterClient: IScopedClusterClient,
actionResults: ActionResult[]
): Promise<FindActionResult[]> {
const aggs: Record<string, unknown> = {};
Expand Down Expand Up @@ -543,7 +543,7 @@ async function injectExtraFindData(
},
};
}
const aggregationResult = await scopedClusterClient.callAsInternalUser('search', {
const { body: aggregationResult } = await scopedClusterClient.asInternalUser.search({
index: defaultKibanaIndex,
body: {
aggs,
Expand Down
Loading

0 comments on commit e117889

Please sign in to comment.