Skip to content

Commit 9308223

Browse files
Merge branch 'master' into embeddable-maps
2 parents 473876c + 785b916 commit 9308223

143 files changed

Lines changed: 3319 additions & 1782 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
"fast-deep-equal": "^3.1.1",
175175
"file-loader": "4.2.0",
176176
"font-awesome": "4.7.0",
177+
"fp-ts": "^2.3.1",
177178
"getos": "^3.1.0",
178179
"glob": "^7.1.2",
179180
"glob-all": "^3.1.0",
@@ -188,6 +189,7 @@
188189
"hoek": "^5.0.4",
189190
"http-proxy-agent": "^2.1.0",
190191
"https-proxy-agent": "^2.2.2",
192+
"immer": "^1.5.0",
191193
"inert": "^5.1.0",
192194
"inline-style": "^2.0.0",
193195
"joi": "^13.5.2",

src/cli/serve/serve.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,23 +140,12 @@ function applyConfigOverrides(rawConfig, opts, extraCliOptions) {
140140
}
141141

142142
set('plugins.scanDirs', _.compact([].concat(get('plugins.scanDirs'), opts.pluginDir)));
143-
144143
set(
145144
'plugins.paths',
146145
_.compact(
147146
[].concat(
148147
get('plugins.paths'),
149148
opts.pluginPath,
150-
opts.runExamples
151-
? [
152-
// Ideally this would automatically include all plugins in the examples dir
153-
fromRoot('examples/demo_search'),
154-
fromRoot('examples/search_explorer'),
155-
fromRoot('examples/embeddable_examples'),
156-
fromRoot('examples/embeddable_explorer'),
157-
]
158-
: [],
159-
160149
XPACK_INSTALLED && !opts.oss ? [XPACK_DIR] : []
161150
)
162151
)
@@ -253,6 +242,7 @@ export default function(program) {
253242
silent: !!opts.silent,
254243
watch: !!opts.watch,
255244
repl: !!opts.repl,
245+
runExamples: !!opts.runExamples,
256246
// We want to run without base path when the `--run-examples` flag is given so that we can use local
257247
// links in other documentation sources, like "View this tutorial [here](http://localhost:5601/app/tutorial/xyz)".
258248
// We can tell users they only have to run with `yarn start --run-examples` to get those

src/core/server/config/__mocks__/env.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export function getEnvOptions(options: DeepPartial<EnvOptions> = {}): EnvOptions
3838
basePath: false,
3939
optimize: false,
4040
oss: false,
41+
runExamples: false,
4142
...(options.cliArgs || {}),
4243
},
4344
isDevClusterMaster:

src/core/server/config/__snapshots__/env.test.ts.snap

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/server/config/deprecation/core_deprecations.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ export const coreDeprecationProvider: ConfigDeprecationProvider = ({
9797
}) => [
9898
unusedFromRoot('savedObjects.indexCheckTimeout'),
9999
unusedFromRoot('server.xsrf.token'),
100-
unusedFromRoot('uiSettings.enabled'),
101100
renameFromRoot('optimize.lazy', 'optimize.watch'),
102101
renameFromRoot('optimize.lazyPort', 'optimize.watchPort'),
103102
renameFromRoot('optimize.lazyHost', 'optimize.watchHost'),

src/core/server/config/env.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,25 @@ test('pluginSearchPaths does not contains x-pack plugins path if --oss flag is t
152152

153153
expect(env.pluginSearchPaths).not.toContain('/some/home/dir/x-pack/plugins');
154154
});
155+
156+
test('pluginSearchPaths contains examples plugins path if --run-examples flag is true', () => {
157+
const env = new Env(
158+
'/some/home/dir',
159+
getEnvOptions({
160+
cliArgs: { runExamples: true },
161+
})
162+
);
163+
164+
expect(env.pluginSearchPaths).toContain('/some/home/dir/examples');
165+
});
166+
167+
test('pluginSearchPaths does not contains examples plugins path if --run-examples flag is false', () => {
168+
const env = new Env(
169+
'/some/home/dir',
170+
getEnvOptions({
171+
cliArgs: { runExamples: false },
172+
})
173+
);
174+
175+
expect(env.pluginSearchPaths).not.toContain('/some/home/dir/examples');
176+
});

src/core/server/config/env.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export interface CliArgs {
4343
optimize: boolean;
4444
open: boolean;
4545
oss: boolean;
46+
runExamples: boolean;
4647
}
4748

4849
export class Env {
@@ -61,8 +62,6 @@ export class Env {
6162
/** @internal */
6263
public readonly logDir: string;
6364
/** @internal */
64-
public readonly staticFilesDir: string;
65-
/** @internal */
6665
public readonly pluginSearchPaths: readonly string[];
6766

6867
/**
@@ -100,14 +99,14 @@ export class Env {
10099
this.configDir = resolve(this.homeDir, 'config');
101100
this.binDir = resolve(this.homeDir, 'bin');
102101
this.logDir = resolve(this.homeDir, 'log');
103-
this.staticFilesDir = resolve(this.homeDir, 'ui');
104102

105103
this.pluginSearchPaths = [
106104
resolve(this.homeDir, 'src', 'plugins'),
107-
options.cliArgs.oss ? '' : resolve(this.homeDir, 'x-pack', 'plugins'),
105+
...(options.cliArgs.oss ? [] : [resolve(this.homeDir, 'x-pack', 'plugins')]),
108106
resolve(this.homeDir, 'plugins'),
107+
...(options.cliArgs.runExamples ? [resolve(this.homeDir, 'examples')] : []),
109108
resolve(this.homeDir, '..', 'kibana-extra'),
110-
].filter(Boolean);
109+
];
111110

112111
this.cliArgs = Object.freeze(options.cliArgs);
113112
this.configs = Object.freeze(options.configs);

src/core/server/http/__snapshots__/http_config.test.ts.snap

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/server/http/cookie_session_storage.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ configService.atPath.mockReturnValue(
5858
verificationMode: 'none',
5959
},
6060
compression: { enabled: true },
61+
xsrf: {
62+
disableProtection: true,
63+
whitelist: [],
64+
},
6165
} as any)
6266
);
6367

src/core/server/http/http_config.test.ts

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919

2020
import uuid from 'uuid';
2121
import { config, HttpConfig } from '.';
22-
import { Env } from '../config';
23-
import { getEnvOptions } from '../config/__mocks__/env';
2422

2523
const validHostnames = ['www.example.com', '8.8.8.8', '::1', 'localhost'];
2624
const invalidHostname = 'asdf$%^';
2725

26+
jest.mock('os', () => ({
27+
...jest.requireActual('os'),
28+
hostname: () => 'kibana-hostname',
29+
}));
30+
2831
test('has defaults for config', () => {
2932
const httpSchema = config.schema;
3033
const obj = {};
@@ -86,6 +89,24 @@ test('accepts only valid uuids for server.uuid', () => {
8689
);
8790
});
8891

92+
test('uses os.hostname() as default for server.name', () => {
93+
const httpSchema = config.schema;
94+
const validated = httpSchema.validate({});
95+
expect(validated.name).toEqual('kibana-hostname');
96+
});
97+
98+
test('throws if xsrf.whitelist element does not start with a slash', () => {
99+
const httpSchema = config.schema;
100+
const obj = {
101+
xsrf: {
102+
whitelist: ['/valid-path', 'invalid-path'],
103+
},
104+
};
105+
expect(() => httpSchema.validate(obj)).toThrowErrorMatchingInlineSnapshot(
106+
`"[xsrf.whitelist.1]: must start with a slash"`
107+
);
108+
});
109+
89110
describe('with TLS', () => {
90111
test('throws if TLS is enabled but `key` is not specified', () => {
91112
const httpSchema = config.schema;
@@ -265,8 +286,7 @@ describe('with TLS', () => {
265286
clientAuthentication: 'none',
266287
},
267288
}),
268-
{} as any,
269-
Env.createDefault(getEnvOptions())
289+
{} as any
270290
);
271291

272292
expect(httpConfig.ssl.requestCert).toBe(false);
@@ -283,8 +303,7 @@ describe('with TLS', () => {
283303
clientAuthentication: 'optional',
284304
},
285305
}),
286-
{} as any,
287-
Env.createDefault(getEnvOptions())
306+
{} as any
288307
);
289308

290309
expect(httpConfig.ssl.requestCert).toBe(true);
@@ -301,8 +320,7 @@ describe('with TLS', () => {
301320
clientAuthentication: 'required',
302321
},
303322
}),
304-
{} as any,
305-
Env.createDefault(getEnvOptions())
323+
{} as any
306324
);
307325

308326
expect(httpConfig.ssl.requestCert).toBe(true);

0 commit comments

Comments
 (0)