Skip to content

Commit

Permalink
Merge branch 'master' into 52842_1
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Dec 17, 2019
2 parents 8c3324f + 4f5db14 commit da9d2c7
Show file tree
Hide file tree
Showing 84 changed files with 1,594 additions and 644 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ export interface CoreSetup
| [http](./kibana-plugin-server.coresetup.http.md) | <code>HttpServiceSetup</code> | [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) |
| [savedObjects](./kibana-plugin-server.coresetup.savedobjects.md) | <code>SavedObjectsServiceSetup</code> | [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md) |
| [uiSettings](./kibana-plugin-server.coresetup.uisettings.md) | <code>UiSettingsServiceSetup</code> | [UiSettingsServiceSetup](./kibana-plugin-server.uisettingsservicesetup.md) |
| [uuid](./kibana-plugin-server.coresetup.uuid.md) | <code>UuidServiceSetup</code> | [UuidServiceSetup](./kibana-plugin-server.uuidservicesetup.md) |

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [CoreSetup](./kibana-plugin-server.coresetup.md) &gt; [uuid](./kibana-plugin-server.coresetup.uuid.md)

## CoreSetup.uuid property

[UuidServiceSetup](./kibana-plugin-server.uuidservicesetup.md)

<b>Signature:</b>

```typescript
uuid: UuidServiceSetup;
```
1 change: 1 addition & 0 deletions docs/development/core/server/kibana-plugin-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [UiSettingsParams](./kibana-plugin-server.uisettingsparams.md) | UiSettings parameters defined by the plugins. |
| [UiSettingsServiceSetup](./kibana-plugin-server.uisettingsservicesetup.md) | |
| [UserProvidedValues](./kibana-plugin-server.userprovidedvalues.md) | Describes the values explicitly set by user. |
| [UuidServiceSetup](./kibana-plugin-server.uuidservicesetup.md) | APIs to access the application's instance uuid. |

## Variables

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [UuidServiceSetup](./kibana-plugin-server.uuidservicesetup.md) &gt; [getInstanceUuid](./kibana-plugin-server.uuidservicesetup.getinstanceuuid.md)

## UuidServiceSetup.getInstanceUuid() method

Retrieve the Kibana instance uuid.

<b>Signature:</b>

```typescript
getInstanceUuid(): string;
```
<b>Returns:</b>

`string`

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [UuidServiceSetup](./kibana-plugin-server.uuidservicesetup.md)

## UuidServiceSetup interface

APIs to access the application's instance uuid.

<b>Signature:</b>

```typescript
export interface UuidServiceSetup
```

## Methods

| Method | Description |
| --- | --- |
| [getInstanceUuid()](./kibana-plugin-server.uuidservicesetup.getinstanceuuid.md) | Retrieve the Kibana instance uuid. |

6 changes: 5 additions & 1 deletion docs/setup/settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,16 @@ Rollup user interface.

`i18n.locale`:: *Default: en* Set this value to change the Kibana interface language. Valid locales are: `en`, `zh-CN`, `ja-JP`.

`xpack.actions.enabledActionTypes:`:: *Default: +[ {asterisk} ]+* Set this value
to an array of action types that are enabled. An element of `*` indicates all
action types registered are enabled. The action types provided by Kibana are:
`.server-log`, `.slack`, `.email`, `.index`, `.pagerduty`, `.webhook`.

`xpack.actions.whitelistedHosts:`:: *Default: +[ {asterisk} ]+* Set this value
to an array of host names which actions such as email, slack, pagerduty, and
webhook can connect to. An element of `*` indicates any host can be connected
to. An empty array indicates no hosts can be connected to.


include::{docdir}/settings/apm-settings.asciidoc[]
include::{docdir}/settings/dev-settings.asciidoc[]
include::{docdir}/settings/graph-settings.asciidoc[]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
"hapi": "^17.5.3",
"hapi-auth-cookie": "^9.0.0",
"history": "^4.9.0",
"hjson": "3.2.0",
"hjson": "3.2.1",
"hoek": "^5.0.4",
"http-proxy-agent": "^2.1.0",
"https-proxy-agent": "^2.2.2",
Expand Down
9 changes: 9 additions & 0 deletions src/core/server/http/http_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/

import uuid from 'uuid';
import { config, HttpConfig } from '.';
import { Env } from '../config';
import { getEnvOptions } from '../config/__mocks__/env';
Expand Down Expand Up @@ -77,6 +78,14 @@ test('throws if basepath is not specified, but rewriteBasePath is set', () => {
expect(() => httpSchema.validate(obj)).toThrowErrorMatchingSnapshot();
});

test('accepts only valid uuids for server.uuid', () => {
const httpSchema = config.schema;
expect(() => httpSchema.validate({ uuid: uuid.v4() })).not.toThrow();
expect(() => httpSchema.validate({ uuid: 'not an uuid' })).toThrowErrorMatchingInlineSnapshot(
`"[uuid]: must be a valid uuid"`
);
});

describe('with TLS', () => {
test('throws if TLS is enabled but `key` is not specified', () => {
const httpSchema = config.schema;
Expand Down
6 changes: 6 additions & 0 deletions src/core/server/http/http_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { CspConfigType, CspConfig, ICspConfig } from '../csp';
import { SslConfig, sslSchema } from './ssl_config';

const validBasePathRegex = /(^$|^\/.*[^\/]$)/;
const uuidRegexp = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i;

const match = (regex: RegExp, errorMsg: string) => (str: string) =>
regex.test(str) ? undefined : errorMsg;
Expand Down Expand Up @@ -92,6 +93,11 @@ export const config = {
)
),
}),
uuid: schema.maybe(
schema.string({
validate: match(uuidRegexp, 'must be a valid uuid'),
})
),
},
{
validate: rawConfig => {
Expand Down
4 changes: 4 additions & 0 deletions src/core/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { IUiSettingsClient, UiSettingsServiceSetup } from './ui_settings';
import { SavedObjectsClientContract } from './saved_objects/types';
import { SavedObjectsServiceSetup, SavedObjectsServiceStart } from './saved_objects';
import { CapabilitiesSetup, CapabilitiesStart } from './capabilities';
import { UuidServiceSetup } from './uuid';

export { bootstrap } from './bootstrap';
export { Capabilities, CapabilitiesProvider, CapabilitiesSwitcher } from './capabilities';
Expand Down Expand Up @@ -269,6 +270,8 @@ export interface CoreSetup {
savedObjects: SavedObjectsServiceSetup;
/** {@link UiSettingsServiceSetup} */
uiSettings: UiSettingsServiceSetup;
/** {@link UuidServiceSetup} */
uuid: UuidServiceSetup;
}

/**
Expand All @@ -290,4 +293,5 @@ export {
PluginsServiceSetup,
PluginsServiceStart,
PluginOpaqueId,
UuidServiceSetup,
};
2 changes: 2 additions & 0 deletions src/core/server/internal_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
InternalSavedObjectsServiceSetup,
} from './saved_objects';
import { CapabilitiesSetup, CapabilitiesStart } from './capabilities';
import { UuidServiceSetup } from './uuid';

/** @internal */
export interface InternalCoreSetup {
Expand All @@ -35,6 +36,7 @@ export interface InternalCoreSetup {
elasticsearch: InternalElasticsearchServiceSetup;
uiSettings: InternalUiSettingsServiceSetup;
savedObjects: InternalSavedObjectsServiceSetup;
uuid: UuidServiceSetup;
}

/**
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export class LegacyObjectToConfigAdapter extends ObjectToConfigAdapter {
keepaliveTimeout: configValue.keepaliveTimeout,
socketTimeout: configValue.socketTimeout,
compression: configValue.compression,
uuid: configValue.uuid,
};
}

Expand Down
2 changes: 2 additions & 0 deletions src/core/server/legacy/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
export interface LegacyConfig {
get<T>(key?: string): T;
has(key: string): boolean;
set(key: string, value: any): void;
set(config: Record<string, any>): void;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,23 @@
* under the License.
*/

import { SavedObject } from 'ui/saved_objects/types';
import { SearchSourceContract } from '../../../../../ui/public/courier';
import { esFilters, Query, RefreshInterval } from '../../../../../../plugins/data/public';
import { LegacyServiceDiscoverPlugins } from './legacy_service';

export interface SavedObjectDashboard extends SavedObject {
id?: string;
copyOnSave: boolean;
timeRestore: boolean;
timeTo?: string;
timeFrom?: string;
title: string;
description?: string;
panelsJSON: string;
optionsJSON?: string;
// TODO: write a migration to rid of this, it's only around for bwc.
uiStateJSON?: string;
lastSavedTitle: string;
searchSource: SearchSourceContract;
destroy: () => void;
refreshInterval?: RefreshInterval;
getQuery(): Query;
getFilters(): esFilters.Filter[];
}
const createDiscoverMock = () => {
const setupContract: DeeplyMockedKeys<LegacyServiceDiscoverPlugins> = {
pluginSpecs: [],
disabledPluginSpecs: [],
uiExports: {} as any,
settings: {},
pluginExtendedConfig: {
get: jest.fn(),
has: jest.fn(),
set: jest.fn(),
} as any,
};
return setupContract;
};

export const legacyServiceMock = {
createDiscover: createDiscoverMock,
};
34 changes: 34 additions & 0 deletions src/core/server/legacy/legacy_service.test.mocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export const findLegacyPluginSpecsMock = jest
.fn()
.mockImplementation((settings: Record<string, any>) => ({
pluginSpecs: [],
pluginExtendedConfig: {
has: jest.fn(),
get: jest.fn(() => settings),
set: jest.fn(),
},
disabledPluginSpecs: [],
uiExports: [],
}));
jest.doMock('./plugins/find_legacy_plugin_specs.ts', () => ({
findLegacyPluginSpecs: findLegacyPluginSpecsMock,
}));
Loading

0 comments on commit da9d2c7

Please sign in to comment.